make finding modules synchronous to avoid some bugs when calling...

internal neovim api functions
This commit is contained in:
2025-07-02 20:34:42 -04:00
parent 5deffca36e
commit 1538046b6f

View File

@ -30,10 +30,7 @@ function modules:setup(speclist, overrides, config_path)
"lua", (speclist.modules.prefix:gsub("%.", "/"))
)
h.uv.fs_scandir(path, function(err, handle)
if err then
logger:log("error", "failed to load modules; reason: %s", err)
else
local handle = h.uv.fs_scandir(path)
while handle do
local name = h.uv.fs_scandir_next(handle)
if name then
@ -46,13 +43,9 @@ function modules:setup(speclist, overrides, config_path)
-- when attempting to load it
name = name:sub(0, #name - 4)
-- attempt to load the module
local mod = module.new(nil, name, speclist.modules.prefix, overrides)
if not mod then
goto continue
end
-- put the module into the list of modules
table.insert(speclist.modules, name)
table.insert(o.modules, mod)
::continue::
elseif name == nil then
-- no more entries
@ -60,12 +53,11 @@ function modules:setup(speclist, overrides, config_path)
else
-- if there's a single error bail out
logger:log("error", "failed to run clean uv.fs_scandir_next failed")
return
break
end
end
end
end)
else
-- loop through all modules and initialize them
for _, modpath in ipairs(speclist.modules) do
local mod = module.new(nil, modpath, speclist.modules.prefix, overrides)
@ -76,7 +68,6 @@ function modules:setup(speclist, overrides, config_path)
table.insert(o.modules, mod)
::continue::
end
end
return self
end