Vim for elixir

During my two month sabbatical from work I am starting a small toy project using elixir. I finally have the time to play around with this great language. But no language is fun to write code in when your tooling is not configured correctly. In this blog post I will go through my current vim configuration for elixir.

vim-polyglot

Plug 'sheerun/vim-polyglot'

Vim-polyglot makes it really easy to have support for tons of programming languages inside of vim. You won’t need to find out the package for a certain language, this plugin has them all. And the best part of it is that it loads the language support on demand.

vim-gutentags

Plug 'ludovicchabant/vim-gutentags'
let g:gutentags_cache_dir = '~/.tags_cache'

I am a heavy user of the tag system within vim. With it you can jump to the definition of a method, class or module using Ctrl-]. More details in the vim wikia. To always have an up to date tags definition file, I am using gutentags. It refreshes the tags file on save in the background.

To make ctags elixir aware I am using this config within my .ctags file.

Neomake

Plug 'neomake/neomake'
autocmd! BufWritePost * Neomake

If you are using vim and haven’t tried Neomake yet, you are definitely doing it wrongTM. Neomake will execute code checks to find mistakes in the currently edited file. If you use neovim or vim > 8 it will use the background job system to prevent any blocking of your editor.

And to make it even better: if you look into the config for elixir you will see that it also uses credo to mark code consistency problems right in your editor.

phoenix.vim

Plug 'c-brenn/phoenix.vim'
Plug 'tpope/vim-projectionist'

I really love working with vim-rails, and this is the same thing for phoenix. It gives you methods to navigate to controllers, models, channels and other files with commands like :Emodel {name}.

Alchemist.vim

Plug 'slashmili/alchemist.vim'
let g:alchemist_tag_disable = 1

Together with deoplete this opens up a new world of tab completions. It exposes module and method definitions to your fingertips. This is one of the things that are really hard to do for languages like ruby.

My complete neovim config can be found in my dotfiles repo.

Portrait photo of Bodo Tasche
Bodo Tasche
Polyglot Developer

I am a freelance polyglot developer and love HTML5, testing, TypeScript, Ruby and Elixir. In the last 20 years I have been in lots of different roles, from Java to Elixir, from backend developer at a 3 people team in an early phase startup to the CTO of a web agency. Some of my work can be seen on my projects page.

Need help developing your MVP or to add new features into your current app? Need a CTO or a front/backend developer for hire? Send me an email.