perf(extras): never load nested extras

This commit is contained in:
Folke Lemaitre 2026-03-20 19:56:46 +01:00
parent 76cb567e5c
commit 8764dfbc8f
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -111,15 +111,40 @@ function M.fix_imports()
) )
spec.import = rename spec.import = rename
end end
local dep = M.deprecated_extras[spec and spec.import] local dep = M.deprecated_extras[spec.import]
if dep then if dep then
dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning." dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning."
LazyVim.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 }) LazyVim.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 })
return false return false
end end
local modname = spec.import
if type(modname) == "string" and vim.startswith(modname, "lazyvim.plugins.extras.") then
M.single_import(spec)
end
end) end)
end end
---@param spec LazySpecImport
function M.single_import(spec)
local modname = spec.import
if type(modname) ~= "string" then
return
end
spec.name = modname
spec.import = function()
package.loaded[modname] = nil
local ok, mod, foo = pcall(require, modname) ---@type boolean, table?, unknown
if ok and type(mod) == "table" then
if foo then
return nil, "Spec module returned more than one value. Expected a single value."
end
return mod
end
return nil, mod
end
end
function M.fix_renames() function M.fix_renames()
---@param plugin LazyPluginSpec ---@param plugin LazyPluginSpec
Meta.add = LazyVim.inject.args(Meta.add, function(self, plugin) Meta.add = LazyVim.inject.args(Meta.add, function(self, plugin)