推荐文章:https://vimjc.com/vim-youcompleteme-install.html
1、版本支持:
在 Linux 终端输入 vim --version 可查看当前 Vim 的版本和编译信息
vim --version
2、安装依赖软件和库
sudo apt-get install build-essential cmake python-dev python3-dev
3、下载 YouCompleteMe 源码
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/plugged/
获取 YouCompleteMe 的相关依赖 :
git submodule update --init --recursive
4、编译 YouCompleteMe
./install.py --clang-completer
5、配置~/.vimrc
~/.vimrc然后增加如下的语句(如果没有此文件,新建一个或者复制/usr/share/vim/vim81/vimrc_example.vim
.vimrc的引用逻辑为先从用户文件中寻找,如果没有的话再寻找usr文件夹。
Plugin ‘VundleVim/YouCompleteMe’
问题一:Linux Git could not resolve proxy:http
step1: Git 有自己的代理,重置一下 Git 的代理。
git config --global https.proxy ""
git config --global http.proxy ""
step2: 重置系统的代理:
export http_proxy=""
export https_proxy=""
export all_proxy=""
问题二:CMake Error at ycm/CMakeLists.txt:107 (file):
file DOWNLOAD HASH mismatch:第四布时出现问题。原因在于没有下载clang相关文件,从提示中推荐的网址,下载在~/.vim/plugged/中,再执行第四步即可。
CMake Error at ycm/CMakeLists.txt:123 (message):
Cannot find path to libclang in prebuilt binaries
-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build_magkgtwt/CMakeFiles/CMakeOutput.log".
See also "/tmp/ycm_build_magkgtwt/CMakeFiles/CMakeError.log".
ERROR: the build failed.
NOTE: it is *highly* unlikely that this is a bug but rather
that this is a problem with the configuration of your system
or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the
issue tracker, including the entire output of this script
and the invocation line used to run it.
问题三:打开Vim时出现“NoExtraConfDetected: No .ycm_extra_conf.py file detected”
step1:
打开~/.vimrc,加上此行
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
step2:
从官网下载.ycm_extra_conf.py文件并移动到/.ycm_extra_conf.py
官网网址:https://github.com/penincillin/vim/blob/master/ycm_extra_conf.py