diff options
Diffstat (limited to 'lua/lspconfig/server_configurations/gopls.lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/gopls.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lua/lspconfig/server_configurations/gopls.lua b/lua/lspconfig/server_configurations/gopls.lua index fd470beb..139f63d8 100644 --- a/lua/lspconfig/server_configurations/gopls.lua +++ b/lua/lspconfig/server_configurations/gopls.lua @@ -1,6 +1,5 @@ local util = require 'lspconfig.util' - -local mod_cache = vim.trim(vim.fn.system 'go env GOMODCACHE') +local mod_cache = nil return { default_config = { @@ -8,6 +7,12 @@ return { filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, root_dir = function(fname) -- see: https://github.com/neovim/nvim-lspconfig/issues/804 + if not mod_cache then + local result = util.async_run_command 'go env GOMODCACHE' + if result and result[1] then + mod_cache = vim.trim(result[1]) + end + end if fname:sub(1, #mod_cache) == mod_cache then local clients = vim.lsp.get_active_clients { name = 'gopls' } if #clients > 0 then |
