vim 安装YouCompleteMe 插件

原文链接:http://www.aisun.org/2017/10/vim+youcompleteme/

 

 

要安装YouCompleteMe ,vim须支持python。可以命令输入vim --version 查看, 如果python前有+号,就是支持,减号就是不支持。

如果不支持,需要以编译安装方式重新安装vim。

编译配置选项:

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

 

安装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 进行自动安装

+号表示已经安装,>表示正在安装;


在.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文件

 

重启vim之后出现需要更高版本的vim,需要先升级vim,

首先,要下载vim的源代码。

cd ~

git clone https://github.com/vim/vim.git

cd vim

 进入源代码的src目录中,执行:
./configure --with-features=huge --enable-pythoninterp=yes --enable-cscope --enable-fontset --enable-perlinterp --enable-rubyinterp --with-python-config-dir=/usr/lib/python2.7/config --prefix=/usr/local
需要注意的是,不能写上--enable-gui,这是开启gui特性的,但是我们是在终端环境下安装的,因此不能开启这个特性,否则会出现编译错误。之后

cd ..

sudo make install

which vim

将src目录下编译好的vim执行文件替换上边which vim路径内的vim文件就升级ok了;

 

 

posted @ 2017-10-13 10:24 枫小Q 阅读(...) 评论(...) 编辑 收藏