golangci-server

golangci-server is a golangci-lint language server.

Installation

  1. Install golangci-lint

  2. Install golangci-server

     go install github.com/stephenafamo/[email protected]
    

Inspiration

Most of the inspiration for this was taken from golangci-lint-langserver.

I started out trying to modify it but found it easier to just rebuild based on the excellent glsp package

Configuration for coc.nvim

coc-settings.json

{
  "languageserver": {
    "golangci-server": {
      "command": "golangci-server",
      "filetypes": ["go"],
    }
  }
}

Configuration for vim-lsp

augroup vim_lsp_golangci_server
  au!
  autocmd User lsp_setup call lsp#register_server({
      \ 'name': 'golangci-server',
      \ 'cmd': {server_info->['golangci-server']},
      \ 'whitelist': ['go'],
      \ })
augroup END

Configuration for nvim-lspconfig

local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'

if not configs.golangcilsp then
 	configs.golangcilsp = {
		default_config = {
			cmd = {'golangci-server'},
			root_dir = lspconfig.util.root_pattern('.git', 'go.mod'),
		};
	}
end
lspconfig.golangcilsp.setup {
	filetypes = {'go'}
}

Configuration for lsp-mode (Emacs)

(with-eval-after-load 'lsp-mode
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection
                                     '("golangci-server"))
                    :major-modes '(go-mode)
                    :language-id "go"
                    :priority 0
                    :server-id 'golangci-lint
                    :add-on? t
                    :library-folders-fn #'lsp-go--library-default-directories

  (add-to-list 'lsp-language-id-configuration '(go-mode . "golangci-lint")))

GitHub

View Github