Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (39 sloc) 2.19 KB

What is it

Vim and Neovim plugin that integrates elixir-ls with Vim through ALE. It will download and compile elixir-ls upon installation. I also provided 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:

if has('nvim')
  let s:user_dir = stdpath('config')
  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:

autocmd FileType elixir,eelixir nnoremap <C-]> :ALEGoToDefinition<CR>
autocmd FileType elixir,eelixir nnoremap <C-\> :ALEFindReferences<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' ]

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

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.