refactor(loader): use vim.fs

This commit is contained in:
Lewis Russell
2023-03-26 12:46:24 +01:00
parent 2257ade3dc
commit 3c82ce0d62
3 changed files with 11 additions and 9 deletions

View File

@@ -77,6 +77,8 @@ local function join_paths(...)
return (table.concat({ ... }, '/'):gsub('//+', '/'))
end
---@alias Iterator fun(): string?, string?
--- Return an iterator over the files and directories located in {path}
---
---@param path (string) An absolute or relative path to the directory to iterate
@@ -100,10 +102,13 @@ function M.dir(path, opts)
})
if not opts.depth or opts.depth == 1 then
return function(fs)
local fs = vim.loop.fs_scandir(M.normalize(path))
return function()
if not fs then
return
end
return vim.loop.fs_scandir_next(fs)
end,
vim.loop.fs_scandir(M.normalize(path))
end
end
--- @async