From f271d706611049bc53a6a439b310fe60bf0fab13 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sun, 15 May 2022 20:37:35 -0600 Subject: feat(fs): add vim.fs.find() This is a pure Lua implementation of the Vim findfile() and finddir() functions without the special syntax. --- test/functional/lua/fs_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional') diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 6f1f1df012..204bdc1567 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -66,4 +66,17 @@ describe('vim.fs', function() ]], nvim_dir, nvim_prog_basename)) end) end) + + describe('find()', function() + it('works', function() + eq({test_build_dir}, exec_lua([[ + local dir = ... + return vim.fs.find('build', { path = dir, upward = true, type = 'directory' }) + ]], nvim_dir)) + eq({nvim_prog}, exec_lua([[ + local dir, nvim = ... + return vim.fs.find(nvim, { path = dir, type = 'file' }) + ]], test_build_dir, nvim_prog_basename)) + end) + end) end) -- cgit