update gopls setting and update README

pull/429/merge
ray-x 1 month ago
parent dadedaeda2
commit 72932a7799

@ -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
<details>
<summary>Gopls default settings in go.nvim</summary>
@ -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
})
```

@ -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

@ -18,9 +18,8 @@ call plug#end()
" No need for rquire('lspconfig'), navigator will configure it for you
lua <<EOF
require('go').setup({
goimport='goimport', -- goimport command
goimports = 'goimports', -- goimports command
gofmt = 'gofumpt', --gofmt cmd,
max_line_len = 120, -- max line length in goline format
tag_transform = false, -- tag_transfer check gomodifytags for details
verbose = true, -- output loginf in messages
log_path = vim.fn.expand("$HOME") .. "/tmp/gonvim.log",

Loading…
Cancel
Save