Yesterday I installed LanguageClient-neovim for NeoVim.
This tool adds Language Server Protocol support for NeoVim (or Vim8).
It helps with autocompletion, code formatting, code definitions, and offers other features as well.
LanguageClient-neovim Installation
With minpac
:
call minpac#add('autozimu/LanguageClient-neovim',
{'rev': 'next',
'do': '!bash install.sh'})
In Neovim, run the following command afterwards:
:UpdateRemotePlugins
elixir-ls Installation
You have to install a language server for each language you want to support and then configure the plugin.
For Elixir, you can check my previous blog post on Developing with Elixir in Vim.
$ git clone git@github.com:elixir-lsp/elixir-ls.git
$ cd elixir-ls
$ mix deps.get
$ mix compile
$ MIX_ENV=prod mix elixir_ls.release
This creates a folder with an executable, i.e., release/language_server.sh
.
(For Windows, use .bat
.)
Configuration
This has to go into your .vimrc
:
set hidden
let g:LanguageClient_serverCommands = {
\ 'elixir': ['~/<path-to-your-language-server-executable.sh-or-bat>],
\ }
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" Or map each action separately
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
Top comments (3)
Did jump to definition and rename work for you out of the box with this config?
Hover worked for me and it looks great, but nothing else did, not even linting...
Yes, it does. I use the elixir-ls fork (github.com/elixir-lsp/elixir-ls).
I'm currently running Elixir 1.94, but it worked with earlier versions, too.
Did you check if you compieled the language server with the same version that you use for your app?
Perhaps you could try a different language plugin? LanguageClient Neovim was the one that offered best integration with the languages I use. But others might suit you better.
bluz71.github.io/2019/10/16/lsp-in...
Yeah, I've been using it with ALE and it works fine with it, somehow.
I wanted to give LCN a chance cause it seems to try to do a lot less than ALE (that can be a little sluggish at times). I also miss Deoplete so I thought I could have it back by having a language client that doesn't clash with it.
Thanks for your answer :)