Linux系统Vim编辑器如何安装YouCompleteMe插件?
编译配置选项:
/configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset
在我的机器上装有python2.7.5 和 python3.3, 但加了enable-python3interp参数依然没有支持py3,不知何故,先不管,youcompleteme 只要求有py2.6以上。
安装vundle插件
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
在.vimrc中配置
set nocompatible “ be improved, required
filetype off ” required
“ set the runtime path to include vundle and initialize
set 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, required
plugin ‘gmarik/vundle’
” the following are examples of different formats supported.
“ keep plugin commands between here and filetype plugin indent on.
” scripts on github repos
plugin ‘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.html
plugin ‘l9’
plugin ‘fuzzyfinder’
” scripts not on github
plugin ‘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 “ required
bundle ‘valloric/youcompleteme’
保存退出,打开vim,输入 :bundleinstall 进行自动安装
进程如下,+号表示已经安装,》表示正在安装
。 plugin ‘gmarik/vundle’ |~
+ plugin ‘tpope/vim-fugitive’ |~
+ plugin ‘lokaltog/vim-easymotion’ |~
+ plugin ‘tpope/vim-rails.git’ |~
+ plugin ‘rstacruz/sparkup’ |~
+ plugin ‘l9’ |~
+ plugin ‘fuzzyfinder’ |~
》 plugin ‘git://git.wincent.com/command-|~
t.git’ |~
plugin ‘file:///home/gmarik/path/to/pl|~
ugin’ |~
plugin ‘valloric/youcompleteme’ |~
helptags
备注:结束时有个错误,这是正常的,因为ycm需要手工编译出库文件
done! with errors; press l to view log
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!
到 .vim/bundle/youcompleteme 下
/install.sh --clang-completer
参数是为了支持c/c++ 的补全。
安装完成后,进行一些简单的配置就可以使用。
youcompleteme 的补全配置文件在/bundle/youcompleteme/cpp/ycm/.ycm_extra_conf.py,这是个隐藏文件。
默认会使用这个文件,也可以把这个文件copy到工程的根目录中作修改,打开工程文件时会优先使用当前目录下的配置文件。
如果找不到,会根据配置中的ycm_global_ycm_extra_conf 进行查找。
在.vimrc 中添加
let mapleader = ”,“ ” 这个leader就映射为逗号“,”
let g:ycm_global_ycm_extra_conf = ‘~/.vim/bundle/youcompleteme/cpp/ycm/.ycm_extra_conf.py’ “配置默认的ycm_extra_conf.py
nnoremap 《leader》jd :ycmcompleter gotodefinitionelsedeclaration《cr》 “按,jd 会跳转到定义
let g:ycm_confirm_extra_conf=0 “打开vim时不再询问是否加载ycm_extra_conf.py配置
let g:ycm_collect_identifiers_from_tag_files = 1 “使用ctags生成的tags文件
以上就是linux给vim安装youcompleteme插件的方法了,youcompleteme插件号称vim自动补全神器,这个插件对vim来说相当重要。
上一篇: 小米10劲敌 红魔5G GeekBench跑分曝光:有多个版本
下一篇: 人参黄芪汤的做法