fix(util.plugin): single imports for extras

This commit is contained in:
Folke Lemaitre 2026-03-20 20:42:57 +01:00
parent 8764dfbc8f
commit 1b4be534f1
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -133,15 +133,18 @@ function M.single_import(spec)
end end
spec.name = modname spec.name = modname
spec.import = function() spec.import = function()
package.loaded[modname] = nil local modinfo = vim.loader.find(modname)[1]
local ok, mod, foo = pcall(require, modname) ---@type boolean, table?, unknown local modpath = modinfo and modinfo.modpath
if ok and type(mod) == "table" then local mod, err = loadfile(modpath)
if mod then
local ret, foo = mod()
if foo then if foo then
return nil, "Spec module returned more than one value. Expected a single value." return nil, "Spec module returned more than one value. Expected a single value."
end end
return mod return ret
else
return nil, err
end end
return nil, mod
end end
end end