/vim-rtags

C++ code navigation in Vim editor.

Primary LanguageVim ScriptGNU General Public License v2.0GPL-2.0

vim-rtags

C++ code navigation in Vim editor.

rtags uses clang to find symbol references, definitions, etc.

Setup

vim-plug:

Plug 'yakubin/vim-rtags'

pathogen.vim:

cd ~/.vim/bundle && \
git clone https://github.com/yakubin/vim-rtags

Vundle:

Plugin 'yakubin/vim-rtags'

The rtags bin directory needs to be in your PATH.

Usage

:RtagsFollowSymbolUnderCursor find definition/declarations of the symbol under the cursor
:RtagsFindRefsToSymbolUnderCursor find references to the symbol under the cursor
:RtagsGetTypeOfSymbolUnderCursor print the type of symbol under the cursor in the status line
:RtagsFind symbol find definition/declarations of symbol
:RtagsRegexFind pattern find definitions/declarations of symbols matching pattern

Suggested keymaps

nnoremap <silent> <F1> :RtagsFollowSymbolUnderCursor<CR>
nnoremap <silent> <F2> :RtagsFindRefsToSymbolUnderCursor<CR>
nnoremap <silent> t :RtagsGetTypeOfSymbolUnderCursor<CR>

The Vim-unimpared plugin can help with navigating the output of vim-rtags. It maps:

  • [l, ]l to move up/down a line in the "location list" window
  • [L, ]L to move to first/last entry, and
  • [<C-L>, ]<C-L> to jump to previous/next file.

To do

  • Make it work when a source file has not been saved. Note: buffers other than the current one may have significant unsaved changes. (A special case exists where a buffer has never been saved.) The simplest solution might be just to save everything that has been modified/created before calling rtags.
  • Automatically start rdm. (rc should start rdm if it can't connect to rdm.)
  • Lots more!