YouCompleteMe安装教程

按着官网和其他大佬的教程走了一回。安装确实很复杂,但,总的来说,实现linux爬梯子后很顺畅。

对了,YCM是什么?是一款针对vim的自动补全的插件,非常牛逼,堪比vs的自动补全。用tab和shift tab即可自动联想。

话不多说。

prerequisite

首先要确保vim版本大于8.1,并且vim能支持python 3(3.6以上),可以输入vim --version检查

安装vundle

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

然后打开.vimrc(vim ~/.vimrc),粘贴如下:(vim教程就不教了哈,最简单直接i,然后粘贴,然后Escape,然后:wq,就好了)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
Plugin 'file:///home/gmarik/path/to/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'}

" 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

最后运行

1
vim +PluginInstall +qall

安装 CMake, Vim and Python

1
apt install build-essential cmake vim-nox python3-dev

安装 mono-complete, go, node, java and npm

1
apt install mono-complete golang nodejs default-jdk npm

下载源码,获取相关依赖

1
2
3
4
5
6
7
# 这两步因为网速会非常慢,建议先实现科学上网
# 获取源码
git clone https://github.com/ycm-core/YouCompleteMe ~/.vim/bundle/YouCompleteMe

# 解决相关依赖
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive

安装

1
~/.vim/bundle/YouCompleteMe$ python3 install.py --clangd-completer # 对c/cpp自动补全,可以改成--all,支持所有语言

差不多好了!~


YouCompleteMe安装教程
http://baokker.github.io/2022/02/12/YouCompleteMe安装教程/
作者
Baokker
发布于
2022年2月12日
更新于
2022年5月29日
许可协议