-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Describe the solution you'd like
It would be awesome if keymaps could also accept a desc field.
That would mean that probably the structure would have to change for the current callback to be a table instead of a function, so it accepts multiple fields that can be used in vim.keymap.set. Currently this is the diff I made locally, but because I am new to programming I'm not that confident to create a PR for this and maybe there are other side-effects I'm not able to think of, but I believe should give you the gist about what has to change in general
diff --git a/lua/vgit/core/keymap.lua b/lua/vgit/core/keymap.lua
index e3720b7..393ee57 100644
--- a/lua/vgit/core/keymap.lua
+++ b/lua/vgit/core/keymap.lua
@@ -12,17 +12,18 @@ local function parse_commands(commands)
return parsed_commands
end
-function keymap.set(mode, key, callback)
+function keymap.set(mode, key, callback, desc)
if type(callback) == 'string' then
vim.api.nvim_set_keymap(mode, key, string.format('<Cmd>lua require("vgit").%s()<CR>', callback), {
noremap = true,
silent = true,
+ desc = desc,
})
return keymap
end
- vim.keymap.set(mode, key, callback, { silent = true, noremap = true })
+ vim.keymap.set(mode, key, callback, { desc = desc, silent = true, noremap = true })
return keymap
end
@@ -36,7 +37,14 @@ end
function keymap.define(keymaps)
for commands, callback in pairs(keymaps) do
commands = parse_commands(commands)
- keymap.set(commands[1], commands[2], callback)
+ local desc = nil
+ if type(callback) == 'table' then
+ desc = callback.desc
+ callback = callback[1]
+ keymap.set(commands[1], commands[2], callback, desc)
+ else
+ keymap.set(commands[1], commands[2], callback)
+ end
end
return keymaptanvirtin
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request