解决安装YouCompleteMe与Vim版本不兼容问题

时间:2021-12-22 20:39:07

用vim 7.4.4版本装YouCompleMe的时候提示这样的信息:

YouCompleteMe unavailable: requires Vim 7.4.1578+。明明版本比它要求的还高,居然还会报错,网上搜了一下说需要升级vim到8.0版本,大都需要用到sudo命令,但是我的是在服务器上,我并没有sudo权限,所以可以考虑将vim安装在local,安装步骤如下:

I. Install the Vim 8.0 with Make

1. Install the necessary package.

$ sudo yum install gcc-c++ ncurses-devel python-devel

2. Get the source code of Vim.

$ git clone https://github.com/vim/vim.git

3. Go to build directory.

$ cd vim/src && git check v8.0.1522

Use the version like my MacVim.

4. Configure it !

$ ./configure \
--disable-nls \
--enable-cscope \
--enable-gui=no \
--enable-multibyte \
--enable-pythoninterp \
--enable-rubyinterp \
--prefix=/home/jonny/.local/vim \
--with-features=huge \
--with-python-config-dir=/usr/lib/python2.7/config \
--with-tlib=ncurses \
--without-x

注意上面的一些参数需要做对应的修改:

  • --prefix: 需要改成local user路径
  • --with-python-config-dir:我用的是anaconda,然后我的/home/anaconda3/lib/python3.7路径下并没有config文件夹,这个文件夹是用来支持YouCompleteMe插件的,所以你可以先手工创建这个文件夹即可。

5. Compile and install the Vim.

$ make && make install

6. Add ~/.local/vim/bin/ into $PATH.

$ vim ~/.bashrc
...
if [ -d "$HOME/.local/vim/bin/" ] ; then
PATH="$HOME/.local/vim/bin/:$PATH"
fi

7. Reload the bashrc.

source ~/.bashrc

8. Check Vim version

输入$ vim --version你就会看到此时vim版本变成了8.0.

II. Install the YouCompleteMe plugin

  1. Install the necessary package.
$ sudo yum install gcc-c++ cmake python-devel
  1. Get the YouCompleteMe plugin.
$ mkdir ~/.vim/bundle && git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
  1. Compile and install the YouCompleteMe.
$ cd ~/.vim/bundle/YouCompleteMe && python ./install.py

安装完YouCompleteMe之后,每次打开一个文件都会提示这样的信息

Found /Users/username/.ycm_extra_conf.py. Load?

(Question can be turned off with options, see YCM docs)
[O]k, (C)ancel

可以在.vimrc文件中添加如下命令即可关闭提示

let g:ycm_confirm_extra_conf = 0

Enjoy it.

感谢: Install the Vim 8.0 and YouCompleteMe with Make on CentOS 7.4

微信公众号:AutoML机器学习

解决安装YouCompleteMe与Vim版本不兼容问题

MARSGGBO♥原创

如有意合作或学术讨论欢迎私戳联系~
邮箱:marsggbo@foxmail.com


2018-11-29