From 2dd4c46ecdb53716013c42c0d3c2f8e4f37caeb5 Mon Sep 17 00:00:00 2001 From: abcdefg233 <32760059+abcdefg233@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:43:19 +0800 Subject: [PATCH] feat(ui): always load plugins in order of priority --- lua/lazy/core/loader.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index cfcc136..be89226 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -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