lyuts / vim-rtags

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

Conditional Jump to a New Tab #125

Closed esman closed 4 years ago

esman commented 4 years ago

Hi, thanks for the great plugin I'm using on a daily basis!

Is it possible to 'follow' a symbol and open it in a new tab only in case it would be a different source file?

Thanks!

mckellyln commented 4 years ago

I see this: noremap \<Leader>rT :call rtags#JumpTo(g:NEW_TAB) Does \<Leader>rT on the symbol open a new tab ?

mckellyln commented 4 years ago

Several people have added some maps and updated things in pull requests and/or their own forks of vim-rtags.

esman commented 4 years ago

Indeed, rtags#JumpTo(g:NEW_TAB) opens a new tab, but it does so even if the symbol is at the same (currently opened) source file. So you'll end up with two tabs with the same file opened.

mckellyln commented 4 years ago

ok, sorry I didn't get that detail in your original question - you only want a new tab if the symbol is in a different file. I think one could modify the mapping or add a new mapping for that. Would have to experiment some to figure it out.

mckellyln commented 4 years ago

I added some code to my fork of vim-rtags for this. So now \<Leader>rT will only create a new tab if the symbol is in a different file than the current buffer. \<Leader>rt still always opens a new tab. You can check it out if you like, I have not tested it much.

mckellyln commented 4 years ago

@esman fyi, I just updated my vim-rtags repo again with one more change after some more testing.

mckellyln commented 4 years ago

I changed my fork again just now, so rT is new tab if different file and rt is new tab always - but if same file then its a tab split instead of a tab new. So thanks for suggesting this, it made for some nice updates :-)

esman commented 4 years ago

@mckellyln Thank you a lot. Your changes really work for the case!

I think I should try to dive into a syntax and provide PR to this repo also.

mckellyln commented 4 years ago

@esman you are welcome. Let me know if you have any problems or suggestions. I hadn't looked at this in a while and I am glad I did because of your note - and then I found and fixed a few more little things. Several others have submitted PRs but I think it's been a while since any were reviewed/merged? Which is why I created a fork and updated it and cherry-picked some other great fixes/features from others' PRs over time.