aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorRudrajeet Pal <rudrajeetpal64@gmail.com>2026-06-04 16:33:03 +0530
committerJustin M. Keyes <justinkz@gmail.com>2026-07-01 12:05:41 +0200
commit4e04dff2287eed576cdb1063d5b7c00bf91b9fad (patch)
treec0f6733b71c81bbf34307abfbcb8288bab49c5f7 /runtime/doc
parent0d81f257afd24373144873e8f030bf929c1900e2 (diff)
downloadrneovim-4e04dff2287eed576cdb1063d5b7c00bf91b9fad.tar.gz
rneovim-4e04dff2287eed576cdb1063d5b7c00bf91b9fad.tar.bz2
rneovim-4e04dff2287eed576cdb1063d5b7c00bf91b9fad.zip
feat(vim.fs): dir(), find() error-reporting
Problem: vim.fs.dir() and vim.fs.find() drop errors returned by uv.fs_scandir(). Solution: - vim.fs.dir(): - Return root scan failures as a secondary return value. - Propagate recursive scan failures through the iterator. This allows callers to distinguish unreadable directories from empty ones. - vim.fs.find(): Collect errors during search, and return the list as a second retval.
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/lua.txt34
-rw-r--r--runtime/doc/news.txt3
2 files changed, 30 insertions, 7 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index aa9fb67ad6..130031ff4c 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -2596,6 +2596,20 @@ vim.fs.dir({path}, {opts}) *vim.fs.dir()*
Gets an iterator over items found in `path` (normalized via
|vim.fs.normalize()|).
+ Example: >lua
+ local it, err = vim.fs.dir(path)
+
+ if err then
+ -- Failed to scan the root directory
+ end
+
+ for name, type, err in it do
+ if err then
+ -- Failed to scan a child directory
+ end
+ end
+<
+
Attributes: ~
Since: 0.8.0
@@ -2611,11 +2625,14 @@ vim.fs.dir({path}, {opts}) *vim.fs.dir()*
current directory. Only useful when depth > 1 Return an
iterator over the items located in {path}
- Return: ~
+ Return (multiple): ~
(`Iterator`) over items in {path}. Each iteration yields two values:
- "name" and "type". "name" is the basename of the item relative to
- {path}. "type" is one of the following: "file", "directory", "link",
- "fifo", "socket", "char", "block", "unknown".
+ "name" and "type", along with an optional value "err" "name" is the
+ basename of the item relative to {path}. "type" is one of the
+ following: "file", "directory", "link", "fifo", "socket", "char",
+ "block", "unknown". "err" is a string with the format {errname}:
+ {message}
+ (`string?`) err Error encountered while scanning the base directory
vim.fs.dirname({file}) *vim.fs.dirname()*
Gets the parent directory of the given path (not expanded/resolved, the
@@ -2708,9 +2725,12 @@ vim.fs.find({names}, {opts}) *vim.fs.find()*
through parent directories. Otherwise, search child
directories (recursively).
- Return: ~
- (`string[]`) Normalized paths |vim.fs.normalize()| of all matching
- items
+ Return (multiple): ~
+ (`string[]`) matches Normalized paths |vim.fs.normalize()| of all
+ matching items
+ (`table[]`) errors list of errors encountered during the search
+ • {err} (`string`) Error message
+ • {path} (`string`) Path at which error was encountered
vim.fs.joinpath({...}) *vim.fs.joinpath()*
Concatenates partial paths (one absolute or relative path followed by zero
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 09580a6644..6c1b58737a 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -253,6 +253,9 @@ LUA
• |vim.net.request()| can now accept `method` param overload for multiple HTTP methods.
• |writefile()| treats Lua strings as "blob", so it can be used to write
binary data.
+• |vim.fs.dir()| and |vim.fs.find()| report errors encountered while
+ scanning directories that cannot be read (e.g. due to permissions),
+ instead of treating them as empty.
• |vim.filetype.inspect()| returns a copy of the internal tables used for
filetype detection.
• Added `__eq` metamethod to |vim.VersionRange|. 2 distinct but representing