网上关于VIM编辑器补齐插件YouCompleteMe安装文档都是不完整的;YouCompleteMe也是VIM安装过程最复杂的插件。
安装过程请仔细阅读官方文档,不要相信网文。
最小化安装操作系统CentOS7.6
1.配置YUM源:
cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.6.1810/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.6.1810/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.6.1810/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
ISO源
cat CentOS-Media.repo
[c7-media]
name=CentOS-$releasever - Media
baseurl=ftp://192.168.150.222/iso/centos76
gpgcheck=0
enabled=1
2.安装python3.6.15
#要求python>=3.6
yum install -y bzip2-devel ncurses-devel gdbm-devel openssl-devel readline-devel zlib-devel sqlite-devel tk-devel xz-devel gcc readline.i686 libffi-devel gcc-c++
cd Python-3.6.15
./configure --prefix=/usr/local/python36 --enable-optimizations --enable-shared
make
make install
修改YUM依赖python2的配置:
vi /usr/bin/yum
第一行:
#!/usr/bin/python ====》#!/usr/bin/python2
vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python ====》#!/usr/bin/python2
rm -f /usr/bin/python
ln -s /usr/local/python36/bin/python3 /usr/bin/python
echo "/usr/local/python36/lib">>/etc/ld.so.conf.d/python3.conf
ldconfig
3.安装devtoolset-8以上的g++支持包:
yum install centos-release-scl
yum install devtoolset-10
scl enable devtoolset-10 bash # 只在当前窗口有效
4.安装VIM8
如果已有VIM命令,需要进行卸载:
yum remove -y vim-minimal
cp -r /usr/local/python36/lib/python3.6 /usr/lib64
tar -xvf vim-8.2.4412.tar.gz
cd ~/vim-8.2.4412
./configure --with-features=huge \
--enable-multibyte \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib64/python2.7/config \
--with-python3-command=python2 \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu \
--prefix=/usr/local/vim8 \
--with-python3-command=python3 \
--enable-cscope \
--enable-fontset
make && make install
配置VIM环境变量:
PATH=$PATH:$HOME/bin ====> PATH=$PATH:$HOME/bin:/usr/local/vim8/bin
#添加别名:
alias vi='/usr/local/vim8/bin/vim'
source ~/.bash_profile
5.安装 git
yum -y install git
6.安装vim插件管理器
官网:
https://github.com/VundleVim/Vundle.vim
cd ~/.vim/bundle/
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.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
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
安装完成后。输入:
vim
:PluginInstall
回车自动安装插件
7.安装cmake-3.22.2.tar.gz
官方下载地址:
https://cmake.org/download/
cd ~
tar -xvf cmake-3.22.2.tar.gz
cd cmake-3.22.2
./bootstrap --system-curl
gmake -j4
gmake install
8.安装自动补齐插件YouCompleteMe
YouCompleteMe官网:
https://github.com/ycm-core/YouCompleteMe
git clone https://github.com/ycm-core/YouCompleteMe.git
git submodule update --init --recursive
9.安装go
下载
https://golang.google.cn/dl/
解压:
cd ~
tar -xvf go1.17.3.linux-amd64.tar.gz
mv go /usr/local
配置环境变量:
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/vim8/bin ====>PATH=$PATH:$HOME/bin:/usr/local/vim8/bin:/usr/local/go/bin
添加GO环境变量
export GOROOT=/usr/local/go
export GOPATH=/root/go
export GOBIN=/root/go
设置go环境变量,模块包下载地下改为国内源:
Go 1.13 及以上(推荐)
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
安装go的gopls
go install golang.org/x/tools/gopls@latest
10.这里仅安装YouCompleteMe中关于go语言的补齐插件
文件.vimrc添加:
Plugin 'fatih/vim-go'
:PluginInstall
:q
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --go-completer
最后修改时间:2022-02-21 09:55:00
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




