mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(plugin): added Plugin.priority
for start plugins
This commit is contained in:
parent
eec0485d45
commit
edf8310288
4 changed files with 50 additions and 7 deletions
|
@ -4,6 +4,8 @@ local Handler = require("lazy.core.handler")
|
|||
|
||||
local M = {}
|
||||
|
||||
local DEFAULT_PRIORITY = 50
|
||||
|
||||
---@type LazyPlugin[]
|
||||
M.loading = {}
|
||||
M.init_done = false
|
||||
|
@ -73,8 +75,9 @@ function M.startup()
|
|||
|
||||
-- 2. load start plugin
|
||||
Util.track({ start = "start" })
|
||||
for _, plugin in pairs(Config.plugins) do
|
||||
if plugin.lazy == false and not plugin._.loaded then
|
||||
for _, plugin in ipairs(M.get_start_plugins()) do
|
||||
-- plugin may be loaded by another plugin in the meantime
|
||||
if not plugin._.loaded then
|
||||
M.load(plugin, { start = "start" })
|
||||
end
|
||||
end
|
||||
|
@ -103,6 +106,22 @@ function M.startup()
|
|||
Util.track()
|
||||
end
|
||||
|
||||
function M.get_start_plugins()
|
||||
---@type LazyPlugin[]
|
||||
local start = {}
|
||||
for _, plugin in pairs(Config.plugins) do
|
||||
if plugin.lazy == false and not plugin._.loaded then
|
||||
start[#start + 1] = plugin
|
||||
end
|
||||
end
|
||||
table.sort(start, function(a, b)
|
||||
local ap = a.priority or DEFAULT_PRIORITY
|
||||
local bp = b.priority or DEFAULT_PRIORITY
|
||||
return ap > bp
|
||||
end)
|
||||
return start
|
||||
end
|
||||
|
||||
---@class Loader
|
||||
---@param plugins string|LazyPlugin|string[]|LazyPlugin[]
|
||||
---@param reason {[string]:string}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue