从了解YCM以来陆陆续续安装过两次了,都是出现各种问题,因为太费时间就没有安装;由于最近需要经常在Linux下写代码,所以在昨天又尝试安装了一次,终于安装成功了;这一次首先是用 full install guide,后来一直出错就回到用脚本安装,通过full install guide也更加了解了YCM的安装。在这里记录一下安装的详细过程,以备后续再次安装可以查阅。
安装环境:宿主机-Win7 VMware虚拟机-Ubuntu 16.04.04-desktop
安装步骤主要分为:①更新VIM版本到8.x ②安装Vundle ③在Vundle中安装YouCompleteMe插件 ④安装依赖并编译YCM ⑤配置.vimrc和.ycm_extra_conf.py文件。
首先进入YCM的官网,选择相应OS,查看相关安装步骤,网站地址如下:
https://valloric.github.io/YouCompleteMe/#ubuntu-linux-x64
一、 更新VIM到8.x
由于YCM要求VIM版本至少要 Vim 7.4.1578以上,我们这里直接上VIIM8。
1、 进入Compile VIM From Source的github页面,查看说明。
2、安装依赖库,这里可能会提示有些库没有安装成功,只要sudo apt-get update更新一下再执行就好了。
sudo apt install -y libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
python3-dev ruby-dev lua5.1 liblua5.1-dev libperl-dev git
3、移除原来老版本的VIM
sudo apt remove vim vim-runtime gvim
4、下载VIM源码
git clone https://github.com/vim/vim.git
5、进入源码编译
注意原文中这句:这里比较坑
Note for Ubuntu users: You can only use Python 2 or Python 3. If you try to compile vim with both python-config-dir and python3-config-dir, YouCompleteMe will give you an error YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support, when you start VIM.
然后更改下面的的命令,把原说明中的关于python3的两行去掉,如下:
cd vim
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim80
6、make安装
cd ~/vim
sudo make install
7、把VIM设置成默认的编辑器
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alte