UBUNTU 14.04 + VIM + youcompleteme installation configuration

Source: Internet
Author: User

Want your vim to have a c/cpp code complement function? It is recommended that you use the Youcompleteme tool. The configuration is a little cumbersome, but under my step-by-step instructions, you will be able to do very well.

First mention a few key tools and their links:

Vundle: It is a vim plug-in manager, very useful, to install Youcompleteme first need to install Vundle.

Youcompleteme: Code completion tool.

CMake, LLVM, clang and some other installation youcompleteme dependent tools.

In fact, all the installation steps in Vundle, as well as youcompleteme two addresses above have been said to be very thorough, but because the first installation, you may not have much experience, see so many need to install the tool feel big head. Below we step by step to operate, I believe that according to the following operation, you will be able to successfully complete the code completion function.

First, you want to ensure that your Vim version number is higher than 7.3.584, you can enter by the terminal:

Vim--version

To see the version number of your VIM. If you do not have vim, you need to install it yourself.

Step two, install CMake

sudo apt-get install build-essential cmake

Step three, install LLVM and clang

To www.llvm.org download the corresponding version of LLVM and clang, because I am using the Ubuntu 14.04 64bit system so I directly download the pre-build binary version without the need to download the source code and then recompile. Save a lot of trouble.

After the download is complete, unzip the downloaded zip file directly and enter its directory

Tar zxvf clang+llvm-3.7.0-amd64-ubuntu-14.04. TAR.GZCD clang+llvm-3.7.0-amd64-ubuntu-14.04.

Where *.tar.gz is the compressed file you downloaded.

To run the command:

sudo cp-r */usr/

Copy all the files in the directory to the appropriate system directory, and then configure the soft link:

sudo ln-sf/usr/bin/clang++/etc/alternatives/c++

where "s" in "-SF" represents a soft link, "f" is the meaning of force.

Run: clang--version If you see its version number, it means that LLVM and clang are configured.

Fourth step: Install Vundle, the installation process please refer to https://github.com/VundleVim/Vundle.vim#about; p.s. : If you are installing VIM for the first time, you may need to create your own vim profile, which is a hidden file in the "~/" directory. The "dot" in front of VIM indicates that this is a hidden directory that can be viewed with ls-a, and if not, create the directory. namely: mkdir ~/.vim

To configure the Vundle, open the. vimrc file in the home directory, which is configured according to the steps of the previous installation of Vundle, please call Vundle#begin () and calling Vundle#end () Add Plugin ' valloric/youcompleteme ' between, in addition to the Begin () and end () in addition to Plugin ' Vundlevim/vundle.vim ' and Plugin ' Valloric /youcompleteme ' Other plugin are commented out, feeling no eggs.

Fifth Step: Install plug-ins with Vundle

Very simple, open vim in the terminal, enter ":P Lugininstall", wait for the Vundle to complete installation. This may take some time. When Vim's bottom bar is displayed: done! (note is not done with error!!! ) indicates that the installation was successful.

Sixth step: Compile Youcompleteme, in order not to guarantee error, I use a completely installed method.

CD ~mkdir YCM_BUILDCD Ycm_build

Because I want to support C/cpp's semantic support, I choose:

Cmake-g "Unix makefiles"-duse_system_libclang=on. ~/.vim/bundle/youcompleteme/third_party/ycmd/cpp

Here, I choose to use the system Libclang, because we also downloaded from the official website Llvm+clang (the directory has bin, Lib, include and other folders), we can also execute: cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp 其中“~/ycm_temp/llvm_root_dir”就是我们解压过的文件的根目录

Seventh Step: Generate

Make Ycm_support_libs

At this point, the basic configuration is done, but there is a flaw: # include <iostream>, #include <stdio> vector, nothing is complete, because the path to these header files is not found, The following job is to let Youcompleteme find these header files, and, in the future, what library files, such as Opencv,opengl, can be added in this way.

Open the. vimrc file under ~/, and make sure to see if there is a configuration like this:

Let g:ycm_global_ycm_extra_conf = ' ~/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py '

If not, please modify the path of the. ycm_extra_conf.py is correct.

Open ~/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py

Vim ~/.vim/bundle/youcompleteme/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py

You can add the path you want after the flags[*] array, for example, the header file for C language such as Stdio.h is included in the/usr/include, so you need to add such a

'-isystem ',

'/usr/include ',

Be careful not to forget the "," in the back.

Need to complete the CPP, you need to add:

'-isystem ',

'/usr/include/c++/4.7 ',

What you need, just add what, so easy.

UBUNTU 14.04 + VIM + youcompleteme installation configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.