上网搜了一下安装方法。基本上分为两种。用vundle或者下载源码安装。
记录一下手动安装方法以及安装时遇到的问题:
首先ycm对vim版本要求。7.4.143以上版本。
vim7.4 patch 143:
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
wget ftp://ftp.vim.org/pub/vim/patches/7.4/7.4.143
tar -jxvf vim-7.4.tar.bz2
cd vim74
patch -p0 < ../7.4.143 >& logfile
./configure --with-features=huge --enable-pythoninterp --enable-perlinterp --enable-rubyinterp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset --with-features=huge --enable-pythoninterp --enable-perlinterp --enable-rubyinterp --enable-luainterp --enable-multibyte --enable-sniff --enable-cscope && make && make install
其中参数说明如下:
--prefix=/usr/local/vim74:编译安装路径 默认路径为/usr/local/bin/
--with-features=huge:支持最大特性
--enable-pythoninterp:启用Vim对python编写的插件的支持
--enable-perlinterp:启用Vim对perl编写的插件的支持
--enable-rubyinterp:启用Vim对ruby编写的插件的支持
--enable-luainterp:启用Vim对lua编写的插件的支持
--enable-multibyte:多字节支持 可以在Vim中输入中文
--enable-sniff:Vim状态提示 提示Vim当前处于INSERT、NORMAL、VISUAL哪种模式
--enable-cscope:Vim对cscope支持
--enable-gui=gtk2:gtk2支持,也可以使用gnome,表示生成gvim
mv /usr/bin/vim /usr/bin/vim.old
ln -s /usr/local/bin/vim /usr/bin/vim
在ycm中有使用到这个插件。不安装这个插件编辑文件的时候会提示这里边的函数找不到。
UltiSnips:
https://github.com/SirVer/ultisnips
cp -r ultisnips/* ~/.vim
YouCompleteMe:
cd YouCompleteMe
./install.sh
如果需要支持c 或其它语言的语义补全可以使用 ./install.sh --clang-completer 需要安装clang.
c#:--omnisharp-completer
go:--gocode-completer
javascript:--tern-completer
rust:--racer-completer
或者全部 --all
cd ..
cp -r YouCompleteMe/* ~/.vim
cp YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/
vim ~/.vimrc
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'