首先系统是Ubuntu16.04系统
1、ubuntu16.04系统是自带vim,如有需要下载vim
sudo apt-get install vim-gtk
确定你的vim是支持python
在python3前面有加号亲测可以!!!
2、按照YouCompleteMe的git说明要安装cmake和python-dev
1 sudo apt-get install build-essential cmake 2 sudo apt-get install python-dev python3-dev
3、安装vim的拓展管理器Vundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
安装完成后再安装地方建立文件.vimrc作为Vundle的配置文件
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin(‘~/some/path/here‘) " let Vundle manage Vundle, required Plugin ‘VundleVim/Vundle.vim‘ " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on
再begin和end之间加各种插件配置,这里我们要补全代码的插件YouCompleteMe
在两个之间加上Plugin ‘Valloric/YouCompleteMe‘
不过这里建议先自己下载后再加上
4、建议在~/.vim/bundle/上下载YouCompleteMe
1 git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 2 git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe 3 cd ~/.vim/bundle/YouCompleteMe 4 git submodule update --init --recursive
5、在下载完后选择要支持的语言这里支持C系列语言
1 cd ~/.vim/bundle/YouCompleteMe 2 ./install.py --clang-completer
其他的语言根据git说明设置
使用系统设置的c
./install.py --clang-completer --system-libclang
6、配置YCM
完成后对YCM中还要进行配置要使用的库路径什么的
~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/下的.ycm_extra_conf.py中的flags进行加入
1 ‘-isystem‘, 2 ‘/usr/include‘, 3 ‘-isystem‘, 4 ‘usr/include/c++/5.4.0‘ 5 ‘-isystem‘, 6 ‘usr/include/x86_64-linux-gnu/c++‘,
注释掉
1 try: 2 final_flags.remove( ‘-stdlib-libc++‘ ) 3 except ValueError: 4 pass
然后再前面自己建立的.vimrc中加入
1 let g:ycm_global_ycm_extra_conf = ‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py’ "配置全局路径 2 let g:ycm_confirm_extra_conf=0 "每次直接加载该文件,不提示是否要加载完成!!!