youcompleteme-Vim补全插件安装

这个补全插件从名字看很腻害了~

  1. 系统环境:ubuntu64,准备安装youcompleteme
  2. 确认Vim版本:打开vim就可以看到版本号了,需要大于7.4.143
  3. 确认Vim支持Python:进入Vim,输入:echo has('python') || has('python3'),结果需要为1
  4. 安装Vundle:git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  5. 编辑~/.vimrc,使用Vundle安装各种插件:
    1  set nocompatible                                                            
    2   filetype off
    3   set rtp+=~/.vim/bundle/Vundle.vim
    4   call vundle#begin()
    5   Plugin 'VundleVim/Vundle.vim'
    6   Plugin 'Valloric/YouCompleteMe'
    7  call vundle#end()
    8  filetype plugin indent on
  6. 再打开Vim,输入:PluginInstall,等待出现done!成功安装标志。
  7. 从http://llvm.org/releases/download.html下载Pre-Built Binaries(clang+llvm),解压进入目录并复制到系统目录,再配置一下软链接,最后确定clang版本号就表明clang是最新版
    1 tar zxvf clang+llvm-3.7.0-amd64-Ubuntu-14.04..tar.gz
    2 cd clang+llvm-3.7.0-amd64-Ubuntu-14.04
    3 sudo cp -R * /usr/
    4 sudo ln -sf /usr/bin/clang++ /etc/alternatives/c++
    5 clang --version
  8.  编译youcompleteme

    1 cd ~/.vim/bundle/YouCompleteMe
    2 mkdir build
    3 cd build
    4 cmake -G "Unix Makefiles" -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
    5 make ycm_core -j4  
  9. 配置.ycm_extra_conf.py

    1 echo | clang -v -E -x c++ -
    2 vim ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py
    3 insert flags: ‘isystem', '/usr/include/,(将echo结果写入,最后一个不用‘,’)  
  10. 配置.vimrc
    1 let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

     好咯,安装就到这了,具体的使用就要常用常查了

原文地址:https://www.cnblogs.com/mantouRobot/p/6121423.html