Skip to content

Commit

Permalink
docs(fs.lua): update help docs and add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mike325 committed Feb 28, 2023
1 parent 91a98a2 commit b366d56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/doc/lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ find({names}, {opts}) *vim.fs.find()*
{limit = math.huge, type = 'directory', path = './runtime/'}
)

-- get all the C++ source and header files inside lib/
-- 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'})
Expand Down
2 changes: 1 addition & 1 deletion runtime/lua/vim/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ end
--- {limit = math.huge, type = 'directory', path = './runtime/'}
--- )
---
--- -- get all the C++ source and header files inside lib/
--- -- 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'})
Expand Down
11 changes: 11 additions & 0 deletions test/functional/lua/fs_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local nvim_dir = helpers.nvim_dir
local test_build_dir = helpers.test_build_dir
local test_source_path = helpers.test_source_path
local nvim_prog = helpers.nvim_prog
local is_os = helpers.is_os

Expand Down Expand Up @@ -252,6 +253,16 @@ describe('vim.fs', function()
local opts = { path = dir, upward = true, type = 'directory' }
return vim.fs.find(function(x) return x == 'no-match' end, opts)
]], nvim_dir))
eq(
exec_lua([[
local dir = ...
return vim.tbl_map(vim.fs.basename, vim.fn.glob(dir..'/contrib/*', false, true))
]], test_source_path),
exec_lua([[
local dir = ...
local opts = { path = dir, limit = math.huge }
return vim.tbl_map(vim.fs.basename, vim.fs.find(function(_, d) return d:match('[\\/]contrib$') end, opts))
]], test_source_path))
end)
end)

Expand Down

0 comments on commit b366d56

Please sign in to comment.