*vim.fs.dirname()*
Gets the parent directory of the given path (not expanded/resolved, the
caller must do that).
Attributes: ~
Since: 0.8.0
Parameters: ~
• {file} (`string?`) Path
Return: ~
(`string?`) Parent directory of {file}
vim.fs.find({names}, {opts}) *vim.fs.find()*
Find files or directories (or other items as specified by `opts.type`) in
the given path.
Finds items given in {names} starting from {path}. If {upward} is "true"
then the search traverses upward through parent directories; otherwise,
the search traverses downward. Note that downward searches are recursive
and may search through many directories! If {stop} is non-nil, then the
search stops when the directory given in {stop} is reached. The search
terminates when {limit} (default 1) matches are found. You can set {type}
to "file", "directory", "link", "socket", "char", "block", or "fifo" to
narrow the search to find only that type.
Examples: >lua
-- List all test directories under the runtime directory.
local dirs = vim.fs.find(
{ 'test', 'tst', 'testdir' },
{ limit = math.huge, type = 'directory', path = './runtime/' }
)
-- Get all "lib/*.cpp" and "lib/*.hpp" files, using Lua patterns.
-- Or use `vim.glob.to_lpeg(…):match(…)` for glob/wildcard matching.
local files = vim.fs.find(function(name, path)
return name:match('.*%.[ch]pp$') and path:match('[/\\]lib$')
end, { limit = math.huge, type = 'file' })
<
Attributes: ~
Since: 0.8.0
Parameters: ~
• {names} (`string|string[]|fun(name: string, path: string): boolean`)
Names of the items 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
item with args:
• name: base name of the current item
• path: full path of the current item
The function should return `true` if the given item is
considered a match.
• {opts} (`table`) Optional keyword arguments:
• {path}? (`string`) Path to begin searching from. If
omitted, the |current-directory| is used.
• {upward}? (`boolean`, default: `false`) 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 items of the given type. If
omitted, all items 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.
• {follow}? (`boolean`, default: `false`) Follow symbolic
links.
Return: ~
(`string[]`) Normalized paths |vim.fs.normalize()| of all matching
items
vim.fs.joinpath({...}) *vim.fs.joinpath()*
Concatenates partial paths (one absolute or relative path followed by zero
or more relative paths). Slashes are normalized: redundant slashes are
removed, and (on Windows) backslashes are replaced with forward-slashes.
Examples:
• "foo/", "/bar" => "foo/bar"
• Windows: "a\foo\", "\bar" => "a/foo/bar"
Attributes: ~
Since: 0.10.0
Parameters: ~
• {...} (`string`)
Return: ~
(`string`)
vim.fs.normalize({path}, {opts}) *vim.fs.normalize()*
Normalize a path to a standard format. A tilde (~)