mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-11 09:52:31 +00:00
fix(meta): disable top-level specs before the rest. Closes #1889
This commit is contained in:
parent
ac21a639c7
commit
f81a3fb7fe
2 changed files with 20 additions and 7 deletions
|
@ -179,6 +179,7 @@ function M:_rebuild(name)
|
||||||
local super = nil
|
local super = nil
|
||||||
plugin.url = nil
|
plugin.url = nil
|
||||||
plugin._.dep = true
|
plugin._.dep = true
|
||||||
|
plugin._.top = true
|
||||||
plugin.optional = true
|
plugin.optional = true
|
||||||
|
|
||||||
assert(#plugin._.frags > 0, "no fragments found for plugin " .. name)
|
assert(#plugin._.frags > 0, "no fragments found for plugin " .. name)
|
||||||
|
@ -195,6 +196,7 @@ function M:_rebuild(name)
|
||||||
plugin._.dep = plugin._.dep and fragment.dep
|
plugin._.dep = plugin._.dep and fragment.dep
|
||||||
plugin.optional = plugin.optional and (rawget(fragment.spec, "optional") == true)
|
plugin.optional = plugin.optional and (rawget(fragment.spec, "optional") == true)
|
||||||
plugin.url = fragment.url or plugin.url
|
plugin.url = fragment.url or plugin.url
|
||||||
|
plugin._.top = plugin._.top and fragment.pid == nil
|
||||||
|
|
||||||
-- dependencies
|
-- dependencies
|
||||||
for _, dep in ipairs(fragment.deps or {}) do
|
for _, dep in ipairs(fragment.deps or {}) do
|
||||||
|
@ -302,16 +304,26 @@ end
|
||||||
--- Removes plugins that are disabled.
|
--- Removes plugins that are disabled.
|
||||||
function M:fix_disabled()
|
function M:fix_disabled()
|
||||||
local changes = 0
|
local changes = 0
|
||||||
for _, plugin in pairs(self.plugins) do
|
local function check(top)
|
||||||
if plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()) then
|
for _, plugin in pairs(self.plugins) do
|
||||||
changes = changes + 1
|
if plugin._.top == top then
|
||||||
if plugin.optional then
|
if plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()) then
|
||||||
self:del(plugin.name)
|
changes = changes + 1
|
||||||
else
|
if plugin.optional then
|
||||||
self:disable(plugin)
|
self:del(plugin.name)
|
||||||
|
else
|
||||||
|
self:disable(plugin)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- disable top-level plugins first, since they may have non-top-level frags
|
||||||
|
-- that disable other plugins
|
||||||
|
check(true)
|
||||||
|
self:rebuild()
|
||||||
|
-- then disable non-top-level plugins
|
||||||
|
check(false)
|
||||||
self:rebuild()
|
self:rebuild()
|
||||||
return changes
|
return changes
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
---@field dirty? boolean
|
---@field dirty? boolean
|
||||||
---@field build? boolean
|
---@field build? boolean
|
||||||
---@field frags? number[]
|
---@field frags? number[]
|
||||||
|
---@field top? boolean
|
||||||
---@field handlers? LazyPluginHandlers
|
---@field handlers? LazyPluginHandlers
|
||||||
---@field installed? boolean
|
---@field installed? boolean
|
||||||
---@field is_local? boolean
|
---@field is_local? boolean
|
||||||
|
|
Loading…
Add table
Reference in a new issue