Vim插件YCM的安装

时间:2022-10-01 17:28:14

YouCompleteMe(YCM)是一款非常好用的Vim插件,但是很多人安装的时候会出问题(尤其是涉及到C和C++的补全),我安装的时候也遇到了问题,现在解决了,给大家参考:

Step1: 通过Vundle安装YCM,具体参考我的上一篇博文

Step2: 

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

Step3: (如果不补全C famliy语言可跳过step3)

cd ~/.vim/bundle/YouCompleteMe
mkdir cpp
cd cpp
wget https://raw.githubusercontent.com/Valloric/ycmd/66030cd94299114ae316796f3cad181cac8a007c/.ycm_extra_conf.py

编辑刚才下载的.ycm_extra_conf.py

DIR_OF_THIRD_PARTY = os.path.join( DIR_OF_THIS_SCRIPT, 'third_party' )

替换为

DIR_OF_THIRD_PARTY = os.path.join( DIR_OF_THIS_SCRIPT, '../third_party' )

 

然后在 ~/.vimrc中加入下面的语句:

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

 

然后再打开VIM,就发现可以自动补全了。

 

参考链接:https://github.com/Valloric/YouCompleteMe