diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2025-04-27 13:40:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-27 13:40:46 -0700 |
| commit | 52a4bc45488cb1f626b02be5512cd0301cd48cb8 (patch) | |
| tree | b24c8c1936fd6d77ace98938ef17deee54f50160 /runtime/lua/vim/fs.lua | |
| parent | 82b844fefef5f0024d9ae02ebff1153ca3e9127a (diff) | |
| download | rneovim-52a4bc45488cb1f626b02be5512cd0301cd48cb8.tar.gz rneovim-52a4bc45488cb1f626b02be5512cd0301cd48cb8.tar.bz2 rneovim-52a4bc45488cb1f626b02be5512cd0301cd48cb8.zip | |
docs: lsp, emoji, startup #33446
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Diffstat (limited to 'runtime/lua/vim/fs.lua')
| -rw-r--r-- | runtime/lua/vim/fs.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index 8862afc760..1a99627347 100644 --- a/runtime/lua/vim/fs.lua +++ b/runtime/lua/vim/fs.lua @@ -6,7 +6,7 @@ --- --- >lua --- if vim.uv.fs_stat(file) then ---- vim.print("file exists") +--- vim.print('file exists') --- end --- < @@ -19,21 +19,21 @@ local sysname = uv.os_uname().sysname:lower() local iswin = not not (sysname:find('windows') or sysname:find('mingw')) local os_sep = iswin and '\\' or '/' ---- Iterate over all the parents of the given path. +--- Iterate over all the parents of the given path (not expanded/resolved, the caller must do that). --- --- Example: --- --- ```lua --- local root_dir --- for dir in vim.fs.parents(vim.api.nvim_buf_get_name(0)) do ---- if vim.fn.isdirectory(dir .. "/.git") == 1 then +--- if vim.fn.isdirectory(dir .. '/.git') == 1 then --- root_dir = dir --- break --- end --- end --- --- if root_dir then ---- print("Found git repository at", root_dir) +--- print('Found git repository at', root_dir) --- end --- ``` --- @@ -55,7 +55,7 @@ function M.parents(start) start end ---- Return the parent directory of the given path +--- Gets the parent directory of the given path (not expanded/resolved, the caller must do that). --- ---@since 10 ---@generic T : string|nil @@ -234,16 +234,17 @@ end --- Examples: --- --- ```lua ---- -- list all test directories under the runtime directory ---- local test_dirs = vim.fs.find( ---- {'test', 'tst', 'testdir'}, ---- {limit = math.huge, type = 'directory', path = './runtime/'} +--- -- 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 files ending with .cpp or .hpp inside lib/ ---- local cpp_hpp = vim.fs.find(function(name, path) +--- -- 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'}) +--- end, { limit = math.huge, type = 'file' }) --- ``` --- ---@since 10 |