update gopls setting and update README

pull/429/merge
ray-x 2 months 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 [Nvim-tree](https://github.com/kyazdani42/nvim-tree.lua) and
[Bufferline](https://github.com/akinsho/nvim-bufferline.lua) also introduced lsp diagnostic hooks. [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> <details>
<summary>Gopls default settings in go.nvim</summary> <summary>Gopls default settings in go.nvim</summary>
@ -1101,6 +1106,9 @@ gopls = {
matcher = 'Fuzzy', matcher = 'Fuzzy',
diagnosticsDelay = '500ms', diagnosticsDelay = '500ms',
symbolMatcher = 'fuzzy', symbolMatcher = 'fuzzy',
semanticTokens = true,
noSemanticTokens = true, -- disable semantic string tokens so we can use treesitter highlight injection
['local'] = get_current_gomod(), ['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 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' }, buildFlags = { '-tags', 'integration' },
@ -1134,9 +1142,7 @@ gopls = {
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup() require("mason-lspconfig").setup()
require('lspconfig').gopls.setup({ require('lspconfig').gopls.setup({
gopls_cmd = {install_root_dir .. '/go/gopls'}, -- your gopls setup
dap_debug = true,
dap_debug_gui = true
}) })
``` ```

@ -106,7 +106,12 @@ for _, gopls_cmd in ipairs(gopls_cmds) do
local arguments = { { URI = uri } } local arguments = { { URI = uri } }
local ft = vim.bo.filetype 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].URIs = { uri }
arguments[1].URI = nil arguments[1].URI = nil
end end
@ -327,17 +332,22 @@ M.setups = function()
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md -- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
-- not supported -- not supported
analyses = { analyses = {
append = true,
asmdecl = true,
assign = true,
atomic = true,
unreachable = true, unreachable = true,
nilness = true, nilness = true,
unusedparams = true,
useany = true,
unusedwrite = true,
ST1003 = true, ST1003 = true,
undeclaredname = true, undeclaredname = true,
fillreturns = true, fillreturns = true,
nonewvars = true, nonewvars = true,
fieldalignment = false, fieldalignment = true,
shadow = true, shadow = true,
unusedvariable = true,
unusedparams = true,
useany = true,
unusedwrite = true,
}, },
codelenses = { codelenses = {
generate = true, -- show the `go generate` lens. generate = true, -- show the `go generate` lens.
@ -362,7 +372,11 @@ M.setups = function()
staticcheck = true, staticcheck = true,
matcher = 'Fuzzy', matcher = 'Fuzzy',
diagnosticsDelay = '500ms', 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(), ['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 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' }, buildFlags = { '-tags', 'integration' },
@ -386,7 +400,6 @@ M.setups = function()
end, end,
}, },
} }
setups.settings.gopls.semanticTokens = true
local v = M.version() local v = M.version()
if v == nil then if v == nil then
return return

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

Loading…
Cancel
Save