Install gopls and configure Neovim to use it as the language server for Go.
- Install the Go language server by running
go install golang.org/x/tools/gopls@latest. - Add the following Lua configuration to your
init.luaor~/.config/nvim/lua/plugins.luato enable gopls with vulnerability scanning.
require('nvim-lspconfig').gopls.setup {
settings = {
gopls = {
staticcheck = true,
usePlaceholders = true,
hints = {
assignVariableTypes = true,
constantValues = true,
parameterNames = true,
},
},
},
init_options = {
vulncheck = "Imports",
},
}
- Restart Neovim to apply the changes.