Skip to content
Vim plugin that integrates elixir-ls with Vim through ALE
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
elixir-ls @ ca277c1 Introduce Vim wrapper for ElixirLS May 7, 2019
plugin Add synchronous version for vim-plug hook May 8, 2019
.gitmodules Introduce Vim wrapper for ElixirLS May 7, 2019 Add README May 8, 2019

What is it

Vim plugin that integrates elixir-ls with Vim through ALE. It will download and compile elixir-ls upon installation. I also provided Vim configuration instructions for integrating with ALE and a command for on-demand compilation.

How to install

Use your favorite plugin manager. I prefer vim-plug:

Plug 'GrzegorzKozub/vim-elixirls', { 'do': ':ElixirLsCompileSync' }

Note that we're using post-update hooks to automatically compile elixir-ls after this plugin has been installed or updated.

How to integrate with ALE

At the minimum, you will need to tell ALE where the compiled elixir-ls sits and enable it as linter:

let s:user_dir = has('win32') ? expand('~/vimfiles/') : expand('~/.vim/')
let g:ale_elixir_elixir_ls_release = s:user_dir . 'plugins/vim-elixirls/elixir-ls/release'

let g:ale_elixir_elixir_ls_config = { 'elixirLS': { 'dialyzerEnabled': v:false } }

let g:ale_linters = {}
let g:ale_linters.elixir = [ 'credo', 'elixir-ls' ]

I'm using the following Vim key mappings for quick code navigation:

nnoremap <C-]> :ALEGoToDefinition<CR>
nnoremap <C-\> :ALEFindReferences<CR>
nnoremap <Leader>d :ALEHover<CR>

I'm using mix format to format my elixir code with this config:

let g:ale_fixers = {}
let g:ale_fixers.elixir = [ 'mix_format' ]

augroup UseALEToFormatElixirFiles
  autocmd FileType elixir,eelixir nnoremap <Leader>f :ALEFix<CR>
augroup END

The :ALEInfo command is useful for figuring out why things are not working.

Compiling elixir-ls manually

For elixir-ls to work, it needs to be compiled with the same elixir version as your code. Here's a handy command:

You can’t perform that action at this time.