Skip to content

Commit dfeecf5

Browse files
committed
fix: fallback root_dirs for foam_ls
1 parent 602148c commit dfeecf5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lsp/foam_ls.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ return {
1313
filetypes = { 'foam', 'OpenFOAM' },
1414
root_dir = function(bufnr, on_dir)
1515
local fname = vim.api.nvim_buf_get_name(bufnr)
16-
on_dir(vim.iter(vim.fs.parents(fname)):find(function(path)
17-
if vim.uv.fs_stat(path .. '/system/controlDict') then
18-
return path
16+
for path in vim.fs.parents(fname) do
17+
if vim.uv.fs_stat(path .. "/system/controlDict") then
18+
on_dir(path)
19+
return
1920
end
20-
end))
21+
end
22+
local git_root = vim.fs.root(bufnr, { ".git" })
23+
if git_root then
24+
on_dir(git_root)
25+
return
26+
end
27+
on_dir(vim.fs.dirname(fname))
2128
end,
2229
}

0 commit comments

Comments
 (0)