fix(loader): don't load handlers before installing plugins

This commit is contained in:
Folke Lemaitre 2023-10-16 15:05:16 +02:00
parent ed6c9ffe21
commit 1cfd6d1f36
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
6 changed files with 49 additions and 25 deletions

View file

@ -64,10 +64,11 @@ end
---@param plugin LazyPlugin
function M:values(plugin)
local Plugin = require("lazy.core.plugin")
---@type table<string,any>
local values = {}
---@diagnostic disable-next-line: no-unknown
for _, value in ipairs(plugin[self.type] or {}) do
for _, value in ipairs(Plugin.values(plugin, self.type, true)) do
local event = self:parse(value)
values[event.id] = event
end

View file

@ -39,6 +39,10 @@ end
---@param plugin LazyPlugin
function M.disable(plugin)
if not plugin._.handlers_enabled then
return
end
plugin._.handlers_enabled = false
for type, handler in pairs(M.handlers) do
if plugin[type] then
handler:del(plugin)
@ -49,11 +53,15 @@ end
---@param plugin LazyPlugin
function M.enable(plugin)
if not plugin._.loaded then
if plugin._.handlers_enabled then
return
end
for type, handler in pairs(M.handlers) do
if plugin[type] then
handler:add(plugin)
end
end
plugin._.handlers_enabled = true
end
end
@ -80,10 +88,11 @@ function M:_del(_value) end
---@param plugin LazyPlugin
function M:values(plugin)
local Plugin = require("lazy.core.plugin")
---@type table<string,any>
local values = {}
---@diagnostic disable-next-line: no-unknown
for _, value in ipairs(plugin[self.type] or {}) do
for _, value in ipairs(Plugin.values(plugin, self.type, true)) do
values[value] = value
end
return values

View file

@ -52,7 +52,8 @@ end
---@param plugin LazyPlugin
function M:values(plugin)
return M.resolve(plugin.keys)
local Plugin = require("lazy.core.plugin")
return M.resolve(Plugin.values(plugin, "keys", true))
end
---@param spec? (string|LazyKeysSpec)[]