Ever worked on a server that you didn’t have root privileges and you’ve wanted some software to be installed but the IT guy said no?
This is the right place!
In this articles I will explain how to install software you want or need without root privileges.
Today: Vim + You CompleteMe
Normally I’m using Ubuntu or other updated enviroment, and then Vim and other components are more up to date.
About 3 months ago I’ve started working on a CentOS 6.3 server which I had no root privileges to and I’ve wanted to install YouCompleteMe – the problem:
YouCompleteMe needs an updated version of vim, at least 7.3.584 and cmake 2.8.x (where CentOS 6.3 has vim 7.2.x and cmake 2.6.x)
For the record: Centos 6.5 (most updated) still had the same major versions of vim and cmake.
Comment: This document also apply to install updated vim and YouCompleteMe on a system with root access but older packages (and you don’t want to mess with the repositories)
First of all we will need to download an updated vim version (Source):
hg clone https://code.google.com/p/vim/ -- or if you don't have Mercurial -- wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
Second you will need to untar + compile it:
--- If needed --- tar xvzf vim-7.4.tar.bz2 --- then configure --- ./configure --prefix=~/vim74 \ --with-features=huge \ --enable-rubyinterp \ --enable-pythoninterp \ --with-python-config-dir=/usr/lib/python2.6/config \ --enable-perlinterp \ --enable-gui=gtk2 --enable-cscope \ --enable-luainterp make make install
- Notice: I’ve selected that the installation will take place under ~/vim7.4 (your home directory) with –prefix command – thus no root needed
- Note that even in Centos 6.5 the python’s libraries are 2.6.x thus the –with-python-config-dir=/usr/lib/python2.6/config
(original document uses python 2.7)
- Additional development libraries are needed for the compilation – if you don’t have them request from your IT guy to install them (no workaround in this document)
After the installation complete add this line to your ~/.bashrc so when you type vim/gvim in the terminal the correct version will be opened:
alias gvim="~/vim74/bin/gvim" alias vim="~/vim74/bin/vim"
- The raw vim you’ve installed miss some of the basic elements of the preinstall vim on Ubuntu and CentOS.
Here are some recommendations you want to add to your ~/.vimrc file:
syntax on " Enable syntax highlight set backspace=2 "Set backspace behavior to normal
All done with the vim – now you have an updated version of it.
Vim is rich with modules on anything and everything you will ever need. YCM is one of them and it is a popular one, It gives you the ability to easy auto complete with preview window (explanation on the function/object you want to use).
Vundle and YMC installtion and configuration:
mkdir ~/.vim cd ~/.vim git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle echo "set nocompatible" >> ~/.vimrc echo "filetype off" >> ~/.vimrc echo "set rtp+=~/.vim/bundle/vundle/" >> ~/.vimrc echo "call vundle#rc()" >> ~/.vimrc echo "Bundle 'gmarik/vundle'" >> ~/.vimrc echo "Bundle 'Valloric/YouCompleteMe'" >> ~/.vimrc echo "filetype plugin indent on" >> ~/.vimrc
After you’ve done install the plugin by running Vim and invoking:
You will see that the YCM installation is not complete – you will need to run .install.sh from the YMC directory to complete the installation.
The Problem: CentOS comes with an old cmake and you will need to download a new one.
Download the file cmake-2.8.x.x-Linux-i386.tar.gz from Here.
Untar the the file at your convinient location.
This is an already compiled version!
Now after you have the new cmake edit the file ~/.vim/bundle/YouCompleteMe/install.sh
Find the line that start with:
cmake -G "Unix Makefiles"
and replace it with (this is example for the version I’ve installed of cmake):
~/Downloads/cmake-126.96.36.199-Linux-i386/bin/cmake cmake -G "Unix Makefiles"
Now you can install YCM with invoking ./install.sh
- For you python lovers additional smart complete for python (extent support for YCM) add the bundle: ‘davidhalter/jedi’
- You can add these lines for the ~/.vimrc so the preview window of dunctions/objects will disapear after you’ve finished calling it:
let g:ycm_add_preview_to_completeopt = 0 let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_autoclose_preview_window_after_insertion = 1