diff --git a/README.md b/README.md index 1f1b580..32acb0e 100644 --- a/README.md +++ b/README.md @@ -1015,6 +1015,11 @@ issues, e.g. [navigator.lua](https://github.com/ray-x/navigator.lua), [Nvim-tree](https://github.com/kyazdani42/nvim-tree.lua) and [Bufferline](https://github.com/akinsho/nvim-bufferline.lua) also introduced lsp diagnostic hooks. +> [!IMPORTANT] +> I will integrate more gopls functions into go.nvim, please make sure you have the latest version installed +> Also, enable gopls experimental features if it is configure somewhere other than go.nvim +> Otherwise, set `lsp_cfg` to `true` in your go.nvim setup to enable gopls setup in go.nvim +
Gopls default settings in go.nvim @@ -1101,6 +1106,9 @@ gopls = { matcher = 'Fuzzy', diagnosticsDelay = '500ms', symbolMatcher = 'fuzzy', + semanticTokens = true, + noSemanticTokens = true, -- disable semantic string tokens so we can use treesitter highlight injection + ['local'] = get_current_gomod(), gofumpt = _GO_NVIM_CFG.lsp_gofumpt or false, -- true|false, -- turn on for new repos, gofmpt is good but also create code turmoils buildFlags = { '-tags', 'integration' }, @@ -1134,9 +1142,7 @@ gopls = { require("mason").setup() require("mason-lspconfig").setup() require('lspconfig').gopls.setup({ - gopls_cmd = {install_root_dir .. '/go/gopls'}, - dap_debug = true, - dap_debug_gui = true + -- your gopls setup }) ``` diff --git a/lua/go/gopls.lua b/lua/go/gopls.lua index 6a48cbe..7145f34 100644 --- a/lua/go/gopls.lua +++ b/lua/go/gopls.lua @@ -106,7 +106,12 @@ for _, gopls_cmd in ipairs(gopls_cmds) do local arguments = { { URI = uri } } local ft = vim.bo.filetype - if ft == 'gomod' or ft == 'gosum' or gopls_cmd_name == 'tidy' or gopls_cmd_name == 'update_go_sum' then + if + ft == 'gomod' + or ft == 'gosum' + or gopls_cmd_name == 'tidy' + or gopls_cmd_name == 'update_go_sum' + then arguments[1].URIs = { uri } arguments[1].URI = nil end @@ -327,17 +332,22 @@ M.setups = function() -- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md -- not supported analyses = { + append = true, + asmdecl = true, + assign = true, + atomic = true, unreachable = true, nilness = true, - unusedparams = true, - useany = true, - unusedwrite = true, ST1003 = true, undeclaredname = true, fillreturns = true, nonewvars = true, - fieldalignment = false, + fieldalignment = true, shadow = true, + unusedvariable = true, + unusedparams = true, + useany = true, + unusedwrite = true, }, codelenses = { generate = true, -- show the `go generate` lens. @@ -362,7 +372,11 @@ M.setups = function() staticcheck = true, matcher = 'Fuzzy', diagnosticsDelay = '500ms', - symbolMatcher = 'fuzzy', + diagnosticsTrigger = 'Save', + symbolMatcher = 'FastFuzzy', + semanticTokens = true, + noSemanticTokens = true, -- disable semantic string tokens so we can use treesitter highlight injection + vulncheck = true, ['local'] = get_current_gomod(), gofumpt = _GO_NVIM_CFG.lsp_gofumpt or false, -- true|false, -- turn on for new repos, gofmpt is good but also create code turmoils buildFlags = { '-tags', 'integration' }, @@ -386,7 +400,6 @@ M.setups = function() end, }, } - setups.settings.gopls.semanticTokens = true local v = M.version() if v == nil then return diff --git a/samplevimrc.vim b/samplevimrc.vim index 89c19fc..ac89f0d 100644 --- a/samplevimrc.vim +++ b/samplevimrc.vim @@ -18,9 +18,8 @@ call plug#end() " No need for rquire('lspconfig'), navigator will configure it for you lua <