centos7下安装vim的YouCompleteMe插件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014483177/article/details/52843532

以下简称ycm
1、安装git
yum install git
2、下载Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

3、安装cmake和python:

yum install cmake python-devel

4、下载和安装ycm

git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer或者./install.py --all

具体请在https://github.com/Valloric/YouCompleteMe自行查看
如果不能安装,会有提示,跟着敲提示的命令就行,可能还要装很多东西


5、编辑virmc
vim /etc/vimrc(不同系统位置可能不同)

输入内容如下(参考github上vundle文档):

set nocompatible            
filetype off               

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'  

call vundle#end()  
filetype plugin indent on 

ycm设置:

let g:ycm_global_ycm_extra_conf = ~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py
let g:ycm_seed_identifiers_with_syntax=1      
let g:ycm_confirm_extra_conf=0
let g:ycm_cache_omnifunc=0
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_complete_in_comments=1
let g:ycm_complete_in_strings=1

ycm的具体配置可以参考github上的文档

输入命令:PluginInstall,如果显示无此命令,保存退出重进就有了

6、ycm添加c++头文件补全(git上copy下来的)

Completion doesn't work with the C++ standard library headers

This is caused by an issue with libclang that only affects some operating systems. Compiling with clang the binary will use the correct default header search paths but compiling with libclang.so (which YCM uses) does not.

Mac OS X is normally affected, but there's a workaround in YCM for that specific OS. If you're not running that OS but still have the same problem, continue reading.

The workaround is to call echo | clang -v -E -x c++ - and look at the paths under the #include <...> search starts here: heading. You should take those paths, prepend -isystem to each individual path and append them all to the list of flags you return from your FlagsForFile function in your .ycm_extra_conf.py file.

猜你喜欢

转载自blog.csdn.net/u014483177/article/details/52843532