按照網上的教程安裝該軟件,沒有一篇是成功的(也有多是沒找對)。本身從網上東拼西湊的,終於讓本身的vim智能識別了。python
1. 升級 vim: (ubuntu)linux
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
5. 編譯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
" YouCompleteMeapt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-devycm_core庫
mkdir 123 && cd 123
cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
或者
set runtimepath+=~/.vim/bundle/YouCompleteMe let g:ycm_collect_identifiers_from_tags_files = 1 " 開啓 YCM 基於標籤引擎 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 註釋與字符串中的內容也用於補全 let g:syntastic_ignore_files=[".*\.py$"] let g:ycm_seed_identifiers_with_syntax = 1 " 語法關鍵字補全 let g:ycm_complete_in_comments = 1 let g:ycm_confirm_extra_conf = 0 let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按鍵, 沒有這個會攔截掉tab, 致使其餘插件的tab不能用. let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>'] let g:ycm_complete_in_comments = 1 " 在註釋輸入中也能補全 let g:ycm_complete_in_strings = 1 " 在字符串輸入中也能補全 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 註釋和字符串中的文字也會被收入補全 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' let g:ycm_show_diagnostics_ui = 0 " 禁用語法檢查 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回車即選中當前項 nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳轉到定義處 "let g:ycm_min_num_of_chars_for_completion=2 " 從第2個鍵入字符就開始羅列匹配項
顯示結果:
![](http://static.javashuo.com/static/loading.gif)