mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-22 12:31:07 +00:00
fix(util.plugin): single imports for extras
This commit is contained in:
parent
8764dfbc8f
commit
1b4be534f1
1 changed files with 8 additions and 5 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue