diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-11 13:11:56 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-11 13:11:56 -0800 |
| commit | f6c804b6d6c58ca31c5ced64095c901e022f75f2 (patch) | |
| tree | f69afb4e9078421021a3e5e37ac47677a3364622 /lua | |
| parent | ci: fix close config changes workflow (#1408) (diff) | |
| download | nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar.gz nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar.bz2 nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar.lz nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar.xz nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.tar.zst nvim-lspconfig-f6c804b6d6c58ca31c5ced64095c901e022f75f2.zip | |
Revert "fix(gopls): resolve top-level go.mod as root_dir (#1399)" (#1410)
This reverts commit 86abe8db3ad48271d7295b08cdbb923aa705644b.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/gopls.lua | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/lua/lspconfig/gopls.lua b/lua/lspconfig/gopls.lua index 90c1fde0..0126b127 100644 --- a/lua/lspconfig/gopls.lua +++ b/lua/lspconfig/gopls.lua @@ -6,32 +6,7 @@ configs.gopls = { cmd = { 'gopls' }, filetypes = { 'go', 'gomod' }, root_dir = function(fname) - -- First, search for go.work - local primary_root = util.root_pattern 'go.work'(fname) - if primary_root then - return primary_root - end - - -- Then, search up the filesystem for go.mod - local go_mod_hierarchy = {} - if primary_root then - return primary_root - end - for path in util.path.iterate_parents(fname) do - for _, p in ipairs(vim.fn.glob(util.path.join(path, 'go.mod'), true, true)) do - if util.path.exists(p) then - table.insert(go_mod_hierarchy, p) - end - end - end - - -- Take the top level go.mod - if #go_mod_hierarchy > 0 then - return go_mod_hierarchy[#go_mod_hierarchy] - end - - -- Fallback to the git root - return util.find_git_ancestor(fname) + return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname) end, }, docs = { |
