Skip to content

Commit f81a3fb

Browse files
committedFeb 15, 2025··
fix(meta): disable top-level specs before the rest. Closes #1889
1 parent ac21a63 commit f81a3fb

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
 

‎lua/lazy/core/meta.lua

+19-7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ function M:_rebuild(name)
179179
local super = nil
180180
plugin.url = nil
181181
plugin._.dep = true
182+
plugin._.top = true
182183
plugin.optional = true
183184

184185
assert(#plugin._.frags > 0, "no fragments found for plugin " .. name)
@@ -195,6 +196,7 @@ function M:_rebuild(name)
195196
plugin._.dep = plugin._.dep and fragment.dep
196197
plugin.optional = plugin.optional and (rawget(fragment.spec, "optional") == true)
197198
plugin.url = fragment.url or plugin.url
199+
plugin._.top = plugin._.top and fragment.pid == nil
198200

199201
-- dependencies
200202
for _, dep in ipairs(fragment.deps or {}) do
@@ -302,16 +304,26 @@ end
302304
--- Removes plugins that are disabled.
303305
function M:fix_disabled()
304306
local changes = 0
305-
for _, plugin in pairs(self.plugins) do
306-
if plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()) then
307-
changes = changes + 1
308-
if plugin.optional then
309-
self:del(plugin.name)
310-
else
311-
self:disable(plugin)
307+
local function check(top)
308+
for _, plugin in pairs(self.plugins) do
309+
if plugin._.top == top then
310+
if plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled()) then
311+
changes = changes + 1
312+
if plugin.optional then
313+
self:del(plugin.name)
314+
else
315+
self:disable(plugin)
316+
end
317+
end
312318
end
313319
end
314320
end
321+
-- disable top-level plugins first, since they may have non-top-level frags
322+
-- that disable other plugins
323+
check(true)
324+
self:rebuild()
325+
-- then disable non-top-level plugins
326+
check(false)
315327
self:rebuild()
316328
return changes
317329
end

‎lua/lazy/types.lua

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
---@field dirty? boolean
1111
---@field build? boolean
1212
---@field frags? number[]
13+
---@field top? boolean
1314
---@field handlers? LazyPluginHandlers
1415
---@field installed? boolean
1516
---@field is_local? boolean

0 commit comments

Comments
 (0)
Please sign in to comment.