国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

CentOS7 Vim自動補全插件----YouCompleteMe安裝與配置

2024-06-28 13:21:27
字體:
來源:轉載
供稿:網友
CentOS7 Vim自動補全插件----YouCompleteMe安裝與配置

最近剛裝了新系統CentOS7,想要把編碼環境配置一下,使用Vim編寫程序少不了使用自動補全插件,我以前用的是neocomplcache+code_complete+omnicppcomplete。但在網上搜索時,看到了YouCompleteMe,說YCM更好用一些。個人也喜歡新鮮事物,故決定安裝YCM。但安裝過程遇到了不少坑,網上的教程有不同的安裝方法,基本都試遍了。最終在倒騰了一下午的情況下終于弄好了,現在把可行的安裝配置方法貼出來,以供需要的人參考。

YouCompleteMe:一個隨鍵而全的、支持模糊搜索的、高速補全的插件。YCM 由 google 公司搜索項目組的軟件工程師 Strahinja Val Markovic 所開發,YCM 后端調用 libclang(以獲取AST,當然還有其他語言的語義分析庫)、前端由 C++ 開發(以提升補全效 率)、外層由 python 封裝(以成為 vim 插件),它可能是我見過安裝最復雜的 vim 插件了。

要安裝YouCompleteMe ,vim須支持python。看是否支持,可以在vim中:version 查看, 如果python前有+號,就是支持,減號就是不支持。

如果不支持,需要以編譯安裝方式重新安裝vim。編譯配置選項:

./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset

一、安裝vundle插件

步驟一:

[zhupengfei@localhost ~]$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle^C

步驟二: 在.vimrc中配置

[zhupengfei@localhost ~]$ vim .vimrc

set nocompatible              " be iMPRoved, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/vundle/call vundle#rc()" alternatively, pass a path where Vundle should install plugins"let path = '~/some/path/here'"call vundle#rc(path)" let Vundle manage Vundle, requiredPlugin 'gmarik/vundle'" The following are examples of different formats supported." Keep Plugin commands between here and filetype plugin indent on." scripts on GitHub reposPlugin 'tpope/vim-fugitive'Plugin 'Lokaltog/vim-easymotion'Plugin 'tpope/vim-rails.git'" The sparkup vim script is in a subdirectory of this repo called vim." Pass the path to set the runtimepath properly.Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}" scripts from http://vim-scripts.org/vim/scripts.htmlPlugin 'L9'Plugin 'FuzzyFinder'" scripts not on GitHubPlugin 'git://git.wincent.com/command-t.git'" git repos on your local machine (i.e. when working on your own plugin)Plugin 'file:///home/gmarik/path/to/plugin'" ...filetype plugin indent on     " requiredBundle 'Valloric/YouCompleteMe'

步驟三:保存退出,打開vim,輸入 :BundleInstall 進行自動安裝。

進程如下,+號表示已經安裝,>表示正在安裝。

[zhupengfei@localhost ~]$ vim
:BundleInstall 

安裝時有個錯誤,這是正常的,因為ycm需要手動編譯出庫文件。

Done! With errors; press l to view logycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!

二、安裝配置YouCompleteMe

步驟四: 然后到.vim/bundle/YouCompleteMe 下執行命令:

./install.sh --clang-completer

參數是為了支持c/c++的補全

[zhupengfei@localhost YouCompleteMe]$ ./install.sh --clang-complete

然后可能還會出現報錯:

Some folders in /home/sky-tm/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party are empty; you probably forgot to run: git submodule update --init --recursive

若出現此錯誤,則按照提示來,繼續輸入命令:

git submodule update --init --recursive

[zhupengfei@localhost YouCompleteMe]$git submodule update --init --recursive

等此命令更新完成后,再此執行命令:

./install.sh --clang-completer

[zhupengfei@localhost YouCompleteMe]$ ./install.sh --clang-complete

安裝完成后,進行一些簡單的配置就可以使用了。

YouCompleteMe進行補全時需要查找一個ycm_global_ycm_extra_conf文件。可以每次在工作目錄中放置這個文件,也可以設置全局。全局設置要在.vimrc中添加一行即可。

注:.ycm_extra_conf.py 是個隱藏文件,路徑在~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py '

關于.vimrc的配置就不貼了,網上有很多,可以根據個人的喜好進行配置。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴和县| 泾川县| 宜君县| 家居| 临桂县| 安国市| 白河县| 横峰县| 石泉县| 武宣县| 文安县| 新乡市| 唐山市| 曲阜市| 新野县| 甘德县| 泰和县| 兰州市| 枝江市| 孙吴县| 繁昌县| 华池县| 井研县| 绍兴市| 双辽市| 鲁甸县| 罗定市| 湘潭县| 三台县| 海宁市| 齐齐哈尔市| 青州市| 章丘市| 北安市| 原平市| 丹寨县| 依安县| 太仓市| 玉山县| 岳西县| 若羌县|