按照网上的教程安装该软件,没有一篇是成功的(也有可能是没找对)。自己从网上东拼西凑的,终于让自己的vim智能识别了。
1. 升级 vim: (ubuntu)
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
2. 安装vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
3.下载ycm
cd ~/.vim/
git clone --recursive https://github.com/Valloric/YouCompleteMe.git
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive
4. 安装libclang
apt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev
5. 编译ycm_core库
mkdir 123 && cd 123
cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
或者
cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DEXTERNAL_LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/libclang-3.9.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp #未验证
cmake --build . --target ycm_core --config Release
6. 配置
#perl警告处理
echo "export LC_ALL=C" >> /root/.bashrc
source /root/.bashrc
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/
配置vimrc
"~/.vimrc
let g:ycm_server_python_interpreter=‘/usr/bin/python2.7‘ " 当时编译python的版本
let g:ycm_global_ycm_extra_conf=‘~/.vim/.ycm_extra_conf.py‘
set nocompatible " be iMproved
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"let Vundle manage Vundle
" required!
Bundle ‘scrooloose/syntastic‘
Bundle ‘gmarik/vundle‘
" My bundles here:
"
" original repos on GitHub
Bundle ‘tpope/vim-fugitive‘
Bundle ‘Lokaltog/vim-easymotion‘
Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}
Bundle ‘tpope/vim-rails.git‘
" vim-scripts repos
Bundle ‘L9‘
Bundle ‘FuzzyFinder‘
" non-GitHub repos
Bundle ‘git://git.wincent.com/command-t.git‘
" Git repos on your local machine (i.e. when working on your own plugin)
Bundle ‘file:///Users/gmarik/path/to/plugin‘
" ...
Bundle ‘Valloric/YouCompleteMe‘
filetype plugin indent on " required!
" 编码为utf-8
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set encoding=utf-8
显示结果: