mirror of
https://github.com/neovim/neovim.git
synced 2026-07-09 10:59:38 +00:00
refactor(dir): use vim.fs.dir()
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
local api = vim.api
|
||||
local fs = vim.fs
|
||||
local uv = vim.uv
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -50,17 +49,13 @@ end
|
||||
---@param dir string
|
||||
---@return boolean
|
||||
local function render(buf, dir)
|
||||
-- TODO(#39878): drop this scandir probe once vim.fs.dir() can report
|
||||
-- traversal errors.
|
||||
local handle, err = uv.fs_scandir(dir)
|
||||
if not handle then
|
||||
vim.notify('dir: ' .. (err or ('cannot read directory: ' .. dir)), vim.log.levels.ERROR)
|
||||
return false
|
||||
end
|
||||
|
||||
---@type { name: string, dir: boolean }[]
|
||||
local items = {}
|
||||
for name, type in fs.dir(dir) do
|
||||
for name, type, err in fs.dir(dir, { err = true }) do
|
||||
if err then
|
||||
vim.notify('dir: ' .. err, vim.log.levels.ERROR)
|
||||
return false
|
||||
end
|
||||
if type == 'link' and vim.fn.isdirectory(fs.joinpath(dir, name)) == 1 then
|
||||
type = 'directory'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user