Ubuntu15.04YouCompleteMe插件安装

0x00. 简介html

YouCompleteMe号称Vim的自动补全神器,YouCompleteMe: a code-completion engine for Vim,该项目在github的地址:YouCompleteMepython

0x01. Requirementslinux

Vim is at least 7.3.584 and it has support for python2 scripting.c++

0x02. 用Vundle来安装YCM(YouCompleteMe)git

安装其实很是简单,在.vimrc文件中加入语句 Bundle 'Valloric/YouCompleteMe' 便可,保存,退出,而后再次打开Vim,normal模式下输入 :BundleInstall 即开始下载。以下图:github

也能够切换至 .vim/bundle 下手动下载,输入以下命令:vim

git clone https://github.com/Valloric/YouCompleteMe.git

手动下载完后检查仓库的完整性,切换到 YouCompleteMe 目录下,输入以下命令:ui

git submodule update --init --recursive

0x03.  下载最新的libclangspa

Clang是一个开源的编译器,它能够编译C/C++/Objective-C/Objective-C++. Clang提供的libclang库是用来给YCM为这些语言提供语义补全的引擎。和YCM配合的libclang版本必须 >=3.6 ,但理论上也是能够和 3.2+ 版本的libclang配合使用的。下载最新的libclang以下:3d

sudo apt-get install libclang-dev

0x04. 编译YCM须要的ycm_support_libs库

首先要确保你已经安装类cmake。若是没有,请按以下安装:

sudo apt-get install cmake

其次须要确保你有一些 Python 头文件。若是没有,请按以下安装:

sudo apt-get install python-dev

接下来,建立新的文件夹 ycm_build 进行编译,以下:

1 cd ~
2 mkdir ycm_build
3 cd ycm_build

不须要语义补全的童鞋们,直接执行下面的语句:

cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

然并卵啊,俺们是须要语义补全的呀~,那么请先去 llvm.org 下载最新的 clang+llvm 包,而后把它们解压到 ~/ycm_temp/llvm_root_dir 文件夹下。接着,执行以下语句:

cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

再接着要开始编译 ycm_support_libs 库,执行以下语句:

make ycm_support_libs

这样就编译完了。

0x05. 配置YCM

本渣开始觉得编译完了就完事了,谁知道再次打开Vim,它来了这么一句:No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++. 哦呵呵呵~

~/.vim/bundle/YouCompleteMe 文件夹下一看。。。没有 cpp !没有 cpp !没有 cpp !

咋办?新建呗。。。而后把 YCM‘S own .ycm_extra_conf.py 文件拷贝到相应的文件夹下。

接着再次打开 .vimrc 配置YCM,以下:

"YouCompleteMe
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

以后再次打开Vim便可。

为了补全,咱们还须要在 .ycm_extra_conf.py 文件中进行配置,以下:

1 '-isystem',
2 '/usr/include',
3 '-isystem',
4 '/usr/include/c++/4.9.2',
5 '-isystem',
6 '/usr/include',
7 '/usr/include/x86_64-linux-gnu/c++',

0x06. Summary

城里人真会玩:)

本身再配置配置能够起飞了~

相关文章
相关标签/搜索