vim-rtags


Ⅰ. 插件描述

Vim bindings for rtags, llvm/clang based c++ code indexer.

Ⅱ. 基本信息

创建日期:  2014-03-02
使用用户:  118
Github星:  257
插件作者:  lyuts

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'lyuts/vim-rtags-holy-ground'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'lyuts/vim-rtags-holy-ground'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'lyuts/vim-rtags-holy-ground'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/lyuts/vim-rtags

Ⅳ. 文档说明

# Vim Rtags

Vim bindings for rtags.

https://github.com/Andersbakken/rtags

Requirements

Installation

Vundle

Add the following line to .vimrc

Plugin 'lyuts/vim-rtags'

then while in vim run:

:source %
:PluginInstall

NeoBundle

Add the following line to .vimrc

NeoBundle 'lyuts/vim-rtags'

then while in vim run:

:source %
:NeoBundleInstall

Pathogen

$ cd ~/.vim/bundle
$ git clone https://github.com/lyuts/vim-rtags

Configuration

This plugin interacts with RTags by invoking rc commands and interpreting
their results. You can override the path to rc binary by setting
g:rtagsRcCmd variable. By default, it is set to rc, expecting it to be
found in the $PATH.

Out of box this plugin provides mappings. In order to use custom mappings the
default mappings can be disabled:

let g:rtagsUseDefaultMappings = 0

By default, search results are showed in a location list. Location lists
are local to the current window. To use the vim QuickFix window, which is
shared between all windows, set:

let g:rtagsUseLocationList = 0

To implement 'return to previous location after jump' feature, internal stack is used.
It is possible to set its maximum size (number of entries), default is 100:

let g:rtagsJumpStackMaxSize = 100

Usage

Mappings

Mappingrc flagDescription
<Leader>ri-USymbol info
<Leader>rj-fFollow location
<Leader>rJ-f --declaration-onlyFollow declaration location
<Leader>rS-fFollow location (open in horizontal split)
<Leader>rV-fFollow location (open in vertical split)
<Leader>rT-fFollow location open in a new tab
<Leader>rp-U --symbol-info-include-parentsJump to parent
<Leader>rc--class-hierarchyFind subclasses
<Leader>rC--class-hierarchyFind superclasses
<Leader>rh--class-hierarchyList full class hierarchy
<Leader>rf-e -rFind references
<Leader>rF-r --containing-function-locationCall tree (o - open node, Enter - jump)
<Leader>rn-ae -RFind references by name
<Leader>rs-a -FFind symbols by name
<Leader>rr-VReindex current file
<Leader>rl-wList all available projects
<Leader>rw-e -r --renameRename symbol under cursor
<Leader>rv-k -rFind virtuals
<Leader>rd--diagnoseDiagnose file for warnings and errors
<Leader>rbN/AJump to previous location

Unite sources

This plugin defines three Unite sources:

  • rtags/references - list references (i.e., <Leader>rf).
  • rtags/symbol - find symbol (i.e., <Leader>rs). Use rtags/symbol:i
    for case insensitive search.
  • rtags/project - list/switch projects.

Code completion

Code completion functionality uses completefunc (i.e. CTRL-X CTRL-U). If completefunc
is set, vim-rtags will not override it with RtagsCompleteFunc. This functionality is still
unstable, but if you want to try it you will have to set completefunc by

set completefunc=RtagsCompleteFunc

Also RtagsCompleteFunc can be used as omnifunc. For example, you can use
such approach with neocomplete(for more details read it's docs):

function! SetupNeocompleteForCppWithRtags()
    " Enable heavy omni completion.
    setlocal omnifunc=RtagsCompleteFunc

    if !exists('g:neocomplete#sources#omni#input_patterns')
        let g:neocomplete#sources#omni#input_patterns = {}
    endif
    let l:cpp_patterns='[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
    let g:neocomplete#sources#omni#input_patterns.cpp = l:cpp_patterns 
    set completeopt+=longest,menuone
endfunction

autocmd FileType cpp,c call SetupNeocompleteForCppWithRtags()

Such config provides automatic calls, of omnicompletion on c and cpp entity accessors.

Current limitations

  • There is no support for overridden functions and methods
  • There is no support for function argument completion

Notes

  1. This plugin is wip.

Development

Unit tests for some plugin functions can be found in tests directory.
To run tests, execute:

$ vim tests/test_rtags.vim +UnitTest

添加新评论