summaryrefslogtreecommitdiffstatshomepage
path: root/nvim
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-10-12 13:27:44 -0500
committerToby Vincent <tobyv13@gmail.com>2022-10-12 13:27:44 -0500
commit2a667a938800398219f4b242b5bd6e9b30398d13 (patch)
treebbf4a7f1e0eb0fe3ee80af8b3d822c5c3a84efc5 /nvim
parent18c144b5facd3fc7dc2b24b9b9c0382fffed8d84 (diff)
feat(nvim): improve alpha keymaps
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua26
1 files changed, 23 insertions, 3 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
index 66b6881..e101200 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
@@ -38,8 +38,9 @@ M.button = function(sc, txt, keybind, keybind_opts)
}
if keybind then
- keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true })
- opts.keymap = { "n", sc_, keybind, { noremap = false, silent = true, nowait = true } }
+ keybind_opts = vim.F.if_nil(keybind_opts, {})
+ keybind_opts.desc = vim.F.if_nil(keybind_opts.desc, txt)
+ opts.keymap = { "n", sc_, keybind, keybind_opts }
end
local function on_press()
@@ -69,7 +70,7 @@ M.file_button = function(filename, sc)
if fn_start ~= nil then
table.insert(hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
end
- local button = M.button(sc, ico_txt .. short_fn, "<Cmd>e " .. filename .. " <CR>")
+ local button = M.button(sc, ico_txt .. short_fn, "<Cmd>e " .. filename .. " <CR>", { desc = "oldfile_" .. sc })
button.opts.hl = hl
button.opts.cursor = M.width - 1
return button
@@ -106,11 +107,15 @@ end
M.actions_cache = nil
M.actions = function()
if M.actions_cache == nil then
+ local builtins = require("telescope.builtin")
+ local neogit = require("neogit")
M.actions_cache = {
{
type = "group",
val = {
M.button("e", "new", "<cmd>enew<cr>"),
+ M.button("f", "find", builtins.find_files),
+ M.button("g", "git", neogit.open),
M.button("s", "session", "<cmd>SessionManager load_current_dir_session<cr>"),
M.button("q", "quit", "<cmd>qa<cr>"),
},
@@ -127,6 +132,21 @@ M.setup = function()
return
end
+ alpha.keymaps_element.button = function(el, _, state)
+ if el.opts and el.opts.keymap then
+ if type(el.opts.keymap[1]) == "table" then
+ for _, map in el.opts.keymap do
+ map[4].buffer = state.buffer
+ vim.keymap.set(unpack(map))
+ end
+ else
+ local map = el.opts.keymap
+ map[4].buffer = state.buffer
+ vim.keymap.set(unpack(map))
+ end
+ end
+ end
+
local fortune = require("alpha.fortune")
local logo = {