Skip to content
FUJIWARA Takuya edited this page Dec 12, 2019 · 30 revisions

Installing server

Pick any one of the following servers.

go get -u golang.org/x/tools/cmd/gopls
go get -u github.com/sourcegraph/go-langserver

Registering in .vimrc

if executable('gopls')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'gopls',
        \ 'cmd': {server_info->['gopls', '-mode', 'stdio']},
        \ 'whitelist': ['go'],
        \ })
    autocmd BufWritePre *.go LspDocumentFormatSync
endif
if executable('go-langserver')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'go-langserver',
        \ 'cmd': {server_info->['go-langserver', '-gocodecompletion']},
        \ 'whitelist': ['go'],
        \ })
    autocmd BufWritePre *.go LspDocumentFormatSync
endif