Awesome
golangci-lint-langserver
golangci-lint-langserver is golangci-lint language server.
Installation
Install golangci-lint.
go install github.com/nametake/golangci-lint-langserver@latest
Options
-debug
output debug log
-nolintername
don't show a linter name in message
Configuration
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", "--enable-all", "--disable", "lll", "--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', '--enable-all', '--disable', 'lll', '--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", "--enable-all", "--disable", "lll", "--out-format", "json", "--issues-exit-code=1" };
}
};
}
end
lspconfig.golangci_lint_ls.setup {
filetypes = {'go','gomod'}
}
Configuration for lsp-mode (Emacs)
(with-eval-after-load 'lsp-mode
(lsp-register-custom-settings
'(("golangci-lint.command"
["golangci-lint" "run" "--enable-all" "--disable" "lll" "--out-format" "json" "--issues-exit-code=1"])))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
'("golangci-lint-langserver"))
:activation-fn (lsp-activate-on "go")
:language-id "go"
:priority 0
:server-id 'golangci-lint
:add-on? t
:library-folders-fn #'lsp-go--library-default-directories
:initialization-options (lambda ()
(gethash "golangci-lint"
(lsp-configuration-section "golangci-lint")))))