mirror of https://github.com/folke/lazy.nvim.git
feat(plugin)!: `cond` is now the same as `enabled`, but skips clean
This commit is contained in:
parent
f8611632d0
commit
fbb0bea2db
|
@ -297,16 +297,9 @@ function M._load(plugin, reason, opts)
|
|||
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
||||
end
|
||||
|
||||
local cond = plugin.cond
|
||||
if cond == nil then
|
||||
cond = Config.options.defaults.cond
|
||||
end
|
||||
if cond ~= nil and not (opts and opts.force) then
|
||||
if cond == false or (type(cond) == "function" and not cond(plugin)) then
|
||||
plugin._.cond = false
|
||||
if plugin._.cond == false and not (opts and opts.force) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
plugin._.loaded = {}
|
||||
|
|
|
@ -146,13 +146,20 @@ function Spec:warn(msg)
|
|||
self:log(msg, vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
function Spec:fix_disabled()
|
||||
function Spec:fix_cond()
|
||||
for _, plugin in pairs(self.plugins) do
|
||||
if not plugin.name or not plugin.dir then
|
||||
self:error("Plugin spec for **" .. plugin.name .. "** not found.\n```lua\n" .. vim.inspect(plugin) .. "\n```")
|
||||
self.plugins[plugin.name] = nil
|
||||
local cond = plugin.cond
|
||||
if cond == nil then
|
||||
cond = Config.options.defaults.cond
|
||||
end
|
||||
if cond == false or (type(cond) == "function" and not cond(plugin)) then
|
||||
plugin._.cond = false
|
||||
plugin.enabled = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Spec:fix_optional()
|
||||
if not self.optional then
|
||||
---@param plugin LazyPlugin
|
||||
local function all_optional(plugin)
|
||||
|
@ -166,6 +173,18 @@ function Spec:fix_disabled()
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Spec:fix_disabled()
|
||||
for _, plugin in pairs(self.plugins) do
|
||||
if not plugin.name or not plugin.dir then
|
||||
self:error("Plugin spec for **" .. plugin.name .. "** not found.\n```lua\n" .. vim.inspect(plugin) .. "\n```")
|
||||
self.plugins[plugin.name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
self:fix_optional()
|
||||
self:fix_cond()
|
||||
|
||||
---@type table<string,string[]> plugin to parent plugin
|
||||
local dep_of = {}
|
||||
|
@ -384,6 +403,12 @@ function M.update_state()
|
|||
end
|
||||
end
|
||||
|
||||
for _, plugin in pairs(Config.spec.disabled) do
|
||||
if plugin._.cond == false then
|
||||
installed[plugin.name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
Config.to_clean = {}
|
||||
for pack, dir_type in pairs(installed) do
|
||||
table.insert(Config.to_clean, {
|
||||
|
|
Loading…
Reference in New Issue