欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ubuntu18.04 YCM(YouCompleteMe)自动补全插件安装

程序员文章站 2024-03-21 17:36:28
...

1:准备(若已准备则跳过)

1.cmake安装:    sudo apt install cmake
2.python3安装:   sudo apt install python3  python3-dev
3.gcc/g++库:     sudo apt install build-essential
4.git安装:	 sudo apt install git
5.llvm-clang安装:sudo apt install libclang-7-dev llvm-7 clang-7 libboost-all-dev
		删除旧版本(若存在):自动:sudo apt autoremove
		                手动:sudo apt --purge <name>
   更新clang++:sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 1 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-7

2: 安装vim的插件管理器Vundle与YCM

mkdir -p ~/.vim/bundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

修改~/.vimrc文件,
若不存在则创建,写入:
set nocompatible              " be iMproved, required
filetype off                  " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
call vundle#end()            " required
filetype plugin indent on    " required

若已存在,在begin()与end()之间加入
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'

在vim中输入:PluginInstall并执行,然后耐心等待安装结束

3:安装与配置

cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --system-libclang
mkdir ~/.vim/bundle/YouCompleteMe/cpp/ycm -p
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/bundle/YouCompleteMe/cpp/ycm
echo "let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'" >> ~/.vimrc

4:查看效果
ubuntu18.04 YCM(YouCompleteMe)自动补全插件安装

相关标签: ubuntu vim linux