lyuts / vim-rtags

Vim bindings for rtags, llvm/clang based c++ code indexer.
BSD 2-Clause "Simplified" License
282 stars 56 forks source link

Jump to definition or declaration #42

Closed dpelle closed 8 years ago

dpelle commented 8 years ago

The vim rtags plugin is very useful for browsing c++ code. Thanks. In the current implementation rj jumps either to the definition or to the declaration as follows:

I find this a bit confusing as there is a state. It also causes me to press rj twice if I want to jump to a declaration when cursor is where a symbol is used. I wish there were instead 2 mappings:

Is that possible?

lyuts commented 8 years ago

I personally don't think that the way <leader>rj mapping works is confusing. It is usually called context search and works fine in most cases.

Case Cursor location Mapping action
1 declaration jump to definition
2 definition jump to declaration
3 usage jump to definition

While it is possible to have a separate mapping for jumping to a declaration and a different mapping for jumping to a definition it seems like it would be an overkill. JumpTo has 4 variants: regular, split, vertical split and tab. I'm not sure we want 4 new mappings to cover jump-to-declaration case. AFAIU, the only issue you are having is 3rd case and only when you intend to jump to a declaration. How do you workaround this right now? I'm fine with adding a single mapping for jumping to declaration which will open that in the same window.

lyuts commented 8 years ago

Let me know if this works for you.

dpelle commented 8 years ago

Let me know if this works for you.

Sorry for the late response, I did not see your comment earlier. I got the latest version of plugin with the new rJ mapping. Thanks. It works fine for me.

I often want to jump to the declaration directly (rather than first definition, then declaration), as the documentation is near the declaration in the code that I'm working on.

Off-topic: I see 2 typos in the help files:

$ git diff rtags.txt
diff --git a/doc/rtags.txt b/doc/rtags.txt
index dcdf519..177f2d7 100644
--- a/doc/rtags.txt
+++ b/doc/rtags.txt
@@ -84,7 +84,7 @@ g:rtagsMaxSearchResultWindowHeight
 g:rtagsLog

     Default: empty
-    When set to filename, rtags will put it's logs in that file.
+    When set to filename, rtags will put its logs in that file.

                                                                 *rtags-mappings*
 4. Mappings
@@ -181,7 +181,7 @@ g:rtagsLog

         rtags/symbol        find symbol (alternative to <Leader>rs).

-        rtags/symbol:i      same as rtags/symbol, but for case insensitibe.
+        rtags/symbol:i      same as rtags/symbol, but for case insensitive.

         rtags/project       list/switch projects.
lyuts commented 8 years ago

Thanks for finding typos. I can fix them, or you can fix them and send a pull request if you would like. Problem found, problem solved. Thank you.

lyuts commented 8 years ago

Typos fixed. Thanks for filing.