/RTags

Enables semantic C++ navigation and modification within Sublime Text 3, using RTags.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

RTags Plugin for Sublime Text 3

This plugin aims to give powerful C++ navigation and modification abilities, by intergrating RTags with Sublime Text 3 editor.

In short, RTags is a client/server application which parses C/C++ code and allows semantic auto-completion, navigation, and refactoring. It is the best open-source tool I've found for C/C++ parsing, and it greatly outperforms CTags/GTags etc...



Currently Available Features

  • GoTo Definition/Decleration Live Usage Example of GoTo Definition/Declaration
  • Find All References Live Usage Example of Find All References
  • Find Overrides of Virtual Method
  • Load Compilation Database

All features are available in the Command Panel (via Ctrl+Shift+P), and are assigned with default key bindings (found in Default.sublime-keymap).

Installation Instructions

Installing the Plugin

Clone this repository into your packages folder.

For example, within an Ubuntu machine:

cd ~/.config/sublime-text-3/Packages
git clone https://github.com/papadokolos/RTags.git

But wait! The plugin requires RTags in order to work, so please proceed to the next section.

Installing RTags

This should be fairly quick and easy. But in case you face any difficulties, feel free to ask me for help.

  1. Install Clang and CMake, which are depdendencies of RTags (See Here)

    For example, within an Ubuntu machine:

    sudo apt-get install clang
    sudo apt-get install cmake
  2. Install RTags

    For example, within an Ubuntu machine:

    cd ~/Downloads
    git clone --recursive https://github.com/Andersbakken/rtags.git
    cd rtags
    mkdir build
    cd build
    cmake ..
    make
    sudo make install

    For more information, please refer to RTags README

Setting up RTags to work for the first time

Now that you have RTags installed, it is time to use it to parse your code. A full guide can be found in RTags' README, but basically it sums up to three steps:

  1. Execute RTags server by opening a terminal and simply executing the command rdm.

  2. Generate a compilation databse for your code. This file informs RTags how you build your code.

    • If you build using CMake:

      cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
    • If you build using Make:

      sudo apt-get install bear  # Install a helper tool
      make -c                    # Clear past builds history in order to make a full build
      bear make                  # Build the code and generate the compilation database
    • If you build using SCons:

    sudo apt-get install bear  # Install a helper tool
    scons -c                   # Clear past builds history in order to make a full build
    bear scons                 # Build the code and generate the compilation database
  3. Direct RTags server to your generated compilation database by executing rc -J in the directory of the generated database.

Using the Plugin

First, make sure that the RTags server is up and running for this plugin to communicate with it. This can be done by opening a terminal and simply executing the command rdm. Make sure to keep this terminal open!

Now you are free to open the Command Panel (via Ctrl+Shift+P) and type RTags:. This will present you with all the available commands.

In case nothing happenes when you execute a command, try looking at the status bar for an error message of the plugin. For more verbose information, refer to Sublime Text's console (via Ctrl+`). If you're still unable to solve your problem, please open an issue and I'll be glad to assist you.

Contributions

You are very welcome to ask, suggest and contribute in any way you'd like. I'm using this plugin on a daily basis, so I'll be glad for any suggested improvements 😉

Worth Noting

This plugin was originally developed for my own use, and I was encouraged by my co-workers to post it to the public. Knowing that this plugin is very similar to ones that are already available via Package Control, especially Sublime RTags, I have no will to compete with them. So I will keep this plugin outside of Package Control.