(updated ) by

Neovim 0.5 LSP with ElixirLS

Neovim 0.5 comes with a built in LSP client. This allows you to access LS Language Servers which services the LSP, Language Server Protocol.

Elixir has a Language Server that is built on the shoulders of other analytic services.

But you won’t be able to boot Neovim 0.5 and connect automatically to the LS. You need to configure Neovim to connect to your LS.

Install nvim-lspconfig

To connect to your LS, Neovim 0.5 has a plugin to configure the LSP client in Neovim.

nvim-lspconfig has a list of configuration scripts for setting up Neovim to talk to the language server you need.

nvim-lsp is a plugin. You need a plugin manager but most common systems work.

In your Neovim config.

~/.config/nvim/init.vim

Add the plugin (using Vim plug here).

Plug 'neovim/nvim-lspconfig'

Then setup the configuration for ElixirLS.

lua require'nvim_lsp'.elixirls.setup{}

Now save ~/.config/nvim/init.vim and restart your Neovim.

Install elixirls

You need to install the language server manually.

Usage

I would suggest looking through the Neovim LSP docs. The following is an example config.

nnoremap <silent> gd    <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K     <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gD    <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> 1gD   <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr    <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0    <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gW    <cmd>lua vim.lsp.buf.workspace_symbol()<CR>

Most usage so far is in hover(), definition().