diff options
| author | Mohammed Elwardi Fadeli <34474472+FoamScience@users.noreply.github.com> | 2025-09-21 23:04:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-21 14:04:03 -0700 |
| commit | a13a12861d29fe07b3e5660136baa5cd40751612 (patch) | |
| tree | 87578f1fd66c5913edf8675e0f702504977972bd /lsp | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar.gz nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar.bz2 nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar.lz nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar.xz nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.tar.zst nvim-lspconfig-a13a12861d29fe07b3e5660136baa5cd40751612.zip | |
feat(foam_ls): fallback root directories #4085
Although not common, the associated LSP (foam_ls) can handle single files just fine.
Fallback to git root, or the file's folder.
Diffstat (limited to 'lsp')
| -rw-r--r-- | lsp/foam_ls.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lsp/foam_ls.lua b/lsp/foam_ls.lua index cff7c03e..636b0660 100644 --- a/lsp/foam_ls.lua +++ b/lsp/foam_ls.lua @@ -13,10 +13,17 @@ return { filetypes = { 'foam', 'OpenFOAM' }, root_dir = function(bufnr, on_dir) local fname = vim.api.nvim_buf_get_name(bufnr) - on_dir(vim.iter(vim.fs.parents(fname)):find(function(path) + for path in vim.fs.parents(fname) do if vim.uv.fs_stat(path .. '/system/controlDict') then - return path + on_dir(path) + return end - end)) + end + local git_root = vim.fs.root(bufnr, { '.git' }) + if git_root then + on_dir(git_root) + return + end + on_dir(vim.fs.dirname(fname)) end, } |
