尝试不用编译源码的方式安装YCM,注意:YCM是以编译方式安装的,这里说的不用编译源码指的是不用编译YCM所需的库文件,如ycm_support_libs
一、通过Vundle安装YCM
1、安装Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
2、配置~/.vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
call vundle#end()
Bundle 'Valloric/YouCompleteMe'
filetype plugin indent on
然后在命令行模式下输入
:PluginInstall
注意标明的插件只是举例,并不是所有都需要,可根据自身情况安装,接着执行
:BundleInstall
在安装完YoucompleteMe之后,如果提示YoucompleteMe unavailable requires vim compiled with python 2.x support
执行下面命令
apt-get install vim-nox
之后打开vim会出现:
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!
这是正常提示,因为还需接着编译安装
两种安装插件的方法目前还没有具体比较过。
安装完YoucompleteMe以后,首先需要做配置可参考配置YCM
然后安装:
apt-get install libclang-dev
然后执行
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --system-libclang
这个过程中会自动安装clang,并且也会安装系统clang以防出现兼容问题,安装完成后会在~/.vim/bundle/YouCompleteMe/third_party/ycmd/下生成libclang.so、ycm_client_support.so、ycm_core.so等,之后的操作参考博文
在Debian中,.ycm_extra_conf.py在 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm 下,将其复制到当前用户的根目录下。 之后YouCompleteMe就可以正常使用了,
Trouble Shooting
安装YCM的过程中最大的坑就是They ycmd server shut down (restart with:YcmRestartServer) stderr( last 30 lines).解决方法是在.vimrc中输入
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'
然后执行
:YcmToggleLogs stderr
查看错误日志,最终看到是 ~/.ycm.extra.conf.py文件中的缩进有问题,因为之前是自己手动编辑的,而不是将生成的~/.ycm.extra.conf.py复制到用户根目录下