Skip to content

Commit

Permalink
feat(ui): always load plugins in order of priority
Browse files Browse the repository at this point in the history
  • Loading branch information
hoofcushion committed Jul 22, 2024
1 parent a09c876 commit 609431a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,30 @@ function M.load(plugins, reason, opts)
---@diagnostic disable-next-line: cast-local-type
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|LazyPlugin)[]

local queue = {}
for _, plugin in pairs(plugins) do
if type(plugin) == "string" then
if Config.plugins[plugin] then
plugin = Config.plugins[plugin]
elseif Config.spec.disabled[plugin] then
plugin = nil
goto continue
else
Util.error("Plugin " .. plugin .. " not found")
plugin = nil
goto continue
end
end
if plugin and not plugin._.loaded then
M._load(plugin, reason, opts)
if not plugin._.loaded then
table.insert(queue, plugin)
end
::continue::
end

table.sort(queue,function (a,b)
return a.priority and b.priority and a.priority>b.priority
end)

for _,plugin in ipairs(queue) do
M._load(plugin, reason, opts)
end
end

Expand Down

0 comments on commit 609431a

Please sign in to comment.