From 2a62bec37ced51678ff914700d7165605d5a0d53 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sun, 15 May 2022 20:10:12 -0600 Subject: feat(fs): add vim.fs.dir() This function is modeled after the path.dir() function from Penlight and the luafilesystem module. --- test/functional/lua/fs_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional') diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 674a7f6957..6f1f1df012 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -52,4 +52,18 @@ describe('vim.fs', function() ]], nvim_prog)) end) end) + + describe('dir()', function() + it('works', function() + eq(true, exec_lua([[ + local dir, nvim = ... + for name, type in vim.fs.dir(dir) do + if name == nvim and type == 'file' then + return true + end + end + return false + ]], nvim_dir, nvim_prog_basename)) + end) + end) end) -- cgit