mirror of https://github.com/folke/lazy.nvim.git
feat(keys): include custom keys in help menu (#1105)
This commit is contained in:
parent
906ff8e569
commit
43c284a578
17
README.md
17
README.md
|
@ -371,22 +371,27 @@ return {
|
||||||
browser = nil, ---@type string?
|
browser = nil, ---@type string?
|
||||||
throttle = 20, -- how frequently should the ui process render events
|
throttle = 20, -- how frequently should the ui process render events
|
||||||
custom_keys = {
|
custom_keys = {
|
||||||
-- you can define custom key maps here.
|
-- You can define custom key maps here. If present, the description will
|
||||||
-- To disable one of the defaults, set it to false
|
-- be shown in the help menu.
|
||||||
|
-- To disable one of the defaults, set it to false.
|
||||||
|
|
||||||
-- open lazygit log
|
["<localleader>l"] = {
|
||||||
["<localleader>l"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term({ "lazygit", "log" }, {
|
require("lazy.util").float_term({ "lazygit", "log" }, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open lazygit log",
|
||||||
|
},
|
||||||
|
|
||||||
-- open a terminal for the plugin dir
|
["<localleader>t"] = {
|
||||||
["<localleader>t"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term(nil, {
|
require("lazy.util").float_term(nil, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open terminal in plugin dir",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
diff = {
|
diff = {
|
||||||
|
|
|
@ -473,22 +473,27 @@ CONFIGURATION *lazy.nvim-lazy.nvim-configuration*
|
||||||
browser = nil, ---@type string?
|
browser = nil, ---@type string?
|
||||||
throttle = 20, -- how frequently should the ui process render events
|
throttle = 20, -- how frequently should the ui process render events
|
||||||
custom_keys = {
|
custom_keys = {
|
||||||
-- you can define custom key maps here.
|
-- You can define custom key maps here. If present, the description will
|
||||||
-- To disable one of the defaults, set it to false
|
-- be shown in the help menu.
|
||||||
|
-- To disable one of the defaults, set it to false.
|
||||||
|
|
||||||
-- open lazygit log
|
["<localleader>l"] = {
|
||||||
["<localleader>l"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term({ "lazygit", "log" }, {
|
require("lazy.util").float_term({ "lazygit", "log" }, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open lazygit log",
|
||||||
|
},
|
||||||
|
|
||||||
-- open a terminal for the plugin dir
|
["<localleader>t"] = {
|
||||||
["<localleader>t"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term(nil, {
|
require("lazy.util").float_term(nil, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open terminal in plugin dir",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
diff = {
|
diff = {
|
||||||
|
|
|
@ -81,22 +81,27 @@ M.defaults = {
|
||||||
browser = nil, ---@type string?
|
browser = nil, ---@type string?
|
||||||
throttle = 20, -- how frequently should the ui process render events
|
throttle = 20, -- how frequently should the ui process render events
|
||||||
custom_keys = {
|
custom_keys = {
|
||||||
-- you can define custom key maps here.
|
-- You can define custom key maps here. If present, the description will
|
||||||
-- To disable one of the defaults, set it to false
|
-- be shown in the help menu.
|
||||||
|
-- To disable one of the defaults, set it to false.
|
||||||
|
|
||||||
-- open lazygit log
|
["<localleader>l"] = {
|
||||||
["<localleader>l"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term({ "lazygit", "log" }, {
|
require("lazy.util").float_term({ "lazygit", "log" }, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open lazygit log",
|
||||||
|
},
|
||||||
|
|
||||||
-- open a terminal for the plugin dir
|
["<localleader>t"] = {
|
||||||
["<localleader>t"] = function(plugin)
|
function(plugin)
|
||||||
require("lazy.util").float_term(nil, {
|
require("lazy.util").float_term(nil, {
|
||||||
cwd = plugin.dir,
|
cwd = plugin.dir,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
desc = "Open terminal in plugin dir",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
diff = {
|
diff = {
|
||||||
|
|
|
@ -121,9 +121,10 @@ function M.create()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for key, handler in pairs(Config.options.ui.custom_keys) do
|
for lhs, rhs in pairs(Config.options.ui.custom_keys) do
|
||||||
if handler then
|
if rhs then
|
||||||
self:on_key(key, function()
|
local handler = type(rhs) == "table" and rhs[1] or rhs
|
||||||
|
self:on_key(lhs, function()
|
||||||
local plugin = self.render:get_plugin()
|
local plugin = self.render:get_plugin()
|
||||||
if plugin then
|
if plugin then
|
||||||
handler(plugin)
|
handler(plugin)
|
||||||
|
|
|
@ -209,6 +209,14 @@ function M:help()
|
||||||
self:append(" " .. (mode.desc_plugin or mode.desc)):nl()
|
self:append(" " .. (mode.desc_plugin or mode.desc)):nl()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for lhs, rhs in pairs(Config.options.ui.custom_keys) do
|
||||||
|
if type(rhs) == "table" and rhs.desc then
|
||||||
|
self:append("- ", "LazySpecial", { indent = 2 })
|
||||||
|
self:append("Custom key ", "Title")
|
||||||
|
self:append(lhs, "LazyProp")
|
||||||
|
self:append(" " .. rhs.desc):nl()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:progressbar()
|
function M:progressbar()
|
||||||
|
|
Loading…
Reference in New Issue