From 38d9dc76b4fad5afb827ee7a2e05777fa05e31c8 Mon Sep 17 00:00:00 2001 From: psychhim Date: Wed, 10 Dec 2025 03:53:55 +0530 Subject: [PATCH] Update: alpha buttons --- lua/plugins/custom/alpha.lua | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lua/plugins/custom/alpha.lua b/lua/plugins/custom/alpha.lua index 93b0b02..7267fe3 100644 --- a/lua/plugins/custom/alpha.lua +++ b/lua/plugins/custom/alpha.lua @@ -59,19 +59,39 @@ return { vim.cmd 'enew' vim.cmd 'startinsert' end + _G.new_file_alpha = new_file_alpha + + -- Recent files button handling + _G.open_telescope_oldfiles = function() + vim.schedule(function() + local keymaps = vim.api.nvim_get_keymap 'n' + local leader = vim.g.mapleader or '\\' + local target_key = leader .. '?' + for _, map in ipairs(keymaps) do + if map.lhs == target_key then + if map.callback then + map.callback() + elseif map.rhs then + vim.cmd(map.rhs) + end + return + end + end + end) + end -- Setup buttons dashboard.section.buttons.val = { -- New file - dashboard.button('i', ' New File', new_file_alpha), - -- Create new tab and open Alpha - dashboard.button('e', ' New Tab', 'tabnewlua require("alpha").start(true)'), + dashboard.button('i', ' New File', 'lua new_file_alpha()'), + -- Recent files + dashboard.button('?', ' Recent Files', 'lua open_telescope_oldfiles()'), -- Open Neo-tree in current directory - dashboard.button('n', ' Open Neo-tree', 'Neotree toggle float'), + dashboard.button('n', ' File-tree', 'Neotree toggle float'), -- Close Alpha window or quit Neovim dashboard.button( 'q', - ' Exit', + ' Close', 'lua (function() local wins = vim.api.nvim_tabpage_list_wins(0) if #wins > 1 then vim.cmd("close") else local tab_count = #vim.api.nvim_list_tabpages() if tab_count > 1 then vim.cmd("tabclose") else vim.cmd("qa!") end end end)()' ), }