安装vim插件YouCompleteMe

30 篇文章 0 订阅
3 篇文章 1 订阅

仓库地址 https://github.com/ycm-core/YouCompleteMe

安装编译环境:

sudo apt install build-essential cmake
sudo apt install python-dev python3-dev
sudo apt install ctags
sudo apt install gcc g++
sudo apt install clang libclang-dev
git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

Compiling YCM with semantic support for C-family languages through libclang:

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

到这里会提示 "git submodule update --init --recursive"

继续

sudo git submodule update --init --recursive

提示 错误

fatal: unable to access 'https://go.googlesource.com/tools/': Failed to connect to go.googlesource.com port 443: 连接超时
fatal: 无法克隆 'https://go.googlesource.com/tools' 到子模组路径 '/home/zyj/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools'

处理:https://www.cnblogs.com/YMaster/p/11209813.html

原因 go.googlesource.com 域名国内无法直接访问,这时候根据 后面的路径  /home/zyj/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools 来知道该模块是要放这个路径下的

到 github 上找到该模块下载到该路径

cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x

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

# 继续子模块的安装
git submodule update --init --recursive

成功安装子模块。

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

Done.

-----------------------------------以下为配置-----------------------------------------

cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/

在~/.vimrc中添加

let g:ycm_server_python_interpreter='/usr/bin/python3'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'

在~/.vimrc总 call vundle#begin()  和 call vundle#end()  之间添加插件

	Plugin 'Valloric/YouCompleteMe'

莫要忘记在vim中安装插件

vim 任意文件,进入命令模式

至此自动补全功能阔以用了。

上图

--------------------------------------------------------------------------------------------------------------------------------------

使用YCM的跳转功能

在~/.vimrc中添加

    nnoremap jd :YcmCompleter GoToDefinitionElseDeclaration<CR>  
    nnoremap <F2> :YcmCompleter GoToDefinitionElseDeclaration<CR>  

“使用',j+d'组合键/F2键 完成跳转,跳转到函数或变量的声明或定义位置

跳转成功之后,可使用VIM命令ctrl+o返回光标上一个位置

配合ctags 一起使用,更舒服(函数跳转)

vimrc上传还要写50个字的概述...

参考:https://blog.csdn.net/liao20081228/article/details/80347889

------------------------------End

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值