Installing Language server plugins in Neovim

In notebook:
Work Notes
Created at:
2018-10-30
Updated:
2018-10-30
Tags:

There are several packages available, here are my findings.

LanguageClient neovim

On GitHub LanguageClient-neovim

call plug#begin('~/config/.nvim/plugged')

  " A dependency of 'ncm2'.
  Plug 'roxma/nvim-yarp'

  " v2 of the nvim-completion-manager.
  Plug 'ncm2/ncm2'

  " LanguageServer client for NeoVim.
  Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }
call plug#end()

and then (for JavaScript)

set completeopt=noinsert,menuone,noselect
let g:LanguageClient_serverCommands = {
    \ 'rust': ['rustup', 'run', 'stable', 'rls'],
    \ 'javascript': ['typescript-language-server', '--stdio']
    \ }


nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>

You also need to install the language-server

The above config is for the typescript-language-server available on GitHub: theia-ide/typescript-language-server

there's also the sourcegraph javascript-typescript-langserver, but I had some troubles with it on larger repos where it couldn't parse the commonjs modules. Probably a config issue but didn't have the patience to dig deeper.

Vim-lsp

Another Language Server client prabirshrestha/vim-lsp

I managed to get it working, but then found it hard to customise (due to my limited Vim skills)

coc.nvim

neoclide/coc.nvim. It's a younger project but according to the author it has more completions than LanguageClient.

Make sure you have yarn installed globally to be able to add the plugin.

Add this to your plugins list:

  Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}

to istall the JavaScript language server just do:

 :CocInstall coc-tsserver

no need to install a separate language server

Then for example:

" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)

Veonim

Or, the simplest solution is just to use Veonim and it has everything you need!