歡迎轉載,轉載請注明出處,http://blog.csdn.net/up2wing。
1、編譯vim ycm需要python支援,而預設的vim是不帶python支援的。可以在vim中輸入指令
:version
檢視是否有“+python”。如果是“-python”,則沒有帶python支援,需要重新編譯。編譯步驟比較簡單,從vim官網下載下傳src包,進入到src目錄。先執行下 ./configure --help 看下有哪些選項:
[[email protected] src]# ./configure --help |grep python
--enable-pythoninterp=OPTS Include Python interpreter. default=no OPTS=no/yes/dynamic
--enable-python3interp=OPTS Include Python3 interpreter. default=no OPTS=no/yes/dynamic
--with-python-config-dir=PATH Python's config directory
--with-python3-config-dir=PATH Python's config directory
是以我們執行
./configure --with-features=huge --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.6/config/ --prefix=/usr
make install -j4
安裝後再次檢查是否成功,可以檢查configure日志:src/auto/config.log,對症解決。如果python configure有問題的 話,檢查 python-dev是否安裝。可嘗試重新安裝python。 編譯安裝成功後,注意預設安裝目錄為/usr/local/bin/vim,需要拷貝覆寫/usr/bin/vim。 2、安裝YouCompleteMe ycm需要先在vim插件管理vundle工具中加入,vimrc配置檔案可參考 https://github.com/up2wing/fox-vim, 然後編譯才能使用。否則會有錯誤提示:
[[email protected] ~]# vim
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!
2.1 自動安裝 支援c語言,按照下面,ycm會自動下載下傳并安裝:
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
2.2 手動安裝 首先要下載下傳libclang.so,官網位址: http://llvm.org/releases/。YCM是基于libclang3.5或以上版本設計的,但理論上3.2+也可以。下載下傳後解壓。 接下來編譯YCM需要的ycm_support_libs。需要cmake産生Makefile,若無需先安裝cmake。然後建立編譯目錄,開始編譯ycm_support_libs。
cd ~
mkdir ycm_build
cd ycm_build
如果不需要c語言的語義支援,執行下面就可以:
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
如果需要c語言語義支援,将下面解壓的LLVM+Clang目錄下面的内容拷貝到~/ycm_temp/llvm_root_dir(with bin, lib,include etc.),然後執行:
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
執行上面的這句可能會失敗,需要更新下代碼目錄,因為ycm需要一些第三方作為子子產品:
git submodule update --init --recursive
到此,準備工作終于做好了,make産生ycm_support_libs:
make ycm_support_libs
reference: 1、 http://www.bkjia.com/ASPjc/817543.html 2、 https://github.com/Valloric/YouCompleteMe