Boost your Vim autocompletion with YouCompleteMe and Jedi (on a CentOS system)
@ Tony Cheneau | Thursday, May 30, 2013 | 4 minutes read | Update at Thursday, May 30, 2013

Recently, Steve Francia’s Vim Distribution (aka vim-spf13) brought a new life to my aging vimrc dotfile. It bundles most of the popular plugins that makes you life as a programmer easier (Syntastics, ctrlp, …). The only thing missing to make it into a good IDE is a completion plugin for C and C++. In this brief blog entry, I’ll show you how to install YouCompleteMe on CentOS and improve your Vim experience.

As I said, this small howto will walk you through installing YouCompleteMe and Jedi on a CentOS 6.3 system. YouCompleteMe will offer C/C++ autocompletion based on the suggestion provided by clang. The YoucCompleteMe plugin website offers a great deal of information on how to install the plugin and its dependencies.

On most distros, you’ll install this plugin in a breeze. Other distros, like CentOS will make you life tougher. Because I found it to complete, I was compelled to write this documentation page. I will mostly focus on fixing these two main issues:

  • installing YouCompleteMe on vim-spf13 will conflict with existing (now redundant) plugins shipped with vim-spf13
  • breathing a new life into [CentOS] by installing new version of the [Vim] and clang

Assumption

  • you are running on CentOS 6.3
  • you are using vim-spf13 and know how to configure it
  • you are willing to spend half an hour for installing a Vim plugin

Dependencies

You need cmake28 to compile the plugin. Install it is as easy as:

sudo yum install -y cmake28

Upgrading Vim

The version of Vim shipped with CentOS at the time of the writing of this entry is 7.2.xxx, whereas vim-spf13 requires the 7.3.xxx branch and YouCompleteMe requires at least Vim 7.3.584.

Before anything else, you need to install a newer version of Vim. In my case, I installed the source RPM of Vim in the latest Fedora and compiled it. You can find a slightly modified source RPM. Install this archive with rpm -i and build the packages from the source using rpmbuild -bb vim.spec (this file should be in your SPEC subdirectory of the rpmbuild directory, which should be located in your home by default).

For more information, you can look at the dedicated CentOS page.

Preparation work

This plugin WILL conflict with other plugins part of the vim-spf13 default distribution. They should be disabled first, add the following lines to your ~/.vimrc.local:

UnBundle 'Shougo/neocomplcache'
UnBundle 'pythoncomplete'

Now, you need to tell Vim to actually removes both packages:

vim -c ':BundleClean!'

Also, you should undo some default binding of vim-spf13 so that they don’t conflict with YouCompleteMe later on. Again, edit your ~/.vimrc.local and add the following lines:

iunmap <expr><s-CR>
iunmap <expr><CR>
iunmap <expr><BS>
iunmap <expr><C-y>

Installing the plugins

Add the following line to you ~/.vimrc.bundles.local

Bundle 'Valloric/YouCompleteMe'
Bundle 'davidhalter/jedi'

Now ask Vim to install these packages:

    vim -c ':BundleInstall'

The YouCompleteMe plugin installation is not complete just yet. It needs you to compile things, and that where it gets hairy on CentOS (because the clang version shipped with the system is too old).

Installing clang locally

In order to get YouCompleteMe to work, a recent version of clang is required. While you can build from source, I preferred to save some time and downloaded a version that was built for my system. Ryan Prichard hosts built version for for a lot of systems that are not pre-packaged in the clang website (many thanks to him!). You can download an archive on his project’s website. In my case, I downloaded the x86_64 version.

I extracted the tarball in a ~/tools directory (located in my home). If this directory does not exists, you can create it with:

	mkdir ~/tools

Then I did the following to build the plugin:

mkdir ~/.vim/bundle/YouCompleteMe/ycm_build
cd ~/.vim/bundle/YouCompleteMe/ycm_build
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/tools/clang-3.2-1-x86_64-linux/lib
cmake28 -G "Unix Makefiles" \
        -DPATH_TO_LLVM_ROOT=~/tools/clang-3.2-1-x86_64-linux/ . ~/.vim/bundle/YouCompleteMe/cpp
make

If everything goes fine, the make command completes. One last step remains, if you don’t want to have to overload the LD_LIBRARY_PATH variable each time you use the plugin. You need to copy the libllvm.so file in a path where the plugin can always find it. In my case, I did the following:

cp tools/clang-3.2-1-x86_64-linux/lib/libLLVM-3.2svn.so ~/.vim/bundle/YouCompleteMe/python

You’re all set, but don’t forget to read the YouCompleteMe manual, or else you might omit to create a .ycm_extra_conf.py in you C/C++ project directory and think the plugin is malfunctioning.

Comments

You can use your Mastodon account to reply to this post.

Reply

Copyright by Tony Cheneau

Everything about $me

My name is Tony Cheneau and I’m currently a devops (catchy title) at ANSSI.

I was previously occupying a postdoc position at the National Institute of Standards and Technology (also known as NIST), in the Advanced Network Technologies Division. This was a really entertaining job where my main research interests are focused on wireless applications over the Smart Grid and defining new security solution for these applications.

If you are interested in my education (or in hiring me), you can check out my very formal (and not so up to date) resume.pdf.

How you can contact me

