mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
api: enable nvim_get_runtime_file to find subdirectories
This commit is contained in:
@@ -1885,25 +1885,40 @@ describe('API', function()
|
||||
end)
|
||||
|
||||
describe('nvim_get_runtime_file', function()
|
||||
it('works', function()
|
||||
local p = helpers.alter_slashes
|
||||
it('can find files', function()
|
||||
eq({}, meths.get_runtime_file("bork.borkbork", false))
|
||||
eq({}, meths.get_runtime_file("bork.borkbork", true))
|
||||
eq(1, #meths.get_runtime_file("autoload/msgpack.vim", false))
|
||||
eq(1, #meths.get_runtime_file("autoload/msgpack.vim", true))
|
||||
local val = meths.get_runtime_file("autoload/remote/*.vim", true)
|
||||
eq(2, #val)
|
||||
local p = helpers.alter_slashes
|
||||
if endswith(val[1], "define.vim") then
|
||||
ok(endswith(val[1], p("autoload/remote/define.vim")))
|
||||
ok(endswith(val[2], p("autoload/remote/host.vim")))
|
||||
ok(endswith(val[1], p"autoload/remote/define.vim"))
|
||||
ok(endswith(val[2], p"autoload/remote/host.vim"))
|
||||
else
|
||||
ok(endswith(val[1], p("autoload/remote/host.vim")))
|
||||
ok(endswith(val[2], p("autoload/remote/define.vim")))
|
||||
ok(endswith(val[1], p"autoload/remote/host.vim"))
|
||||
ok(endswith(val[2], p"autoload/remote/define.vim"))
|
||||
end
|
||||
val = meths.get_runtime_file("autoload/remote/*.vim", false)
|
||||
eq(1, #val)
|
||||
ok(endswith(val[1], p("autoload/remote/define.vim"))
|
||||
or endswith(val[1], p("autoload/remote/host.vim")))
|
||||
ok(endswith(val[1], p"autoload/remote/define.vim")
|
||||
or endswith(val[1], p"autoload/remote/host.vim"))
|
||||
|
||||
eq({}, meths.get_runtime_file("lua", true))
|
||||
eq({}, meths.get_runtime_file("lua/vim", true))
|
||||
end)
|
||||
|
||||
it('can find directories', function()
|
||||
local val = meths.get_runtime_file("lua/", true)
|
||||
eq(1, #val)
|
||||
ok(endswith(val[1], p"lua/"))
|
||||
|
||||
val = meths.get_runtime_file("lua/vim/", true)
|
||||
eq(1, #val)
|
||||
ok(endswith(val[1], p"lua/vim/"))
|
||||
|
||||
eq({}, meths.get_runtime_file("foobarlang/", true))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user