diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-07-08 12:39:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-08 12:39:35 -0700 |
| commit | e32fae9986aee17fd38498002a423b0b217eb764 (patch) | |
| tree | f2e380885aceb7c61ee837eb30d12be12fd1fc27 /lua | |
| parent | [docgen] Update CONFIG.md (diff) | |
| parent | feat: try to resolve root for new files (diff) | |
| download | nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar.gz nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar.bz2 nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar.lz nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar.xz nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.tar.zst nvim-lspconfig-e32fae9986aee17fd38498002a423b0b217eb764.zip | |
Merge pull request #1041 from mjlbach/fix/try-resolve-new-filepath
feat: try to resolve root for new files
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/util.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 625d3170..542d13eb 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -161,15 +161,16 @@ M.path = (function() -- Iterate the path until we find the rootdir. local function iterate_parents(path) - path = uv.fs_realpath(path) local function it(s, v) - if not v then + if v and not is_fs_root(v) then + v = dirname(v) + else return end - if is_fs_root(v) then + if not uv.fs_realpath(v) then return end - return dirname(v), path + return v, path end return it, path, path end @@ -263,7 +264,14 @@ function M.search_ancestors(startpath, func) if func(startpath) then return startpath end + local guard = 100 for path in M.path.iterate_parents(startpath) do + -- Prevent infinite recursion if our algorithm breaks + guard = guard - 1 + if guard == 0 then + return + end + if func(path) then return path end |
