Skip to content

Commit 2dd4c46

Browse files
committed
feat(ui): always load plugins in order of priority
1 parent 839f9e7 commit 2dd4c46

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lua/lazy/core/loader.lua

+14-5
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,30 @@ function M.load(plugins, reason, opts)
181181
---@diagnostic disable-next-line: cast-local-type
182182
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
183183
---@cast plugins (string|LazyPlugin)[]
184-
184+
local queue = {}
185185
for _, plugin in pairs(plugins) do
186186
if type(plugin) == "string" then
187187
if Config.plugins[plugin] then
188188
plugin = Config.plugins[plugin]
189189
elseif Config.spec.disabled[plugin] then
190-
plugin = nil
190+
goto continue
191191
else
192192
Util.error("Plugin " .. plugin .. " not found")
193-
plugin = nil
193+
goto continue
194194
end
195195
end
196-
if plugin and not plugin._.loaded then
197-
M._load(plugin, reason, opts)
196+
if not plugin._.loaded then
197+
table.insert(queue, plugin)
198198
end
199+
::continue::
200+
end
201+
202+
table.sort(queue,function (a,b)
203+
return a.priority and b.priority and a.priority>b.priority
204+
end)
205+
206+
for _,plugin in ipairs(queue) do
207+
M._load(plugin, reason, opts)
199208
end
200209
end
201210

0 commit comments

Comments
 (0)