Compare commits

...

2 Commits

Author SHA1 Message Date
HC 26d05dde99
Merge 2dd4c46ecd into 7967abe557 2024-11-11 19:29:57 +02:00
abcdefg233 2dd4c46ecd feat(ui): always load plugins in order of priority 2024-07-23 16:19:09 +08:00
1 changed files with 14 additions and 5 deletions

View File

@ -181,23 +181,32 @@ function M.load(plugins, reason, opts)
---@diagnostic disable-next-line: cast-local-type ---@diagnostic disable-next-line: cast-local-type
plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins plugins = (type(plugins) == "string" or plugins.name) and { plugins } or plugins
---@cast plugins (string|LazyPlugin)[] ---@cast plugins (string|LazyPlugin)[]
local queue = {}
for _, plugin in pairs(plugins) do for _, plugin in pairs(plugins) do
if type(plugin) == "string" then if type(plugin) == "string" then
if Config.plugins[plugin] then if Config.plugins[plugin] then
plugin = Config.plugins[plugin] plugin = Config.plugins[plugin]
elseif Config.spec.disabled[plugin] then elseif Config.spec.disabled[plugin] then
plugin = nil goto continue
else else
Util.error("Plugin " .. plugin .. " not found") Util.error("Plugin " .. plugin .. " not found")
plugin = nil goto continue
end end
end end
if plugin and not plugin._.loaded then 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) M._load(plugin, reason, opts)
end end
end end
end
---@param plugin LazyPlugin ---@param plugin LazyPlugin
function M.deactivate(plugin) function M.deactivate(plugin)