Skip to content

Commit

Permalink
feat: expose all commands on main lazy module
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 18, 2022
1 parent 0b4a04d commit f25f942
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lua/lazy/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type LazyCommands
local M = {}

---@param spec LazySpec Should be a module name to load, or a plugin spec
Expand Down Expand Up @@ -87,4 +88,10 @@ function M.plugins()
return vim.tbl_values(require("lazy.core.config").plugins)
end

setmetatable(M, {
__index = function(_, key)
return require("lazy.view.commands").commands[key]
end,
})

return M
8 changes: 6 additions & 2 deletions lua/lazy/view/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function M.cmd(cmd, plugins)
end
end

---@class LazyCommands
M.commands = {
clean = function(plugins)
Manage.clean({ clear = true, mode = "clean", plugins = plugins })
Expand All @@ -33,6 +34,9 @@ M.commands = {
home = function()
View.show("home")
end,
show = function()
View.show("home")
end,
help = function()
View.show("help")
end,
Expand All @@ -44,8 +48,8 @@ M.commands = {
end,
sync = function()
Manage.clean({ clear = true, wait = true, mode = "sync" })
Manage.update({ interactive = true })
Manage.install({ interactive = true })
Manage.update()
Manage.install()
end,
update = function(plugins)
Manage.update({ clear = true, mode = "update", plugins = plugins })
Expand Down

0 comments on commit f25f942

Please sign in to comment.