Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs.lua): pass path to vim.fs.find function predicate and lazy evaluate the predicate #22378

Merged
merged 7 commits into from
Mar 1, 2023
Prev Previous commit
Next Next commit
docs(fs.lua): update find description
Co-authored-by: Gregory Anders <[email protected]>
  • Loading branch information
mike325 and gpanders committed Feb 27, 2023
commit 2898ffaebce153eeacd869880d6243431eb59911
2 changes: 1 addition & 1 deletion runtime/lua/vim/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ end
---@param names (string|table|fun(name: string, path: string): boolean) Names of the files
justinmk marked this conversation as resolved.
Show resolved Hide resolved
--- and directories to find.
--- Must be base names, paths and globs are not supported when {names} is a string or a table.
--- If {names} is a function, it will be called for each file and directory
--- If {names} is a function, it will be called once for each file or directory
--- within the traversed directory with the base name of the
--- file and directory and the path of the directory being traversed.
--- The function should return `true` if the given file or directory is considered a match.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a blank line is needed here to work around the docs rendering issue (it joins this line).

Suggested change
--- The function should return `true` if the given file or directory is considered a match.
---
--- The function should return `true` if the given file or directory is considered a match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to work, gen_vimdoc.py sends everything after the new line to the general description, just below the code examples, it renders like

...
     -- get all files ending with .cpp or .hpp inside lib/
     local cpp_hpp = vim.fs.find(function(name, path)
       return name:match('.*%.[ch]pp$') and path:match('[/\\]lib$')
     end, {limit = math.huge, type = 'file'})
<

    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 when {names} is a string or
                 a table. If {names} is a function, it is called for each
                 traversed file and directory with args:
                 • name: base name of the current item
                 • path: full path of the current item
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll try to fix it later.

Don't want to block this PR meanwhile.

Expand Down