Ubuntu15.04YouCompleteMe外掛程式安裝,youcompleteme

來源:互聯網
上載者:User

Ubuntu15.04YouCompleteMe外掛程式安裝,youcompleteme

0x00. 簡介

YouCompleteMe號稱Vim的自動補全神器,YouCompleteMe: a code-completion engine for Vim,該項目在github的地址:YouCompleteMe。

0x01. Requirements

Vim is at least 7.3.584 and it has support for python2 scripting.

0x02. 用Vundle來安裝YCM(YouCompleteMe)

安裝其實非常簡單,在.vimrc檔案中加入語句 Bundle 'Valloric/YouCompleteMe' 即可,儲存,退出,然後再次開啟Vim,normal模式下輸入 :BundleInstall 即開始下載。如:

也可以切換至 .vim/bundle 下手動下載,輸入如下命令:

git clone https://github.com/Valloric/YouCompleteMe.git

手動下載完後檢查倉庫的完整性,切換到 YouCompleteMe 目錄下,輸入如下命令:

git submodule update --init --recursive

0x03.  下載最新的libclang

Clang是一個開源的編譯器,它可以編譯C/C++/Objective-C/Objective-C++. Clang提供的libclang庫是用來給YCM為這些語言提供語義補全的引擎。和YCM配合的libclang版本必須 >=3.6 ,但理論上也是可以和 3.2+ 版本的libclang配合使用的。下載最新的libclang如下:

sudo apt-get install libclang-dev

0x04. 編譯YCM需要的ycm_support_libs庫

首先要確保你已經安裝類cmake。如果沒有,請按如下安裝:

sudo apt-get install cmake

其次需要確保你有一些 Python 標頭檔。如果沒有,請按如下安裝:

sudo apt-get install python-dev

接下來,建立新的檔案夾 ycm_build 進行編譯,如下:

1 cd ~2 mkdir ycm_build3 cd ycm_build

不需要語義補全的童鞋們,直接執行下面的語句:

cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

然並卵啊,俺們是需要語義補全的呀~,那麼請先去 llvm.org 下載最新的 clang+llvm 包,然後把它們解壓到 ~/ycm_temp/llvm_root_dir 檔案夾下。接著,執行如下語句:

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

再接著要開始編譯 ycm_support_libs 庫,執行如下語句:

make ycm_support_libs

這樣就編譯完了。

0x05. 配置YCM

本渣開始以為編譯完了就完事了,誰知道再次開啟Vim,它來了這麼一句:No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++. 哦呵呵呵~

進 ~/.vim/bundle/YouCompleteMe 檔案夾下一看。。。沒有 cpp !沒有 cpp !沒有 cpp !

咋辦?建立唄。。。然後把 YCM‘S own .ycm_extra_conf.py 檔案拷貝到相應的檔案夾下。

接著再次開啟 .vimrc 配置YCM,如下:

"YouCompleteMelet g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

之後再次開啟Vim即可。

為了補全,我們還需要在 .ycm_extra_conf.py 檔案中進行配置,如下:

1 '-isystem',2 '/usr/include',3 '-isystem',4 '/usr/include/c++/4.9.2',5 '-isystem',6 '/usr/include',7 '/usr/include/x86_64-linux-gnu/c++',

0x06. Summary

城裡人真會玩:)

自己再配置配置可以起飛了~

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.