feat(plugin): support running all init functions

This commit is contained in:
MeanderingProgrammer 2024-11-04 12:24:37 -08:00
parent b1134ab82e
commit 9f4b3546f6
2 changed files with 30 additions and 6 deletions

View file

@ -111,9 +111,7 @@ function M.startup()
for _, plugin in pairs(Config.plugins) do
if plugin.init then
Util.track({ plugin = plugin.name, init = "init" })
Util.try(function()
plugin.init(plugin)
end, "Failed to run `init` for **" .. plugin.name .. "**")
M.init(plugin)
Util.track()
end
end
@ -157,6 +155,16 @@ function M.startup()
Util.track()
end
---@param plugin LazyPlugin
function M.init(plugin)
Util.try(function()
local inits = Plugin.super_functions(plugin, "init")
for _, init in ipairs(inits) do
init(plugin)
end
end, "Failed to run `init` for **" .. plugin.name .. "**")
end
function M.get_start_plugins()
---@type LazyPlugin[]
local start = {}
@ -264,9 +272,7 @@ function M.reload(plugin)
-- run init
if plugin.init then
Util.try(function()
plugin.init(plugin)
end, "Failed to run `init` for **" .. plugin.name .. "**")
M.init(plugin)
end
-- if this is a start plugin, load it now