Skip to content

vim plugin for rtags (originally forked from lyuts/vim-rtags)

License

Notifications You must be signed in to change notification settings

mckellygit/vim-rtags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vim Rtags

Vim bindings for rtags.

NOTE: Forked from original version: lyuts/vim-rtags

https://github.com/Andersbakken/rtags

Requirements

Installation

Vundle

Add the following line to .vimrc

Plugin 'mckellygit/vim-rtags'

then while in vim run:

:source %
:PluginInstall

NeoBundle

Add the following line to .vimrc

NeoBundle 'mckellygit/vim-rtags'

then while in vim run:

:source %
:NeoBundleInstall

Pathogen

$ cd ~/.vim/bundle
$ git clone https://github.com/mckellygit/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

To automatically re-index file on every save/write, default is 0:

let g:rtagsAutoReindexOnWrite = 1

To add colon (:) to symbol 'word' (via iskeyword), default is 0: (use rx [default mapping] to toggle)

let g:rtagsUseColonKeyword = 1

Usage

Mappings

Mapping rc flag Description
<Leader>ri -U Symbol info
<Leader>rj -f Follow location
<Leader>rJ -f --declaration-only Follow declaration location
<Leader>rV -f Follow location (open in vertical split)
<Leader>rH -f Follow location (open in horizontal split)
<Leader>r| -f Same as <Leader>rV
<Leader>r_ -f Same as <Leader>rH
<Leader>rT -f Follow location open in a new tab
<Leader>rt -f same as rT but same tab if in same file
<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>r, N/A Jump to previous location
<Leader>r. N/A Jump to next location
<Leader>rm --kind-filter -i -F Find method in current file
<Leader>r0 --suspend all Suspend indexing
<Leader>r1 --suspend clear Resume indexing
<Leader>rx N/A Toggle colon (:) in symbol 'word'

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. Forked from original version: lyuts/vim-rtags
  2. Tested with vim, need to test with neovim
  3. PRs welcome

Development

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

$ vim tests/test_rtags.vim +UnitTest

About

vim plugin for rtags (originally forked from lyuts/vim-rtags)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages