golangci-lint-langserver is golangci-lint language server.
Install golangci-lint.
go install github.com/nametake/golangci-lint-langserver@latest
-debug
output debug log
-nolintername
don't show a linter name in message
You need to set golangci-lint command to initializationOptions with --out-format json
.
Configuration for coc.nvim
coc-settings.json
{
"languageserver": {
"golangci-lint-languageserver": {
"command": "golangci-lint-langserver",
"filetypes": ["go"],
"initializationOptions": {
"command": ["golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1"]
}
}
}
}
Configuration for vim-lsp
augroup vim_lsp_golangci_lint_langserver
au!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'golangci-lint-langserver',
\ 'cmd': {server_info->['golangci-lint-langserver']},
\ 'initialization_options': {'command': ['golangci-lint', 'run', '--out-format', 'json', '--issues-exit-code=1']},
\ 'whitelist': ['go'],
\ })
augroup END
vim-lsp-settings provide installer for golangci-lint-langserver.
Configuration for nvim-lspconfig
Requires Neovim v0.6.1 or nightly.
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig/configs'
if not configs.golangcilsp then
configs.golangcilsp = {
default_config = {
cmd = {'golangci-lint-langserver'},
root_dir = lspconfig.util.root_pattern('.git', 'go.mod'),
init_options = {
command = { "golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1" };
}
};
}
end
lspconfig.golangci_lint_ls.setup {
filetypes = {'go','gomod'}
}
Configuration for lsp-mode (Emacs)
Support for golangci-lint-langserver is
built-in
to lsp-mode since late 2023. When the golangci-lint-langserver
executable is
found, it is automatically started for Go buffers as an add-on server along with
the gopls
language server.
Configuration for helix
You can use .golangci.yaml
in the project root directory to enable other linters
[[language]]
name = "go"
auto-format = true
language-servers = [ "gopls", "golangci-lint-lsp" ]
[language-server.golangci-lint-lsp]
command = "golangci-lint-langserver"
[language-server.golangci-lint-lsp.config]
command = ["golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1"]