From 52a4bc45488cb1f626b02be5512cd0301cd48cb8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 27 Apr 2025 13:40:46 -0700 Subject: docs: lsp, emoji, startup #33446 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maria José Solano --- runtime/lua/vim/fs.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'runtime/lua/vim/fs.lua') 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 -- cgit