ubuntu14.04.2安裝 YouCompleteme

c3tc3tc3t發表於2015-07-09

1 安裝git ,按照這篇文章安裝

http://www.cnblogs.com/or2-/p/4350252.html

2 安裝編譯需要的各種包

sudo apt-get install build-essential cmake
sudo apt-get install clang
sudo apt-get install python-dev

3 安裝vim ,使用國內阿狸雲倉庫的vim就可以

sudo apt-get install vim
也可以安裝上vim-gnome
sudo apt-get install vim-gnome

4 在你的使用者家目錄裡新建 .vimrc檔案
例如

~  ls .vimrc 
.vimrc

5 在.vimrc檔案中加入vundle元件管理外掛,

set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'

Plugin 'tpope/vim-fugitive'
Plugin 'L9'
Plugin 'git://git.wincent.com/command-t.git'
Plugin 'Valloric/YouCompleteMe'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'user/L9', {'name': 'newL9'}

call vundle#end()            " required
filetype plugin indent on    " required

6 儲存退出

7 開啟gvim 或者vim 試圖模式執行PluginInstall,等待下載好YouCompleteMe

8 去下載目錄

cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer  //只是編譯安裝支援c/c++語法補全

9編譯安裝後,需要在.vimrc中新增配置,.ycm_extra_conf.py是一個隱藏檔案

let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
set completeopt=longest,menu 
autocmd InsertLeave * if pumvisible() == 0|pclose|endif


let g:ycm_collect_identifiers_from_tags_files=1 
let g:ycm_min_num_of_chars_for_completion=2 
"禁止快取匹配項,每次都重新生成匹配項
let g:ycm_cache_omnifunc=0  
let g:ycm_seed_identifiers_with_syntax=1    
let g:ycm_confirm_extra_conf = 0
"允許在字串裡補全(雙引號)
let g:ycm_complete_in_strings = 1
" 在註釋輸入中也能補全
let g:ycm_complete_in_comments = 1
"自動補全快捷鍵
let g:ycm_key_invoke_completion = '<S-Space>'
"補全之後自動關閉preview
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_key_list_select_completion = ['<Down>']
inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>" 
" YCM 補全選單配色
highlight Pmenu ctermfg=2 ctermbg=3 guifg=SeaGreen guibg=blue
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=SeaGreen guibg=yellow

 

相關文章