@@ -179,6 +179,7 @@ function M:_rebuild(name)
179
179
local super = nil
180
180
plugin .url = nil
181
181
plugin ._ .dep = true
182
+ plugin ._ .top = true
182
183
plugin .optional = true
183
184
184
185
assert (# plugin ._ .frags > 0 , " no fragments found for plugin " .. name )
@@ -195,6 +196,7 @@ function M:_rebuild(name)
195
196
plugin ._ .dep = plugin ._ .dep and fragment .dep
196
197
plugin .optional = plugin .optional and (rawget (fragment .spec , " optional" ) == true )
197
198
plugin .url = fragment .url or plugin .url
199
+ plugin ._ .top = plugin ._ .top and fragment .pid == nil
198
200
199
201
-- dependencies
200
202
for _ , dep in ipairs (fragment .deps or {}) do
@@ -302,16 +304,26 @@ end
302
304
--- Removes plugins that are disabled.
303
305
function M :fix_disabled ()
304
306
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
312
318
end
313
319
end
314
320
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 )
315
327
self :rebuild ()
316
328
return changes
317
329
end
0 commit comments