Mastodon hachyterm.io

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>

Further Reading