Vim bindings for rtags.
https://github.com/Andersbakken/rtags
Add the following line to .vimrc
Plugin 'lyuts/vim-rtags'
then while in vim run:
:source %
:PluginInstall
Add the following line to .vimrc
NeoBundle 'lyuts/vim-rtags'
then while in vim run:
:source %
:NeoBundleInstall
$ cd ~/.vim/bundle
$ git clone https://github.com/lyuts/vim-rtags
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
Mapping | rc flag | Description |
---|---|---|
<Leader>ri | -U | Symbol info |
<Leader>rj | -f | Follow location |
<Leader>rJ | -f --declaration-only | Follow declaration location |
<Leader>rS | -f | Follow location (open in horizontal split) |
<Leader>rV | -f | Follow location (open in vertical split) |
<Leader>rT | -f | Follow location open in a new tab |
<Leader>rp | -U --symbol-info-include-parents | Jump to parent |
<Leader>rc | --class-hierarchy | Find subclasses |
<Leader>rC | --class-hierarchy | Find superclasses |
<Leader>rh | --class-hierarchy | List full class hierarchy |
<Leader>rf | -e -r | Find references |
<Leader>rF | -r --containing-function-location | Call tree (o - open node, Enter - jump) |
<Leader>rn | -ae -R | Find references by name |
<Leader>rs | -a -F | Find symbols by name |
<Leader>rr | -V | Reindex current file |
<Leader>rl | -w | List all available projects |
<Leader>rw | -e -r --rename | Rename symbol under cursor |
<Leader>rv | -k -r | Find virtuals |
<Leader>rd | --diagnose | Diagnose file for warnings and errors |
<Leader>rb | N/A | Jump to previous location |
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 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.
Unit tests for some plugin functions can be found in tests
directory.
To run tests, execute:
$ vim tests/test_rtags.vim +UnitTest