Ubuntu18种安装vimd的补全插件YouCompleteMe

4 篇文章 0 订阅

一、需要准备的依赖项

1、cmake14以上
2、gcc8.0以上
3、vim8.2以上
4、含有python3开发环境
5、clang7.0以上
首先讲上述依赖项安装成功。
1、Ubuntu18安装clang11
(1)gedit /etc/apt/sources.list
在文件中加入:

deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main

(2)`
sudo apt-get update
sudo apt-get upgrade
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

(3)

sudo apt-get install clang-11 lldb-11 lld-11
sudo apt-get install libc++-11-dev libc++abi-11-dev

(4)

cd /usr/bin
sudo ln -s clang-11 clang
sudo ln -s clang++-11 clang++
sudo ln -s /usr/bin/llvm-ar-11 /usr/bin/llvm-ar
sudo ln -s /usr/bin/llvm-as-11 /usr/bin/llvm-as
sudo ln -s /usr/bin/clangd-11 /usr/bin/clangd
sudo ln -s /usr/bin/clang-tidy-11 /usr/bin/clang-tidy

二、安装Vundle

这是vim下插件的管理工具,首先安装该工具。

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

输入cd ~进入家目录,再输入vim ~/.vimrc进行vim配置,让vim安装该插件。
将一下内容复制到.vimrc文件中:

 
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

然后按esc进入vim的命令模式,按ZZ保存并且退出。重新输入vim进入:

```bash
:PluginInstall

以上命令进入末行模式并且安装该管理工具。

三、安装YouCompleteMe

1、下载源文件

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

2、下载相关依赖

cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive

3、编译并且配置

./install.py

运行成功之后在 ~/.vimrc 中的call vundle#begin() 和 call vundle#end() 之间加入以下内容:

Plugin 'Valloric/YouCompleteMe'

保存并且退出,重新进入vim,输入末行模式并且安装:

:PluginInstall

至此插件安装完成,并且只要需要其他插件的时候,可将插件的源代码包下载到~/.vim/bundle/,并在 ~/.vimrc 中的call vundle#begin() 和 call vundle#end() 之间加入以下内容:

Plugin 'Valloric/你的安装包'

然后按照上述命令进行安装。
4、其他配置
到此为止,基本的配置工作就完成了,但是还有一点瑕疵:#include , #include vector, 什么的都不能补全,这是因为这些头文件的路径没有被找到,下面的工作就是要让YouCompleteMe找到这些头文件,而且,以后有什么库文件,比如OpenCV,OPenGL什么的,都可以按照这个方法添加。
打开 ~/下的.vimrc文件,确保查看是否有这样一条配置:

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

然后在该python中的flags[ * ]数组的后面添加你想要的路径,例如: stdio.h等C语言的头文件包含在/usr/include中,那么您需要添加这样一条

‘-isystem’,

‘/usr/include’,

注意,不要忘记后面的“,”。

需要CPP的补全,就需要添加:

‘-isystem’,

‘/usr/include/c++/8’,
5、其他plug命令
PluginInstall [name …],安装插件,如不写name则表示安装所有写在配置文件的插件。

PluginUpdate [name …],更新插件,

PlugClean,删除插件。删除配置文件没有列出的插件,默认删除会有提示。如果加上了!,则不会有提示。

PluginStatus,查看插件安装状态。
参考:https://blog.csdn.net/weixin_42929607/article/details/108978323
https://www.jianshu.com/p/3c7eae5c0c68

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值