My previous projects

  • SimpleRPL: an implementation of the Routing Protocol for Low-Power and Lossy Networks (RFC 6550)
  • NDprotector: an implementation of the Cryptographically Generated Addresses (RFC 3972) and the Secure Neighbor Discovery Protocol (RFC 3971)
  • and more on my GitHub page

Former research interest

During my PhD, I studied several aspects of the Link-Layer security. through the extended use of the Secure Neighbor Discovery protocol (RFC 3971 and RFC 3972).

Other of my previous research interests included MANEMO. MANEMO is the combination of multiple research areas:

  • MANET (Mobile Ad-Hoc Network) specifies how new dynamic routing protocols enable mobile node to route packets over Mobile Ad-Hoc Networks.
  • NEMO (Network Mobility or Network that Moves) defines a protocol similar to Mobile IP where a whole network is moving.
  • AUTOCONF defines an addressing scheme and corresponding solutions to allocate addresses inside a MANET.

Publications

Thesis

  • Tony Cheneau, « Amélioration des adresses CGA et du protocole SEND pour un meilleur support de la mobilité et de nouveaux services de sécurité (Enhancing CGA addresses and the SEND protocol for a better support of mobility application and new security services) », January 2011 manuscript slides

Journals

  • Tony Cheneau, Aymen Boudguiga, Maryline Laurent, « Significantly improved performances of the cryptographically generated addresses thanks to ECC and GPGPU », Computers & Security journal, Elsevier, Volume 29, pages 419-431, June 2010. pdf

Conferences

  • Tony Cheneau, Ranganathan Mudumbai, « Adaptive key management for wireless sensor networks », IEEE Global Communications Conference (GLOBECOM), Atlanta, USA, December 2013.
  • Tony Cheneau, Andrei V. Sambra, Maryline Laurent, « A Trustful Authentication and Key Exchange Scheme (TAKES) for Ad Hoc Networks », 5th International Conference on Network and System Security (NSS), Milan, Italy, September 2011. pdf
  • Tony Cheneau, Maryline Laurent, « Using SEND Signature Algorithm Agility and Multiple-Key CGA to Secure Proxy Neighbor Discovery and Anycast Addressing », 6th Conference on Network Architectures and Information Systems Security, La Rochelle, France, May 2011. pdf slides
  • Tony Cheneau, Maryline Laurent, « Étude des solutions de proxy Neighbor Discovery sécurisées et proposition basée sur la Signature Agility » (a study of secure proxy Neighbor Discovery solutions and proposition of a Signature Algorithm Agility based solution) , 5ème Conférence sur la Sécurité des Architectures Réseaux et des Systèmes d’Information, Menton , France, May 2010. pdf slides
  • Tony Cheneau, Aymen Boudguiga, Maryline Laurent-Maknavicius, « Amélioration des performances des adresses CGA et du protocole SEND: étude comparée de RSA et d’ECC/ECDSA » (Improving the CGA and SEND protocol performances: a comparative study of RSA and ECC/ECDSA), 4ème Conférence sur la Sécurité des Architectures Réseaux et des Systèmes d’Information, Luchon, France, (best student paper award), pages 139-156, in proceedings (SAR-SSI 2009) (ISBN: 978-2-7483-4833-0), June 2009. pdf proceedings slides
  • Tony Cheneau, Jean-Michel Combes, Une attaque par rejeu sur le protocole SEND » (A replay attack on the SEND protocol), 3ème Conférence sur la Sécurité des Architectures Réseaux et des Systèmes d’Information, Loctudy, France, pages 289-300, in proceedings (SAR-SSI 2008) (ISBN: 978-2-7483-3289-2), October 2008. pdf proceedings slides

Research Report

  • Aymen Boudguiga, Tony Cheneau, Maryline Laurent-Maknavicius, « Usage and Performance of Cryptographically Generated Addresses » TELECOM and Management SudParis, 08-014 LOR, 2008. zip

Internet Drafts

Back in time, I made some propositions inside the CGA and SEND maIntenance working (CSI) group:

  • draft-cheneau-csi-send-sig-agility-02 proposes a Signature Agility Solution to the SEND protocol (RFC3971). link
  • draft-cheneau-csi-ecc-sig-agility-02 on the previous draft and proposes to use Elliptic Curve Cryptography in CGA (RFC 3972) and SEND (RFC 3971). link

Teachings

During my PhD, I happened to give some lecture:

  • Data network (ingénieurs 1ère année)
  • Virtual Private Network (Master 2 CCN, Master spécialisé SSR et ingénieurs 3ème année)

Education

  • 2007-2011: PhD held at the Institut Télécom SudParis under the direction of Maryline Laurent. This PhD was funded by a grant of the ANR for the MobiSEND project.
  • 2007: Master 2 SSI (sécurité des systèmes informatiques), University of Paris XII, obtained with mention bien
  • 2006: Master 1 d’informatique (STIC - F3I), University of Poitiers, obtained with mention bien
  • 2005: Licence 3 d’informatique (TIS - parcours des réseaux), University of Poitiers, obtained with mention bien
  • 2004: DEUG MIAS (mathématiques et informatique en application en science), University of Poitiers
  • 2002: Baccalauréat S Sciences de l’Ingénieur, lycée E. Branly de Châtellerault (Poitiers academy), obtained with mention assez bien