mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
docs: vim.fs.dir.Opts type #34546
Follow the pattern of vim.fs.find.Opts
This commit is contained in:
@@ -2995,11 +2995,13 @@ vim.fs.dir({path}, {opts}) *vim.fs.dir()*
|
|||||||
iterate over. The path is first normalized
|
iterate over. The path is first normalized
|
||||||
|vim.fs.normalize()|.
|
|vim.fs.normalize()|.
|
||||||
• {opts} (`table?`) Optional keyword arguments:
|
• {opts} (`table?`) Optional keyword arguments:
|
||||||
• depth: integer|nil How deep the traverse (default 1)
|
• {depth}? (`integer`, default: `1`) How deep the traverse.
|
||||||
• skip: (fun(dir_name: string): boolean)|nil Predicate to
|
• {skip}? (`fun(dir_name: string): boolean`) Predicate to
|
||||||
control traversal. Return false to stop searching the
|
control traversal. Return false to stop searching the
|
||||||
current directory. Only useful when depth > 1
|
current directory. Only useful when depth > 1 Return an
|
||||||
• follow: boolean|nil Follow symbolic links. (default: false)
|
iterator over the items located in {path}
|
||||||
|
• {follow}? (`boolean`, default: `false`) Follow symbolic
|
||||||
|
links.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`Iterator`) over items in {path}. Each iteration yields two values:
|
(`Iterator`) over items in {path}. Each iteration yields two values:
|
||||||
@@ -3061,7 +3063,7 @@ vim.fs.find({names}, {opts}) *vim.fs.find()*
|
|||||||
|
|
||||||
The function should return `true` if the given item is
|
The function should return `true` if the given item is
|
||||||
considered a match.
|
considered a match.
|
||||||
• {opts} (`table`) Optional keyword arguments:
|
• {opts} (`table?`) Optional keyword arguments:
|
||||||
• {path}? (`string`) Path to begin searching from. If
|
• {path}? (`string`) Path to begin searching from. If
|
||||||
omitted, the |current-directory| is used.
|
omitted, the |current-directory| is used.
|
||||||
• {upward}? (`boolean`, default: `false`) Search upward
|
• {upward}? (`boolean`, default: `false`) Search upward
|
||||||
|
@@ -124,6 +124,23 @@ function M.joinpath(...)
|
|||||||
return (path:gsub('//+', '/'))
|
return (path:gsub('//+', '/'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @class vim.fs.dir.Opts
|
||||||
|
--- @inlinedoc
|
||||||
|
---
|
||||||
|
--- How deep the traverse.
|
||||||
|
--- (default: `1`)
|
||||||
|
--- @field depth? integer
|
||||||
|
---
|
||||||
|
--- Predicate to control traversal.
|
||||||
|
--- Return false to stop searching the current directory.
|
||||||
|
--- Only useful when depth > 1
|
||||||
|
--- Return an iterator over the items located in {path}
|
||||||
|
--- @field skip? (fun(dir_name: string): boolean)
|
||||||
|
---
|
||||||
|
--- Follow symbolic links.
|
||||||
|
--- (default: `false`)
|
||||||
|
--- @field follow? boolean
|
||||||
|
|
||||||
---@alias Iterator fun(): string?, string?
|
---@alias Iterator fun(): string?, string?
|
||||||
|
|
||||||
--- Return an iterator over the items located in {path}
|
--- Return an iterator over the items located in {path}
|
||||||
@@ -131,13 +148,7 @@ end
|
|||||||
---@since 10
|
---@since 10
|
||||||
---@param path (string) An absolute or relative path to the directory to iterate
|
---@param path (string) An absolute or relative path to the directory to iterate
|
||||||
--- over. The path is first normalized |vim.fs.normalize()|.
|
--- over. The path is first normalized |vim.fs.normalize()|.
|
||||||
--- @param opts table|nil Optional keyword arguments:
|
---@param opts? vim.fs.dir.Opts Optional keyword arguments:
|
||||||
--- - depth: integer|nil How deep the traverse (default 1)
|
|
||||||
--- - skip: (fun(dir_name: string): boolean)|nil Predicate
|
|
||||||
--- to control traversal. Return false to stop searching the current directory.
|
|
||||||
--- Only useful when depth > 1
|
|
||||||
--- - follow: boolean|nil Follow symbolic links. (default: false)
|
|
||||||
---
|
|
||||||
---@return Iterator over items in {path}. Each iteration yields two values: "name" and "type".
|
---@return Iterator over items in {path}. Each iteration yields two values: "name" and "type".
|
||||||
--- "name" is the basename of the item relative to {path}.
|
--- "name" is the basename of the item relative to {path}.
|
||||||
--- "type" is one of the following:
|
--- "type" is one of the following:
|
||||||
@@ -256,7 +267,7 @@ end
|
|||||||
---
|
---
|
||||||
--- The function should return `true` if the given item is considered a match.
|
--- The function should return `true` if the given item is considered a match.
|
||||||
---
|
---
|
||||||
---@param opts vim.fs.find.Opts Optional keyword arguments:
|
---@param opts? vim.fs.find.Opts Optional keyword arguments:
|
||||||
---@return (string[]) # Normalized paths |vim.fs.normalize()| of all matching items
|
---@return (string[]) # Normalized paths |vim.fs.normalize()| of all matching items
|
||||||
function M.find(names, opts)
|
function M.find(names, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
Reference in New Issue
Block a user