mirror of https://github.com/folke/lazy.nvim.git
feat(commands): added build command to force rebuild of a plugin
This commit is contained in:
parent
205ce42cdc
commit
23c0587791
|
@ -489,6 +489,7 @@ Any operation can be started from the UI, with a sub command or an API function:
|
|||
|
||||
| Command | Lua | Description |
|
||||
| ------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `:Lazy build {plugins}` | `require("lazy").build(opts)` | Rebuild a plugin |
|
||||
| `:Lazy check [plugins]` | `require("lazy").check(opts?)` | Check for updates and show the log (git fetch) |
|
||||
| `:Lazy clean [plugins]` | `require("lazy").clean(opts?)` | Clean plugins that are no longer needed |
|
||||
| `:Lazy clear` | `require("lazy").clear()` | Clear finished tasks |
|
||||
|
|
|
@ -144,6 +144,17 @@ function M.log(opts)
|
|||
}, opts)
|
||||
end
|
||||
|
||||
---@param opts? ManagerOpts
|
||||
function M.build(opts)
|
||||
opts = M.opts(opts, { mode = "build" })
|
||||
return M.run({
|
||||
pipeline = { { "plugin.build", force = true } },
|
||||
plugins = function()
|
||||
return false
|
||||
end,
|
||||
}, opts)
|
||||
end
|
||||
|
||||
---@param opts? ManagerOpts
|
||||
function M.sync(opts)
|
||||
opts = M.opts(opts)
|
||||
|
|
|
@ -5,7 +5,11 @@ local Loader = require("lazy.core.loader")
|
|||
local M = {}
|
||||
|
||||
M.build = {
|
||||
skip = function(plugin)
|
||||
---@param opts? {force:boolean}
|
||||
skip = function(plugin, opts)
|
||||
if opts and opts.force then
|
||||
return false
|
||||
end
|
||||
return not (plugin._.dirty and plugin.build)
|
||||
end,
|
||||
run = function(self)
|
||||
|
|
|
@ -13,6 +13,12 @@ function M.cmd(cmd, opts)
|
|||
local command = M.commands[cmd] --[[@as fun(opts)]]
|
||||
if command == nil then
|
||||
Util.error("Invalid lazy command '" .. cmd .. "'")
|
||||
elseif
|
||||
ViewConfig.commands[cmd]
|
||||
and ViewConfig.commands[cmd].plugins_required
|
||||
and not (opts and vim.tbl_count(opts.plugins or {}) > 0)
|
||||
then
|
||||
return Util.error("`Lazy " .. cmd .. "` requires at least one plugin")
|
||||
else
|
||||
command(opts)
|
||||
end
|
||||
|
@ -44,12 +50,10 @@ M.commands = {
|
|||
end,
|
||||
---@param opts ManagerOpts
|
||||
load = function(opts)
|
||||
if not (opts and opts.plugins and #opts.plugins > 0) then
|
||||
return Util.error("`Lazy load` requires at least one plugin name to load")
|
||||
end
|
||||
require("lazy.core.loader").load(opts.plugins, { cmd = "LazyLoad" })
|
||||
end,
|
||||
log = Manage.log,
|
||||
build = Manage.build,
|
||||
clean = Manage.clean,
|
||||
install = Manage.install,
|
||||
sync = Manage.sync,
|
||||
|
|
|
@ -139,6 +139,13 @@ M.commands = {
|
|||
desc = "Run `:checkhealth lazy`",
|
||||
id = 14,
|
||||
},
|
||||
build = {
|
||||
desc = "Rebuild a plugin",
|
||||
id = 13,
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
key_plugin = "b",
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in New Issue