diff options
| author | Connor <Connorc0627@gmail.com> | 2024-09-23 00:13:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-23 15:13:34 +0800 |
| commit | efbfce341c9f546ca2a155a9316886fc1b80eace (patch) | |
| tree | 2108c077b8e93d03cb63d7ee014e9f27265155c3 /lua | |
| parent | fix: root_dir support string value directly (#3313) (diff) | |
| download | nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar.gz nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar.bz2 nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar.lz nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar.xz nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.tar.zst nvim-lspconfig-efbfce341c9f546ca2a155a9316886fc1b80eace.zip | |
fix(gopls): fix nil error when go env GOMODCACHE returns nothing (#3316)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/gopls.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/lspconfig/server_configurations/gopls.lua b/lua/lspconfig/server_configurations/gopls.lua index aceb38da..00df6f02 100644 --- a/lua/lspconfig/server_configurations/gopls.lua +++ b/lua/lspconfig/server_configurations/gopls.lua @@ -12,9 +12,11 @@ return { local result = async.run_command { 'go', 'env', 'GOMODCACHE' } if result and result[1] then mod_cache = vim.trim(result[1]) + else + mod_cache = vim.fn.system 'go env GOMODCACHE' end end - if fname:sub(1, #mod_cache) == mod_cache then + if mod_cache and fname:sub(1, #mod_cache) == mod_cache then local clients = util.get_lsp_clients { name = 'gopls' } if #clients > 0 then return clients[#clients].config.root_dir |
