You CompleteMe插件安装 - linux

You CompleteMe插件安装



第一步:安装Vundle和YouCompleteMe插件

1,安装vundle插件

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

配置.vimrc

如下:

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.

" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'

" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'

" Git plugin not hosted 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'
" 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/'}

" Install L9 and avoid a Naming conflict if you've already installed a different version somewhere else.
Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

" To ignore plugin indent changes, instead use:
"filetype plugin on
"

" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

" 此后添加自己需要的其他vim配置
set number
2,安装YouCompleteMe和其它插件

Launch vim and run :PluginInstall

To install from command line: vim +PluginInstall +qall

或者采用:git clone –recursive https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/vundle

然后使用git submodule update --init --recursive确认仓库的完整性后,开始安装流程。


第二步:编译YouCompleteMe

方法1:脚本编译安装

./install.py –clang-completer

如果不需要*c-family的补全,可以去掉--clang-completer。如果需要*c#的补全,请加上--omnisharp-completer。,如果支持所有,请加上 --all

正常来说,YCM会去下载clang的包,如果已经有,也可以用系统--system-libclang。

就这样,安装结束。打开vim,如果没有提示YCM未编译,则说明安装已经成功了。

注意:clang的版本要求大于3.8,如果yum不能查到现成的编译好的clang版本,则需要手动编译

[ 手动编译安装Clang ] http://www.cnblogs.com/dudu/p/4294374.html

方法2:手动编译安装
  1. 下载最新的clang二进制文件 YCM要求clang版本 > 3.2,一般来说都是下载最新的

    • > 需要下载安装llvm,然后再编译clang
  2. 安装python-dev.(ubuntu下使用sudo apt-get install python-dev,mac下默认提供,否则请安装command line tools)

  3. 编译

    cd ~

    mkdir ycm_build

    cd ycm_build

    cmake -G “Unix Makefiles” -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp make ycm_support_libs

    其中~/ycm_temp/llvm_root_dir中包含的是根据第一步下载的压缩包解压出来的内容(包括includebin等等文件)

这样就完成了,开始感受YCM提供的完全不逊色于大型IDE所提供的自动补全功能吧。

第三步:文件配置

语义补全

在.vimrc中添加

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

进行全语义补全,也可以每次在工作目录中放置这个文件

Tags跳转

在.vimrc中添加

nnoremap gl :YcmCompleter GoToDeclaration
nnoremap gf :YcmCompleter GoToDefinition
nnoremap gg :YcmCompleter GoToDefinitionElseDeclaration

其它配置项

” for ycm
let g:ycm_error_symbol = ‘>>’
let g:ycm_warning_symbol = ‘>*’
nnoremap gl :YcmCompleter GoToDeclaration
nnoremap gf :YcmCompleter GoToDefinition
nnoremap gg :YcmCompleter GoToDefinitionElseDeclaration
nmap :YcmDiags

注意事项

  • 编译安装python的时候:./configure –prefix=/home/install/python2.7.8 –enable-shared

参考

最权威的官方安装指南

如何在无网PC上使用YouCompleteMe

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值