mirror of https://github.com/folke/lazy.nvim.git
fix: properly setup handlers when loading a plugin before startup (build) etc
This commit is contained in:
parent
2a9354c7d2
commit
24f6b6f1c7
|
@ -19,13 +19,19 @@ M.types = {
|
||||||
---@type table<string,LazyHandler>
|
---@type table<string,LazyHandler>
|
||||||
M.handlers = {}
|
M.handlers = {}
|
||||||
|
|
||||||
function M.setup()
|
M.did_setup = false
|
||||||
|
|
||||||
|
function M.init()
|
||||||
for _, type in pairs(M.types) do
|
for _, type in pairs(M.types) do
|
||||||
M.handlers[type] = M.new(type)
|
M.handlers[type] = M.new(type)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
M.did_setup = true
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
Util.try(function()
|
Util.try(function()
|
||||||
M.enable(plugin, true)
|
M.enable(plugin)
|
||||||
end, "Failed to setup handlers for " .. plugin.name)
|
end, "Failed to setup handlers for " .. plugin.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,9 +46,8 @@ function M.disable(plugin)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
---@param force? boolean
|
function M.enable(plugin)
|
||||||
function M.enable(plugin, force)
|
if not plugin._.loaded then
|
||||||
if force or not plugin._.loaded then
|
|
||||||
for type, handler in pairs(M.handlers) do
|
for type, handler in pairs(M.handlers) do
|
||||||
if plugin[type] then
|
if plugin[type] then
|
||||||
handler:add(plugin)
|
handler:add(plugin)
|
||||||
|
|
|
@ -34,6 +34,7 @@ function M.setup()
|
||||||
|
|
||||||
-- load the plugins
|
-- load the plugins
|
||||||
Plugin.load()
|
Plugin.load()
|
||||||
|
Handler.init()
|
||||||
|
|
||||||
-- install missing plugins
|
-- install missing plugins
|
||||||
if Config.options.install.missing then
|
if Config.options.install.missing then
|
||||||
|
@ -301,6 +302,12 @@ function M._load(plugin, reason, opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not Handler.did_setup then
|
||||||
|
Util.try(function()
|
||||||
|
Handler.enable(plugin)
|
||||||
|
end, "Failed to setup handlers for " .. plugin.name)
|
||||||
|
end
|
||||||
|
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
---@diagnostic disable-next-line: assign-type-mismatch
|
||||||
plugin._.loaded = {}
|
plugin._.loaded = {}
|
||||||
for k, v in pairs(reason) do
|
for k, v in pairs(reason) do
|
||||||
|
|
Loading…
Reference in New Issue