mirror of
https://github.com/neovim/neovim.git
synced 2026-04-22 23:35:32 +00:00
refactor(loader): use vim.fs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -450,12 +450,7 @@ function Loader.lsmod(path)
|
||||
if not Loader._indexed[path] then
|
||||
local start = uv.hrtime()
|
||||
Loader._indexed[path] = {}
|
||||
local handle = vim.loop.fs_scandir(path .. '/lua')
|
||||
while handle do
|
||||
local name, t = vim.loop.fs_scandir_next(handle)
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
for name, t in vim.fs.dir(path .. '/lua') do
|
||||
local modpath = path .. '/lua/' .. name
|
||||
-- HACK: type is not always returned due to a bug in luv
|
||||
t = t or uv.fs_stat(modpath).type
|
||||
|
||||
Reference in New Issue
Block a user