DEV Community


Developing with Elixir in Vim

sophiabrandt profile image Sophia Brandt Originally published at on ・3 min read

Using (Neo)Vim is surprisingly enjoyable after the initial hurdle.

Language support for Elixir also works fine in Vim.


I use minpac as my package manager. VimCasts has a good introduction video on minpac if you're interested.

Add these plugins to your ~/.vimrc:


" in `.vimrc` or `~/.config/nvim/init.vim`
syntax on
filetype plugin indent on

set laststatus=2
set wildmenu
Enter fullscreen mode Exit fullscreen mode

Elixir Language Server

You need the Elixir Language Server as a backend/integration tool.

Either head over to the original elixir-ls (slow development at the moment) or the more current fork elixir-lsp elixir-ls fork.

You need to clone the repository.

$ git clone
$ cd elixir-ls
$ mix deps.get
$ mix compile
$ MIX_ENV=prod mix elixir_ls.release
Enter fullscreen mode Exit fullscreen mode

This creates a folder release which includes an executable, for example release/ (.bat for Windows).

You need the path to that file for ALE support.


ALE acts as the client for the Elixir Language Server. Setup for ALE also needs to go into your vim settings (~/.vimrc):

" in `.vimrc` or `~/.config/nvim/init.vim`

let g:ale_linters = {
\   'elixir': ['elixir-ls'],

let g:ale_fixers = {
\   'elixir': ['mix_format'],
Enter fullscreen mode Exit fullscreen mode

You also have to tell ALE where the language server is:

" in `.vimrc` or `~/.config/nvim/init.vim`

let g:ale_elixir_elixir_ls_release='~/<PATH-TO-YOUR-RELEASE>'
Enter fullscreen mode Exit fullscreen mode

Only specify the path, not the file itself ( or language_server.bat).

Now, you can use the command :ALEFix in Vim to fix your files.

I chose the following config options:

" in `.vimrc` or `~/.config/nvim/init.vim`

let g:ale_completion_enabled = 1
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
let g:ale_lint_on_enter = 0
let g:ale_lint_on_text_changed = 'never'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_linters_explicit = 1
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1

noremap <Leader>ad :ALEGoToDefinition<CR>
nnoremap <leader>af :ALEFix<cr>
noremap <Leader>ar :ALEFindReferences<CR>

"Move between linting errors
nnoremap ]r :ALENextWrap<CR>
nnoremap [r :ALEPreviousWrap<CR>
Enter fullscreen mode Exit fullscreen mode

Better Language Client Support

ALE is great for linting and fixing files, but it can make VIM slow.

Alternatively, you can use a dedicated language server plugin, for example LanguageClient-neovim (works for Vim8 and NeoVim).

You can find a guide here.

Further Reading


Editor guide