refactor(dir): use vim.fs.dir()

This commit is contained in:
Justin M. Keyes
2026-07-01 12:32:15 +02:00
parent 971a0a0fe0
commit 1035a9fb5d

View File

@@ -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