解決安裝YouCompleteMe與Vim版本不兼容問題


用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機器學習
MARSGGBO原創
如有意合作或學術討論歡迎私戳聯系~
郵箱:marsggbo@foxmail.com

2018-11-29




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM