个性化阅读
专注于IT技术分析

超简单!Linux VIM自动补全YouCompleteMe使用Vundle快速安装

你看过的YouCompleteMe安装教程是不是都是特别复杂的?漫长而复杂的编译过程,各种依赖源码编译安装,踩雷无数,问题不是过程复杂,而是往往都不大可行,搞得头都大了,不过这个VIM自动补全神器还是不能放弃的,下面我们一起来看一种使用Vundle更简单的安装方法,本人已在Ubuntu上安装成功,若你在安装过程中有任何问题,欢迎在评论中留言留下你的问题。

一、YouCompleteMe安装成功使用效果

下面是一个C语言的自动补全效果,YouCompleteMe同时支持C#,GO,Java,JavaScript,Rust的自动补全。

YouCompleteMe自动补全实例

二、安装配置Vundle

Vundle是Vim Bundle的简写,它是一个Vim插件管理器。

1、安装Vundle:

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

2、配置插件

cd ~
vim .vimrc

将下面的内容添加到.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
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

Plugin 'Valloric/YouCompleteMe'

" 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

:wq保存

vim .vimrc重新打开,输入:PluginInstall安装插件,结果如下图,若有错误底部会有提示,退出使用:q。

Vundle安装YouCompleteMe插件

如果Vim版本不够新安装会提示出错,更新方案如下:

sudo add-apt-repository ppa:jonathonf/vim 
sudo apt update 
sudo apt install vim 
sudo add-apt-repository ppa:jonathonf/vim 
sudo apt-get update && sudo apt-get upgrade

更新过程时间会相对长,耐心更新,一般这步没什么问题的。

更新完成后,vim .vimrc重新打开,输入:PluginInstall安装插件,等待一会,结果如上图表示已安装成功。

三、安装开发工具、CMake和Python头

sudo apt install build-essential cmake3 python3-dev python-dev

安装C语言语义补全支持:

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

C#支持,添加参数 –cs-completer

Java支持,添加参数:–java-completer

GO支持,添加参数:–go-completer

JavaScript和TypeScript支持,添加参数:–ts-completer

Rust支持:–rust-completer

到此成功安装YouCompleteMe!

赞(0)
未经允许不得转载:srcmini » 超简单!Linux VIM自动补全YouCompleteMe使用Vundle快速安装

评论 抢沙发

评论前必须登录!