【轉】ubuntu 12.04 下 Vim 外掛程式 YouCompleteMe 的安裝

來源:互聯網
上載者:User

標籤:

原文網址:http://www.cnblogs.com/jostree/p/4137402.html

jostree 轉載請註明出處 http://www.cnblogs.com/jostree/p/4137402.html

1.需要保證vim的版本大於7.3.584,否則的話需要更新vim

可以通過第三方源更新:

在終端輸入下面的代碼:

$ sudo add-apt-repository ppa:fcwu-tw/ppa$ sudo apt-get update$ sudo apt-get install vim

升級得到vim7.4

 

2.需要有clang3.2以上的庫

可以再此處下載:http://llvm.org/releases/download.html

可以下載已經變編譯好的clang3.4,並注意作業系統版本

 

3.安裝vundle外掛程式

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

並配置.vimrc

set nocompatible "與vi不一致filetype offset rtp+=~/.vim/bundle/vundle/ "載入特定目錄外掛程式"set rtp+=$HOME/.vim/bundle/vundle/ "Windows下call vundle#rc()"plugin "vimscripts帳號下的項目直接填寫名稱即可Bundle ‘snipMate‘"其它需填寫使用者/資源名稱Bundle ‘gmarik/vundle‘"非github上資源Bundle ‘git://git.wincent.com/command-t.git‘"indentBundle ‘php.vim-html-enhanced‘"colorBundle ‘Lucius‘filetype plugin indent on  

 

4.利用vundle外掛程式安裝YouCompleteMe和syntastic外掛程式:

在.vimrc中添加

Bundle ‘https://github.com/Valloric/YouCompleteMe.git‘Bundle ‘https://github.com/scrooloose/syntastic.git‘

然後在vim中執行:Vundle Install!

即可安裝好這兩個外掛程式,安裝YouCompleteMe的過程很漫長

可以直接在~/.vim/bundle/目錄下,執行:

sudo git clone https://github.com/Valloric/YouCompleteMe.gitsudo git submodule update --init --recursive

也可以得到同樣的效果。其中第二行是遞迴的更新子檔案夾的內容。

 

5.編譯YouCompleteMe外掛程式

首先需要安裝CMAKE

sudo apt-get install cmake

 

然後在家目錄下建立一個ycm_build檔案夾

cd ~mkdir ycm_buildcd ycm_build

然後cmke使用cmake命令產生makefile檔案:

cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

此處需要注意的是需要修改DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir,令其等於clang3.4的路徑。

然後make編譯

make ycm_support_libs

即可產生編譯後的庫檔案。

最後回到YouCompleteMe目錄下:

執行

cd ~/.vim/bundle/YouCompleteMe./install.sh --clang-completer --system-clang 

即可完成。

6.配置自動補全python指令碼:

在~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/路徑下的.ycm_extra_conf.py檔案中

刪除.ycm_extra_conf.py中的

# NOTE: This is just for YouCompleteMe; it‘s highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU‘RE NOT 100% YOU NEED IT.
try:
final_flags.remove( ‘-stdlib=libc++‘ )
except ValueError:
pass

將之刪除後YCM才會補全c++標準庫的內容。

並添加

‘/usr/include‘,
‘-isystem‘,
‘/usr/include/c++/‘

到flags列表中使其可以補C++庫中的標頭檔。

7.最終更改~/.vimrc的設定檔:

