mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 04:46:45 +00:00
feat(commands): :Lazy! load
now skips cond
checks when loading plugins. Fixes #330
This commit is contained in:
parent
2ef44e2dee
commit
eed1ef3c2d
4 changed files with 23 additions and 20 deletions
|
@ -157,7 +157,8 @@ end
|
|||
---@class Loader
|
||||
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
|
||||
---@param reason {[string]:string}
|
||||
function M.load(plugins, reason)
|
||||
---@param opts? {force:boolean} when force is true, we skip the cond check
|
||||
function M.load(plugins, reason, opts)
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
|
||||
---@cast plugins (string|LazyPlugin)[]
|
||||
|
@ -174,19 +175,20 @@ function M.load(plugins, reason)
|
|||
end
|
||||
end
|
||||
if plugin and not plugin._.loaded then
|
||||
M._load(plugin, reason)
|
||||
M._load(plugin, reason, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
---@param reason {[string]:string}
|
||||
function M._load(plugin, reason)
|
||||
---@param opts? {force:boolean} when force is true, we skip the cond check
|
||||
function M._load(plugin, reason, opts)
|
||||
if not plugin._.installed then
|
||||
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
||||
end
|
||||
|
||||
if plugin.cond ~= nil then
|
||||
if plugin.cond ~= nil and not (opts and opts.force) then
|
||||
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
|
||||
plugin._.cond = false
|
||||
return
|
||||
|
|
|
@ -50,7 +50,8 @@ M.commands = {
|
|||
end,
|
||||
---@param opts ManagerOpts
|
||||
load = function(opts)
|
||||
require("lazy.core.loader").load(opts.plugins, { cmd = "LazyLoad" })
|
||||
-- when a command is executed with a bang, wait will be set
|
||||
require("lazy.core.loader").load(opts.plugins, { cmd = "Lazy load" }, { force = opts.wait })
|
||||
end,
|
||||
log = Manage.log,
|
||||
build = Manage.build,
|
||||
|
|
|
@ -130,7 +130,7 @@ M.commands = {
|
|||
id = 12,
|
||||
},
|
||||
load = {
|
||||
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`",
|
||||
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks.",
|
||||
id = 13,
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue