mirror of https://github.com/folke/lazy.nvim.git
fix(loader): don't load handlers before installing plugins
This commit is contained in:
parent
ed6c9ffe21
commit
1cfd6d1f36
|
@ -64,10 +64,11 @@ end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M:values(plugin)
|
function M:values(plugin)
|
||||||
|
local Plugin = require("lazy.core.plugin")
|
||||||
---@type table<string,any>
|
---@type table<string,any>
|
||||||
local values = {}
|
local values = {}
|
||||||
---@diagnostic disable-next-line: no-unknown
|
---@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)
|
local event = self:parse(value)
|
||||||
values[event.id] = event
|
values[event.id] = event
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,6 +39,10 @@ end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M.disable(plugin)
|
function M.disable(plugin)
|
||||||
|
if not plugin._.handlers_enabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
plugin._.handlers_enabled = false
|
||||||
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:del(plugin)
|
handler:del(plugin)
|
||||||
|
@ -49,11 +53,15 @@ end
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M.enable(plugin)
|
function M.enable(plugin)
|
||||||
if not plugin._.loaded then
|
if not plugin._.loaded then
|
||||||
|
if plugin._.handlers_enabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
plugin._.handlers_enabled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,10 +88,11 @@ function M:_del(_value) end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M:values(plugin)
|
function M:values(plugin)
|
||||||
|
local Plugin = require("lazy.core.plugin")
|
||||||
---@type table<string,any>
|
---@type table<string,any>
|
||||||
local values = {}
|
local values = {}
|
||||||
---@diagnostic disable-next-line: no-unknown
|
---@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
|
values[value] = value
|
||||||
end
|
end
|
||||||
return values
|
return values
|
||||||
|
|
|
@ -52,7 +52,8 @@ end
|
||||||
|
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
function M:values(plugin)
|
function M:values(plugin)
|
||||||
return M.resolve(plugin.keys)
|
local Plugin = require("lazy.core.plugin")
|
||||||
|
return M.resolve(Plugin.values(plugin, "keys", true))
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param spec? (string|LazyKeysSpec)[]
|
---@param spec? (string|LazyKeysSpec)[]
|
||||||
|
|
|
@ -42,15 +42,6 @@ end
|
||||||
function Spec:parse(spec)
|
function Spec:parse(spec)
|
||||||
self:normalize(spec)
|
self:normalize(spec)
|
||||||
self:fix_disabled()
|
self:fix_disabled()
|
||||||
|
|
||||||
-- calculate handlers
|
|
||||||
for _, plugin in pairs(self.plugins) do
|
|
||||||
for _, handler in pairs(Handler.types) do
|
|
||||||
if plugin[handler] then
|
|
||||||
plugin[handler] = M.values(plugin, handler, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- PERF: optimized code to get package name without using lua patterns
|
-- PERF: optimized code to get package name without using lua patterns
|
||||||
|
@ -609,8 +600,26 @@ end
|
||||||
---@param prop string
|
---@param prop string
|
||||||
---@param is_list? boolean
|
---@param is_list? boolean
|
||||||
function M.values(plugin, prop, is_list)
|
function M.values(plugin, prop, is_list)
|
||||||
|
if not plugin[prop] then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
plugin._.values = plugin._.values or {}
|
||||||
|
local key = prop .. (is_list and "_list" or "")
|
||||||
|
if plugin._.values[key] == nil then
|
||||||
|
plugin[prop] = M._values(plugin, prop, is_list)
|
||||||
|
plugin._.values[key] = true
|
||||||
|
end
|
||||||
|
return plugin[prop] or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Merges super values or runs the values function to override values or return new ones
|
||||||
|
-- Used for opts, cmd, event, ft and keys
|
||||||
|
---@param plugin LazyPlugin
|
||||||
|
---@param prop string
|
||||||
|
---@param is_list? boolean
|
||||||
|
function M._values(plugin, prop, is_list)
|
||||||
---@type table
|
---@type table
|
||||||
local ret = plugin._.super and M.values(plugin._.super, prop, is_list) or {}
|
local ret = plugin._.super and M._values(plugin._.super, prop, is_list) or {}
|
||||||
local values = rawget(plugin, prop)
|
local values = rawget(plugin, prop)
|
||||||
|
|
||||||
if not values then
|
if not values then
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
---@field module? string
|
---@field module? string
|
||||||
---@field dir? string Explicit dir or dev set for this plugin
|
---@field dir? string Explicit dir or dev set for this plugin
|
||||||
---@field rtp_loaded? boolean
|
---@field rtp_loaded? boolean
|
||||||
|
---@field values? table<string,boolean>
|
||||||
|
---@field handlers_enabled? boolean
|
||||||
|
|
||||||
---@alias PluginOpts table|fun(self:LazyPlugin, opts:table):table?
|
---@alias PluginOpts table|fun(self:LazyPlugin, opts:table):table?
|
||||||
|
|
||||||
|
|
|
@ -415,7 +415,7 @@ function M:plugin(plugin)
|
||||||
else
|
else
|
||||||
self:append(" ")
|
self:append(" ")
|
||||||
local reason = {}
|
local reason = {}
|
||||||
if plugin._.kind ~= "disabled" then
|
if plugin._.kind ~= "disabled" and plugin._.handlers_enabled then
|
||||||
for handler in pairs(Handler.types) do
|
for handler in pairs(Handler.types) do
|
||||||
if plugin[handler] then
|
if plugin[handler] then
|
||||||
local values = Handler.handlers[handler]:values(plugin)
|
local values = Handler.handlers[handler]:values(plugin)
|
||||||
|
@ -542,12 +542,13 @@ function M:details(plugin)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if plugin._.handlers_enabled then
|
||||||
for handler in pairs(Handler.types) do
|
for handler in pairs(Handler.types) do
|
||||||
if plugin[handler] then
|
if plugin[handler] then
|
||||||
table.insert(props, {
|
table.insert(props, {
|
||||||
handler,
|
handler,
|
||||||
function()
|
function()
|
||||||
for _, value in ipairs(plugin[handler]) do
|
for _, value in ipairs(Plugin.values(plugin, handler, true)) do
|
||||||
self:reason({ [handler] = value })
|
self:reason({ [handler] = value })
|
||||||
self:append(" ")
|
self:append(" ")
|
||||||
end
|
end
|
||||||
|
@ -555,6 +556,7 @@ function M:details(plugin)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
self:props(props, { indent = 6 })
|
self:props(props, { indent = 6 })
|
||||||
|
|
||||||
self:nl()
|
self:nl()
|
||||||
|
|
Loading…
Reference in New Issue