set nocompatible               " be iMprovedfiletype off                   " required! set rtp+=~/.vim/bundle/vundle/call vundle#rc() " let Vundle manage Vundle" required! Bundle ‘gmarik/vundle‘ " My Bundles here:"" original repos on githubBundle ‘tpope/vim-fugitive‘Bundle ‘Lokaltog/vim-easymotion‘Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}Bundle ‘tpope/vim-rails.git‘" vim-scripts reposBundle ‘L9‘Bundle ‘FuzzyFinder‘" non github reposBundle ‘git://git.wincent.com/command-t.git‘" My pluginBundle ‘perl-support.vim‘Bundle ‘ctags.vim‘Bundle ‘taglist.vim‘Bundle ‘https://github.com/Lokaltog/vim-powerline.git‘Bundle ‘LaTeX-Suite-aka-Vim-LaTeX‘Bundle ‘Simple-R-Omni-Completion‘"Bundle ‘Pydiction‘Bundle ‘The-NERD-tree‘Bundle ‘Tagbar‘Bundle ‘asins/vimcdoc‘Bundle ‘cpp.vim‘Bundle ‘c.vim‘Bundle ‘code_complete‘Bundle ‘autoproto.vim‘Bundle ‘a.vim‘Bundle ‘pyflakes.vim‘Bundle ‘Conque-Shell‘Bundle ‘python.vim‘Bundle ‘multvals.vim‘Bundle ‘gdbvim‘Bundle ‘glib.vim‘Bundle ‘VimIM‘Bundle ‘OmniCppComplete‘Bundle ‘echofunc.vim‘"Bundle ‘clang-complete‘"Bundle ‘pythoncomplete‘Bundle ‘minibufexpl.vim‘Bundle ‘https://github.com/Valloric/YouCompleteMe.git‘Bundle ‘https://github.com/scrooloose/syntastic.git‘"Bundle ‘https://github.com/Valloric/ListToggle.git‘"Bundle ‘Valloric/YouCompleteMe‘"Bundle ‘qiushibaike‘filetype plugin indent on     " required!"" Brief help  -- 此處後面都是vundle的使用命令" :BundleList          - list configured bundles" :BundleInstall(!)    - install(update) bundles" :BundleSearch(!) foo - search(or refresh cache first) for foo" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles"" see :h vundle for more details or wiki for FAQ" NOTE: comments after Bundle command are not allowed..""set nocompatible  "去掉討厭的有關vi一致性模式,避免以前版本的一些bug和局限  set showmatchset matchtime=1set autowriteset ruler                   " 開啟狀態列尺規set cursorline              " 反白當前行nnoremap <F2> :g/^\s*$/d<CR>  set laststatus=1     "啟動顯示狀態行(1),總是顯示狀態行(2)  set foldenable      " 允許摺疊  "set foldmethod=indent   " 手動摺疊  set nuset fileencodings=utf-8,ucd-bom,gb18030,gbk,gb2312,cp936set tabstop=4set sts=4set expandtab set softtabstop=4set shiftwidth=4set autoindentset cindentset cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1scolorscheme desertset nobackupset textwidth=100map <F5> :! /usr/bin/python %map <F6> :call CompileRunGpp()<CR>""""""""""syntastic""""""""""""let g:syntastic_check_on_open = 1let g:syntastic_cpp_include_dirs = [‘/usr/include/‘]let g:syntastic_cpp_remove_include_errors = 1let g:syntastic_cpp_check_header = 1let g:syntastic_cpp_compiler = ‘clang++‘let g:syntastic_cpp_compiler_options = ‘-std=c++11 -stdlib=libstdc++‘"set error or warning signslet g:syntastic_error_symbol = "?"let g:syntastic_warning_symbol = "?" "whether to show balloonslet g:syntastic_enable_balloons = 1let g:syntastic_always_populate_loc_list = 1nnoremap <silent> <C-d> :lclose<CR>:bdelete<CR>cabbrev <silent> bd lclose\|bdelete""""""""""""YCM""""""""""""""""""""let g:ycm_global_ycm_extra_conf = ‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘let g:ycm_collect_identifiers_from_tags_files = 1let g:ycm_seed_identifiers_with_syntax = 1let g:ycm_confirm_extra_conf = 0let g:ycm_always_populate_location_list = 1let g:ycm_min_num_of_chars_for_completion = 2let g:ycm_complete_in_comments = 1nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>nnoremap <leader>lo :lopen<CR>"minibufexpl"{let g:miniBufExplMapCTabSwitchBufs = 1let g:miniBufExplMapWindowNavVim = 1"}""pydiction"{"filetype plugin on"let g:pydiction_location=‘~/.vim/bundle/Pydiction/complete-dict‘"}"" OmniCppComplete"" {" "-- omnicppcomplete setting --"    " 按下F3自動補全代碼,注意該映射語句後不能有其他字元,包括tab;否則按下F3會自動補全一些亂碼"    imap <F3> <C-X><C-O>"    " 按下F2根據標頭檔內關鍵字補全"    imap <F2> <C-X><C-I>   " set completeopt=menu,menuone " 關掉智能補全時的預覽視窗"    let OmniCpp_MayCompleteDot = 1 " autocomplete with ."    let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->"    let OmniCpp_MayCompleteScope = 1 " autocomplete with ::"    let OmniCpp_SelectFirstItem = 2 " select first item (but don‘t insert)"    let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files"    let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window"    let OmniCpp_GlobalScopeSearch=1 " enable the global scope search"    let OmniCpp_DisplayMode=1 " Class scope completion mode: always show all members    "let OmniCpp_DefaultNamespaces=["std"]"    let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column"    let OmniCpp_ShowAccess=1 "    set tags+=/usr/include/c++/tags  "need to  ctags -R --c++-kinds=+p --fields=+iaS --extra=+q" }" echofunc.vim" {" }"vimIM"{let g:vimim_cloud=‘sogou‘let g:vimim_map=‘tab_as_onekey‘let g:vimim_map=‘no-gi‘let g:vimim_map_extra=‘ctrl_h_as_ctrl_bslash‘"let g:vimim_static_input_style=1let g:vimim_toggle = ‘pinyin,sogou,baidu‘ let g:vimim_plugin = ‘/home/liuyi/.vim/bundle/VimIM/plugin‘  "}""" Bundle ‘clang-complete‘"" {"let g:clang_auto_select = 1"let g:clang_complete_copen=1"let g:clang_periodic_quickfix=1"let g:clang_snippets=1"let g:clang_snippets_engine = ‘clang_complete‘"let g:clang_close_preview=1"let g:clang_use_library=1"let g:clang_user_options=‘-stdlib=libc++ -std=c++11 -IIncludePath‘"let g:neocomplcache_enable_at_startup = 1"" }"pyflakes python文法分析"{"filetype plugin indent on"}"python_complete"{set ofu=syntaxcompleteautocmd FileType python set omnifunc=pythoncomplete"autocmd FileType python runtime! autoload/pythoncomplete.vim"}""tagbar"{"nmap <Leader>tb :TagbarToggle<CR>map <F8> :TagbarToggle<CR>imap <F8> <ESC>:NERDTreeToggle<CR>let g:tagbar_ctags_bin=‘/usr/bin/ctags‘let g:tagbar_width=30autocmd BufReadPost *.cpp, *.c, *.h, *.hpp, *.cc, *.cxx call tagbar#autoopen()"}"omni-completion"{"autocmd FileType python set omnifunc=pythoncomplete#Complete "let g:pydiction_location=‘~/.vim/bundle/Pydiction/complete-dict‘  filetype plugin on"}"taglist"{let Tlist_Auto_Highlight_Tag=1 "let Tlist_Auto_Open=1 let Tlist_Auto_Update=1 let Tlist_Display_Tag_Scope=1 let Tlist_Exit_OnlyWindow=1 let Tlist_Enable_Dold_Column=1 "let Tlist_File_Fold_Auto_Close=1 let Tlist_Show_One_File=1 let Tlist_Use_Right_Window=1 let Tlist_Use_SingleClick=1 "nnoremap <Leader>tl :TlistToggle<CR>  "設定F8為taglist開關"}"Nerd-tree"{map <F7> :NERDTreeToggle<CR>imap <F7> <ESC>:NERDTreeToggle<CR>"}"WinManager"{let g:winManagerWindowLayout=‘FileExplorer|BufExplorer‘  " 這裡可以設定 為多個視窗,  如‘FileExplorer|BufExplorer|TagList‘let g:persistentBehaviour=0             " 只剩一個視窗時,  退出vim.let g:winManagerWidth=20let g:defaultExplorer=1nmap <leader>fir :FirstExplorerWindow<cr>nmap <leader>bot :BottomExplorerWindow<cr>nmap <leader>wm :WMToggle<cr>"}"runtime! ftplugin/man.vimset hlsearchset autoindent                  " copy indent from current lineset autoread                    " read open files again when changed outside Vimset autowrite                   " write a modified buffer on each :next , ...set backspace=indent,eol,start  " backspacing over everything in insert mode"set backup                      " keep a backup fileset browsedir=current           " which directory to use for the file browserset complete+=k                 " scan the files given with the ‘dictionary‘ optionset history=50                  " keep 50 lines of command line historyset hlsearch                    " highlightthe last used search patternset incsearch                   " do incremental searchingset listchars=tab:>.,eol:\$     " strings to use in ‘list‘ modeset mouse=a                     " enable the use of the mouseset wrap                      "   wrap linesset popt=left:8pc,right:3pc     " print optionsset ruler                       " show the cursor position all the time"set shiftwidth=2                " number of spaces to use for each step of indentset showcmd                     " display incomplete commandsset smartindent                 " smart autoindenting when starting a new line"set tabstop=2                   " number of spaces that a <Tab> counts forset visualbell                  " visual bell instead of beepingset wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensionsset wildmenu                    " command-line completion in an enhanced modeset formatoptions=tcrqn""-------------------------------------------------------------------------------"  highlight paired brackets"-------------------------------------------------------------------------------highlight MatchParen ctermbg=blue guibg=lightyellowinoremap  ,  ,<Space>""-------------------------------------------------------------------------------" autocomplete parenthesis, (brackets) and braces"-------------------------------------------------------------------------------inoremap  (  ()<Left>inoremap  [  []<Left>inoremap  {  {}<Left>"vnoremap  (  s()<Esc>P<Right>%vnoremap  [  s[]<Esc>P<Right>%vnoremap  {  s{}<Esc>P<Right>%"" surround content with additional spaces"vnoremap  )  s(  )<Esc><Left>P<Right><Right>%vnoremap  ]  s[  ]<Esc><Left>P<Right><Right>%vnoremap  }  s{  }<Esc><Left>P<Right><Right>%set vb t_vb="" vim-powerlineset laststatus=2set t_Co=256let g:Powerline_symbols = ‘unicode‘set encoding=utf8"vimcdoc"{set helplang=cn"}"shift tab page"{ map <S-Left> :tabp<CR> map <S-Right> :tabn<CR>"}

 

【轉】ubuntu 12.04 下 Vim 外掛程式 YouCompleteMe 的安裝

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.