make finding modules synchronous to avoid some bugs when calling...
internal neovim api functions
This commit is contained in:
@ -30,10 +30,7 @@ function modules:setup(speclist, overrides, config_path)
|
|||||||
"lua", (speclist.modules.prefix:gsub("%.", "/"))
|
"lua", (speclist.modules.prefix:gsub("%.", "/"))
|
||||||
)
|
)
|
||||||
|
|
||||||
h.uv.fs_scandir(path, function(err, handle)
|
local handle = h.uv.fs_scandir(path)
|
||||||
if err then
|
|
||||||
logger:log("error", "failed to load modules; reason: %s", err)
|
|
||||||
else
|
|
||||||
while handle do
|
while handle do
|
||||||
local name = h.uv.fs_scandir_next(handle)
|
local name = h.uv.fs_scandir_next(handle)
|
||||||
if name then
|
if name then
|
||||||
@ -46,13 +43,9 @@ function modules:setup(speclist, overrides, config_path)
|
|||||||
-- when attempting to load it
|
-- when attempting to load it
|
||||||
name = name:sub(0, #name - 4)
|
name = name:sub(0, #name - 4)
|
||||||
|
|
||||||
-- attempt to load the module
|
-- put the module into the list of modules
|
||||||
local mod = module.new(nil, name, speclist.modules.prefix, overrides)
|
table.insert(speclist.modules, name)
|
||||||
if not mod then
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(o.modules, mod)
|
|
||||||
::continue::
|
::continue::
|
||||||
elseif name == nil then
|
elseif name == nil then
|
||||||
-- no more entries
|
-- no more entries
|
||||||
@ -60,12 +53,11 @@ function modules:setup(speclist, overrides, config_path)
|
|||||||
else
|
else
|
||||||
-- if there's a single error bail out
|
-- if there's a single error bail out
|
||||||
logger:log("error", "failed to run clean uv.fs_scandir_next failed")
|
logger:log("error", "failed to run clean uv.fs_scandir_next failed")
|
||||||
return
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
else
|
|
||||||
-- loop through all modules and initialize them
|
-- loop through all modules and initialize them
|
||||||
for _, modpath in ipairs(speclist.modules) do
|
for _, modpath in ipairs(speclist.modules) do
|
||||||
local mod = module.new(nil, modpath, speclist.modules.prefix, overrides)
|
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)
|
table.insert(o.modules, mod)
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user