diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-03-26 12:46:24 +0100 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-03-26 12:46:24 +0100 |
commit | 3c82ce0d625184a90e6b2dda96e38fcb44f901d2 (patch) | |
tree | 75bea3e9d289675b555f5f06d549985f5f67f67e /runtime/lua/vim/fs.lua | |
parent | 2257ade3dc2daab5ee12d27807c0b3bcf103cd29 (diff) | |
download | rneovim-3c82ce0d625184a90e6b2dda96e38fcb44f901d2.tar.gz rneovim-3c82ce0d625184a90e6b2dda96e38fcb44f901d2.tar.bz2 rneovim-3c82ce0d625184a90e6b2dda96e38fcb44f901d2.zip |
refactor(loader): use vim.fs
Diffstat (limited to 'runtime/lua/vim/fs.lua')
-rw-r--r-- | runtime/lua/vim/fs.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index 2c3fc64d57..c6371e9163 100644 --- a/runtime/lua/vim/fs.lua +++ b/runtime/lua/vim/fs.lua @@ -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 |