mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
backport: feat(vim.fs): vim.fs.root() can control priority #34413
feat(vim.fs): vim.fs.root() can control priority
Adds the capability of controlling the priority of searched markers in
vim.fs.root() by nesting lists.
(cherry picked from commit 0f0b96dd0f
)
This commit is contained in:
@@ -357,6 +357,36 @@ describe('vim.fs', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('nested markers have equal priority', function()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
eq(
|
||||
vim.fs.joinpath(test_source_path, 'test/functional'),
|
||||
exec_lua(
|
||||
[[return vim.fs.root(..., { 'example_spec.lua', {'CMakeLists.txt', 'CMakePresets.json'}, '.luarc.json'})]],
|
||||
bufnr
|
||||
)
|
||||
)
|
||||
eq(
|
||||
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
|
||||
exec_lua(
|
||||
[[return vim.fs.root(..., { {'CMakeLists.txt', 'CMakePresets.json'}, 'example_spec.lua', '.luarc.json'})]],
|
||||
bufnr
|
||||
)
|
||||
)
|
||||
eq(
|
||||
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
|
||||
exec_lua(
|
||||
[[return vim.fs.root(..., {
|
||||
function(name, _)
|
||||
return name:match('%.txt$')
|
||||
end,
|
||||
'example_spec.lua',
|
||||
'.luarc.json' })]],
|
||||
bufnr
|
||||
)
|
||||
)
|
||||
end)
|
||||
|
||||
it('works with a function', function()
|
||||
---@type string
|
||||
local result = exec_lua(function()
|
||||
|
Reference in New Issue
Block a user