mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
refactor(commands): move ui/commands config to separate file
This commit is contained in:
parent
c1f39f997d
commit
83270cc5e5
6 changed files with 195 additions and 86 deletions
138
lua/lazy/view/config.lua
Normal file
138
lua/lazy/view/config.lua
Normal file
|
@ -0,0 +1,138 @@
|
|||
local M = {}
|
||||
|
||||
---@class LazyViewCommand
|
||||
---@field id number
|
||||
---@field plugins? boolean
|
||||
---@field plugins_required? boolean
|
||||
---@field button? boolean
|
||||
---@field desc? string
|
||||
---@field desc_plugin? string
|
||||
---@field key? string
|
||||
---@field key_plugin? string
|
||||
---@field toggle? boolean
|
||||
|
||||
function M.get_commands()
|
||||
---@type (LazyViewCommand|{name:string})[]
|
||||
local ret = {}
|
||||
for k, v in pairs(M.commands) do
|
||||
v.name = k
|
||||
ret[#ret + 1] = v
|
||||
end
|
||||
table.sort(ret, function(a, b)
|
||||
return a.id < b.id
|
||||
end)
|
||||
return ret
|
||||
end
|
||||
|
||||
M.keys = {
|
||||
hover = "K",
|
||||
close = "q",
|
||||
details = "<cr>",
|
||||
profile_sort = "<C-s>",
|
||||
profile_filter = "<C-f>",
|
||||
}
|
||||
|
||||
---@type table<string,LazyViewCommand>
|
||||
M.commands = {
|
||||
home = {
|
||||
button = true,
|
||||
desc = "Go back to plugin list",
|
||||
id = 1,
|
||||
key = "H",
|
||||
},
|
||||
install = {
|
||||
button = true,
|
||||
desc = "Install missing plugins",
|
||||
desc_plugin = "Install a plugin",
|
||||
id = 2,
|
||||
key = "I",
|
||||
key_plugin = "i",
|
||||
plugins = true,
|
||||
},
|
||||
update = {
|
||||
button = true,
|
||||
desc = "Update plugins. This will also update the lockfile",
|
||||
desc_plugin = "Update a plugin. This will also update the lockfile",
|
||||
id = 3,
|
||||
key = "U",
|
||||
key_plugin = "u",
|
||||
plugins = true,
|
||||
},
|
||||
sync = {
|
||||
button = true,
|
||||
desc = "Run install, clean and update",
|
||||
desc_plugin = "Run install, clean and update",
|
||||
id = 4,
|
||||
key = "S",
|
||||
plugins = true,
|
||||
},
|
||||
clean = {
|
||||
button = true,
|
||||
desc = "Clean plugins that are no longer needed",
|
||||
desc_plugin = "Delete a plugin. WARNING: this will delete the plugin even if it should be installed!",
|
||||
id = 5,
|
||||
key = "X",
|
||||
key_plugin = "x",
|
||||
plugins = true,
|
||||
},
|
||||
check = {
|
||||
button = true,
|
||||
desc = "Check for updates and show the log (git fetch)",
|
||||
desc_plugin = "Check for updates and show the log (git fetch)",
|
||||
id = 6,
|
||||
key = "C",
|
||||
key_plugin = "c",
|
||||
plugins = true,
|
||||
},
|
||||
log = {
|
||||
button = true,
|
||||
desc = "Show recent updates",
|
||||
desc_plugin = "Show recent updates",
|
||||
id = 7,
|
||||
key = "L",
|
||||
key_plugin = "gl",
|
||||
plugins = true,
|
||||
},
|
||||
restore = {
|
||||
button = true,
|
||||
desc = "Updates all plugins to the state in the lockfile",
|
||||
desc_plugin = "Restore a plugin to the state in the lockfile",
|
||||
id = 8,
|
||||
key = "R",
|
||||
key_plugin = "r",
|
||||
plugins = true,
|
||||
},
|
||||
profile = {
|
||||
button = true,
|
||||
desc = "Show detailed profiling",
|
||||
id = 9,
|
||||
key = "P",
|
||||
toggle = true,
|
||||
},
|
||||
debug = {
|
||||
button = true,
|
||||
desc = "Show debug information",
|
||||
id = 10,
|
||||
key = "D",
|
||||
toggle = true,
|
||||
},
|
||||
help = {
|
||||
button = true,
|
||||
desc = "Toggle this help page",
|
||||
id = 11,
|
||||
key = "?",
|
||||
toggle = true,
|
||||
},
|
||||
clear = {
|
||||
desc = "Clear finished tasks",
|
||||
id = 12,
|
||||
},
|
||||
load = {
|
||||
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`",
|
||||
id = 13,
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue