Maintaining an updated version of vim

I use vim for development. More concretely, I use YADR, a fork of dotfiles for my zsh, git, vim, etc. setup. One of the vim plugins that I use the most is neocomplete, which provides simple but powerful autocompletion. One of the last commits in neocomplete introduces a problem that impedes correctly wrapping lines – normally set to 80 characters (issue here). It turns out that it was vim, not neocomplete that triggered this unwanted behaviour. This vim patch, fixes the issue, but the binary cannot be obtained for neither MacOS nor Ubuntu – which are my main OSs – via standard repositories. Thus, I decided to find a way to keep my vim updated so that I can easily patch future problems.

The idea is simple: clone the vim codebase and compile it with the minimal set of necessary options.

Vim codebase is currently hosted in google code (here). Since google code is closing down early next year, the project is likely to be moved to github. As for today these are the necessary steps:

Ubuntu

1. Install mercurial to have access to hg

$ sudo apt-get install mercurial meld

2. Clone the repository

$ hg clone https://vim.googlecode.com/hg/ vim

3. Install the necessary libraries. Many YADR packages require vim to be compiled with  if_lua, thus we need to install that package. Depending on the configuration you require for vim, other packages might be necessary (e.g., python, as shown in the example).

$ sudo apt-get install liblua5.1-dev
$ sudo apt-get install python-dev
$ sudo apt-get install libncurses5-dev

4. Allow vim to install help files (e.g., colors, language support) and manuals.


$ vi $VIM_DIR/src/Makefile
# Uncomment the next line to install Vim manuals in "/usr/share/man/man1"
MANDIR = /usr/share/man
# Uncomment the next line to install Vim help files in "/usr/share/vim"
DATADIR = /usr/share

5. Configure vim. Remember to enable –enable-fail-if-missing to see if something is missing.

$ cd vim/src
$ ./configure --with-features=huge --enable-cscope --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu --enable-multibyte --enable-fontset --disable-gui --disable-netbeans --enable-luainterp=yes --with-lua-prefix=/usr/include/lua5.1 --enable-largefile --enable-fail-if-missing

It is very probably that lua fails to find lua.h. This is because the configuration script is expecting a different directory structure. Do the following if this happens:

$ sudo mkdir /usr/include/lua5.1/include
$ ln -sf /usr/include/lua5.1/* /usr/include/lua5.1/include/; rm /usr/include/lua5.1/include/include
$ sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/local/lib/liblua.so

Come back to step 5.

6. Build

$ make

7. Set up environment

$ sudo ln -sf $CLONE_DIR/vim/src/vim /usr/bin/vim
$ sudo ln -sf /usr/bin/vim /usr/bin/vi

MacOS

For MacOS the process is pretty much the same. The only requirement is having brew installed.

1. Install hg

$ brew install hg

2. Clone the repository

$ hg clone https://vim.googlecode.com/hg/ vim

3. Install the necessary libraries. Many YADR packages require vim to be compiled with  if_lua, thus we need to install that package. Depending on the configuration you require for vim, other packages might be necessary.

$ brew install lua

4. Allow vim to install help files (e.g., colors, language support) and manuals.


$ vi $VIM_DIR/src/Makefile
# Uncomment the next line to install Vim manuals in "/usr/share/man/man1"
MANDIR = /usr/share/man
# Uncomment the next line to install Vim help files in "/usr/share/vim"
DATADIR = /usr/share

5. Configure vim. Remember to enable –enable-fail-if-missing to see if something is missing. Note that the path to the lua library is different than in Ubuntu

$ cd vim/src
$ ./configure --with-features=huge --enable-cscope --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu --enable-multibyte --enable-fontset --disable-gui --disable-netbeans --enable-luainterp=yes --with-lua-prefix=/usr/local/Cellar/lua/5.2.3_1 --enable-largefile --enable-fail-if-missing

6. Build

$ make

7. Set up environment

$ sudo ln -sf $CLONE_DIR/vim/src/vim /usr/local/bin/vim
$ sudo ln -sf /usr/local/bin/vim /usr/bin/vi

Now you can maintain vim updated, fix broken extensions, and try your own patches without depending on people updating vim binaries.

Enjoy! 🙂

Javier.

Leave a comment