第一步 安装vim cmake python
sudo apt install build-essential cmake vim-nox python3-dev
第二步 安装clang
sudo apt-get install clang
第三步 安装git
sudo apt-get install git
第四步 安装VUNDLE
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
在家目录下,vim .vimrc
在.vimrc文件中粘贴下边几句话:
set shell=/bin/bash
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.
" plugin on GitHub repo
" 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
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
打开VIM输入
:PluginInstall
第五步 安装YCM
输入命令
cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git
cd ~/.vim/bundle/YouCompleteMe
然后输入以下命令,在git过程中可能会出现错误,继续git submodule update --init --recursive
git submodule update --init --recursive
上面这部分超级慢,上次搞了我一个多小时,耐心等着就行
第六步 编译YCM
编译的时候也是很慢的
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clangd-completer
出现这3个ok就是编译完成了。
等待编译完成后,在 vim 的配置文件 ~/.vimrc 中添加一行(在call vundle#begin() 和 call vundle#end() 之间)
call vundle#begin()
. . .
Plugin ‘Valloric/YouCompleteMe’
. . .
call vundle#end()
然后保存运行 vim 命令 :PluginInstall。
此时基本完成了,但需要一些配置才能智能提示和代码补全功能。
配置YCM
第72的参数路径是你存放.ycm_extra_conf.py的路径
效果如图
参考链接https://www.freesion.com/article/7538590478/
参考链接https://github.com/ycm-core/YouCompleteMe#installation