customized compiled versions of vim

I needed two different versions of vim: both with Ruby support and each with support for python2 and python3. It is currently impossible for an instance of vim to support both versions of Python at the same time.

prerequisites

  • Install the required libraries.
sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
    libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
    libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
    python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev git
  • Switch to system ruby or make sure that the ruby path is not version 2.3.
rvm use 2.2
# 'system' in place of 2.2 will likely suffice as well

steps

running this script will install vim with support for ruby and python2

#!/bin/bash
\# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

    \# First try to load from a user install
    source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

    \# Then try to load from a root install
    source "/usr/local/rvm/scripts/rvm"

else

    printf "ERROR: An RVM installation was not found.\n"

fi
rvm system
echo `which ruby`
repo=/tmp/vim_python2_sys_ruby
rm -rf "$repo"
git clone https://github.com/vim/vim "$repo"
cd "$repo"
./configure \
--enable-perlinterp \
--enable-pythoninterp \
--enable-rubyinterp 
--with-ruby-command=/home/dmmmd/.rvm/rubies/ruby-2.2.6/bin/ruby \
--enable-cscope 
--enable-gui=auto \
--enable-gtk2-check \
--enable-gnome-check \
--with-features=huge 
--enable-multibyte \
--with-x \
--with-compiledby="xorpd" 
--with-python2-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ 
--prefix=/opt/vim8.0p2
make VIMRUNTIMEDIR= /opt/vim8.0p2
cd "$repo"/src
make test
cd /tmp/"$repo"

for python 3 support replace the relevant line above

--with-python3-config-dir=/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/

caveates

  • --with-ruby-command indicates which ruby binary you want vim to use. It must exist. I had no luck with version = 2.3

    There is an issue filed on GitHub

    Even though you might set the binary to something like the above, vim won't properly compile unless the env ruby is the system one.

    rvm use system
    
  • If you want to set the ruby version in a bash script, this must appear first in the script before rvm will function.

    # Load RVM into a shell session *as a function*
      if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
    
        \# First try to load from a user install
        source "$HOME/.rvm/scripts/rvm"
    
      elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
    
        \# Then try to load from a root install
        source "/usr/local/rvm/scripts/rvm"
    
      else
    
        printf "ERROR: An RVM installation was not found.\n"
    
      fi