Installing MacVim with Lua enabled through Homebrew

January 11, 2016

If you’re like me, you like to have control over the plugins that you have installed in your editor setup. However, staying up to date with the different plugins can be a little bit of a hassle from time to time, so lately, I’ve been using YADR, a set of community maintained dotfiles.

A great autocompletion plugin that YADR comes with is neocomplete.vim, which “provides a keyword completion system by maintaining a cache of keywords in the current buffer”. Unfortunately, for it to work, it needs MacVim with Lua enabled.

Now, I already had MacVim installed through Caskroom:

which mvim
# /usr/local/bin/mvim
ls -l $(which mvim)
# /usr/local/bin/mvim -> /opt/homebrew-cask/Caskroom/macvim/7.4-84/mvim

But this version was installed without Lua enabled. If you find yourself in this situation, and you want to re-install MacVim with the correct setup, just follow these steps:

  1. Install MacVim with Lua through Homebrew (and not Caskroom):

    brew install macvim --with-cscope --with-lua --with-override-system-vim
    
  2. Remove the previous installations of the mvim and vim binaries (if there are any):

    rm /usr/local/bin/mvim
    brew unlink vim
    
  3. Link newly installed binaries:

    brew link macvim
    
  4. Finally, add the newly installed MacVim.app to /Applications:

    brew linkapps macvim
    

You should now see the correct version of MacVim linked:

which mvim
# /usr/local/bin/mvim
ls -l $(which mvim)
# /usr/local/bin/mvim -> ../Cellar/macvim/7.4-89/bin/mvim

Update (January 18, 2016):

If instead of Caskroom, you had an existing vim installation that was setup without Homebrew, you will have to restart your terminal for it to pick up the changes. You can verify which vim binary is being run with:

which vim
# vim: aliased to mvim -v (and not /usr/bin/vim)

Additionally, if you’d like to install vim with Lua support and not MacVim, you can achieve that with:

brew install vim --with-lua
brew link vim

Enjoy your brand new MacVim with Lua and neocompletion!