init.lua/lsp/gopls.lua(view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
---@return vim.lsp.Config
return {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_markers = {
"go.mod",
"go.work",
},
settings = {
gopls = {
linksInHover = false,
staticcheck = true,
gofumpt = true,
analyses = {
unusedparams = true,
unreachable = true,
unusedwrite = true,
shadow = true,
S1008 = true, -- simplify returning boolean expression
SA5000 = true, -- assignment to nil map
SA5007 = true, -- infinite recursion call
ST1019 = true, -- importing the same package multiple times
SA1000 = true, -- invalid regular expression
SA1020 = true, -- using an invalid host:port pair with a net.Listen-related function
SA1023 = true, -- modifying the buffer in an io.Writer implementation
SA9001 = true, -- defers in range loops may not run when you expect them to
ST1013 = true, -- should use constants for HTTP error codes, not magic numbers
},
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = false,
parameterNames = true,
rangeVariableTypes = true,
},
codelenses = {
generate = true,
gc_details = false,
test = false,
tidy = true,
run_govulncheck = true,
upgrade_dependency = true,
},
},
},
}
|