Skip to content

Commit

Permalink
docs(fs.lua): add more info to vim.fs.find docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
mike325 committed Feb 23, 2023
1 parent 61e2cf9 commit dff8853
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
35 changes: 21 additions & 14 deletions runtime/doc/lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2359,26 +2359,33 @@ find({names}, {opts}) *vim.fs.find()*
The search can be narrowed to find only files or only directories by
specifying {type} to be "file" or "directory", respectively.

If {names} is a function, it is called for each file and directory within
the traversed directory and it would be passed the base name of each file
or directory and the path of the directory being traversed. The function
should return `true` if the given file or directory is considered a match.

Parameters: ~
{names} (string|table|fun(name: string, path: string): boolean) Names
of the files and directories to find. Must be base names,
paths and globs are not supported. The function is called per
file and directory within the traversed directories to test
if they match {names}.
{opts} (table) Optional keyword arguments:
• path (string): Path to begin searching from. If omitted,
the |current-directory| is used.
• upward (boolean, default false): If true, search upward
through parent directories. Otherwise, search through child
directories (recursively).
• stop (string): Stop searching when this directory is
reached. The directory itself is not searched.
• type (string): Find only files ("file") or directories
("directory"). If omitted, both files and directories that
match {names} are included.
• limit (number, default 1): Stop the search after finding
this many matches. Use `math.huge` to place no limit on the
number of matches.

Parameters: ~
{opts} (table) Optional keyword arguments:
• path (string): Path to begin searching from. If omitted, the
|current-directory| is used.
• upward (boolean, default false): If true, search upward
through parent directories. Otherwise, search through child
directories (recursively).
• stop (string): Stop searching when this directory is
reached. The directory itself is not searched.
• type (string): Find only files ("file") or directories
("directory"). If omitted, both files and directories that
match {names} are included.
• limit (number, default 1): Stop the search after finding
this many matches. Use `math.huge` to place no limit on the
number of matches.

Return: ~
(table) Normalized paths |vim.fs.normalize()| of all matching files or
Expand Down
5 changes: 5 additions & 0 deletions runtime/lua/vim/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ end
--- The function is called per file and directory within the
--- traversed directories to test if they match {names}.
---
--- If {names} is a function, it is called for each file and directory within the
--- traversed directory and it would be passed the base name of each file or directory and
--- the path of the directory being traversed.
--- The function should return `true` if the given file or directory is considered a match.
---
---@param opts (table) Optional keyword arguments:
--- - path (string): Path to begin searching from. If
--- omitted, the |current-directory| is used.
Expand Down

0 comments on commit dff8853

Please sign in to comment.