Closed daedroza closed 3 years ago
- I want to open the tagbar without going into it's window.
This should already be the default behavior. This can be controlled via the g:tagbar_autofocus
configuration. When set, this option will cause the cursor to move to the tagbar window when opened. But by default this is disabled and so opening the tagbar window should cause the cursor to remain where it is in the file you have opened and not move to the tagbar window.
- I want to jump to next tag (variables, functions, etc) without going into tagbar's window. Expectation is to smoothly traverse the code and not the tagbar window.
I don't think there is a way to do this currently. There are the key mappings for next/prev in the tagbar window to traverse to the next/prev top level tag, but that doesn't sound like what you are asking about.
A function could probably be created to traverse the file like this, but it would have to be newly developed. If you want to take a crack at it we'd be more than happy to help put it in.
I've done an initial test of some code that will handle something like described in item 2. The code is in #780. Give it a try and let me know if this is the behavior you are looking for. This still needs more testing and documentation, but it should give the basic functionality I believe.
You can add the following to your .vimrc
to provide a mapping to the new functionality if you want.
nnoremap <silent> t[ :TagbarJumpPrev<CR>
nnoremap <silent> t] :TagbarJumpNext<CR>
Thanks @raven42 I will take a look tomorrow and will let you know.
Hi, @raven42 I have picked your PR. Sometimes tagbar doesn't jump to private functions. I do have tagbar_wrap = 1. Sometimes it would just jump to top or bottom.
Can you share a screenshot and/or code sample so I can try it out? Does the private function show up in the tagbar window? If you have the tagbar logs that would help too. I'll need to verify the output of ctags for the code as well.
I'm new to vim world hence would require your help in getting the logs. Perhaps a guide or so that worked for you would definitely help me help you in helping me, lol. Here is an example that you can check which has multiple classes and it's functions.
Another thing I noticed is that while jumping to next fold is accurate, jumping to previous fold is not accurate. Not sure if I sure create another ticket for that?
No new ticket. We can track it under this issue as this feature is in development.
Looking at the example code, it does appear to be working for me. Can you please give a specific example from this file for the behavior you are seeing where it isn't jumping to the correct tag? What line is your cursor on, what are you using to jump to the next tag (if a keymap, please include the keymap definition, if using :TagbarNextTag
/:TagbarPrevTag
, please list that... if using a direct function call to :call tagbar#jumpToNearbyTag()
please include that). Also please include what you see vs what you are expecting to see. And also include anything else that you think might help me repro the issue so I can debug.
To get the logs, please see the debugging section in the doc/tagbar.txt file here: 7. Troubleshooting & Known issues
Also please include any relevant configurations in your .vimrc
that are tagbar related.
let g:no_status_line = 1 let g:tagbar_autofocus = 0 let g:tagbar_autopreview = 0 let g:tagbar_autoshowtag = 1 let g:tagbar_compact = 1 let g:tagbar_indent = 1 let g:tagbar_jump_offset = winheight(0)/4 let g:tagbar_left = 1 let g:tagbar_silent = 1 let g:tagbar_sort = 0 let g:tagbar_width = max([40, winwidth(0) / 6]) let g:tagbar_wrap = 1
Additionally, for tagbar_wrap to look nice, I had to set nolinebreak. Can we force just the tagbar window to also set nolinebreak with wrap? It looks cleaner and much better and the whole string isn't broken into 3 lines. That way, I can have linebreak in my working window, while tagbar window has nolinebreak when set with tagbar_wrap = 1.
- Bug with your current PR, video here. Currently, as you can see, the private function is directly skipped.
Can you please describe the behavior you are expecting? It looks to be working correctly to me. Are you expecting it to jump to the private final Runnable mRemoteBugreportTimeoutRunnable = new Runnable()
line? If so, you would need to change your keymapping to call the function directly with a different search_action
. This is not a function itself but is a variable declaration which is initialized to a function call. If you do this for your keymapping then it would include all tags, not just the stl
type tags (tags that have scope).
nnoremap <silent> t[ :call tagbar#jumpToNearbyTag(-1, 'nearest')<CR>
nnoremap <silent> t] :call tagbar#jumpToNearbyTag(1, 'nearest')<CR>
- Another bug with jumping to previous fold, video here. Arrive on the fold (using next fold function), then using previous fold function. It goes back only one line. Again repeat the previous function, goes to previous fold - 1.
This one I can look into. This might be a different bug and we'd want to track it separately. I misunderstood you before and thought you were talking about jumping around with this new feature, not using the zj
/zk
keys to jump within the tagbar window. Sorry about that. Yup what you are seeing does indeed look like a bug. Please file a different issue for the jumping to previous fold within the tagbar window is not working correctly. Please include the relevant information in that issue even though it is described here just to make sure all the necessary info is included there.
- Slight visual issue is the colorcolumn that is also being set in the tagbar window.
What is the visual issue you are describing with colorcolumn? This sounds like it would be a different issue as well. Please file a different issue and we can track it under that. Also please include all relevant info and the required configurations to reproduce. Also include what you are expecting to see.
Additionally, for tagbar_wrap to look nice, I had to set nolinebreak. Can we force just the tagbar window to also set nolinebreak with wrap? It looks cleaner and much better and the whole string isn't broken into 3 lines. That way, I can have linebreak in my working window, while tagbar window has nolinebreak when set with tagbar_wrap = 1.
This one would also be a separate issue. I'd have to look into the reason for the linebreak. We can discuss further in the separate issue, but does this only happen when you have set linebreak
in your .vimrc
?
@David-Hegland Thanks for the help. tagbar#jumpToNearbyTag() is exactly what I'm looking for. The only caveat that I can think of is that it doesn't respect my tagbar_jumpoffset value and the tags are jumped based on what's visible on the working window and not the tagbar window.
For example, let's say I've 3 fields, 4 methods and 3 fields again. Tagbar would show 6 fields at top and 4 methods later. However, navigating through them using the nearbyTag() function is 3 fields -> 4 methods -> 3 fields again. Is this something we can change and probably guard with g:tagbar_strict_navigation = 1 (or something better?). This is purely for plugin's UI experience.
For other issues that I have reported here, I will create relevant tickets.
Created #782 #783 #784 for tracking other issues.
The only caveat that I can think of is that it doesn't respect my tagbar_jumpoffset value and the tags are jumped based on what's visible on the working window and not the tagbar window.
This was actually by design. I was playing around with the jump offset and it felt very unnatural. When jumping from the tagbar window to the tag it feels fine, but when navigating the file itself with the tag jumping, it did not flow well. I can see how some might prefer it though, so I will look at adding a flags field to the function call so it can be customized.
Thanks @raven42 , you've been great help!
@daedroza I've update the PR with an optional flags field to pass into the function. The documentation should be updated to include info about doing what you are wanting. Give it a try and let me know.
Tested the commit with option flag 's', works exactly as intended. Awesome! +2 +1
Hi, Currently I want to have the following use case: 1) I want to open the tagbar without going into it's window. 2) I want to jump to next tag (variables, functions, etc) without going into tagbar's window. Expectation is to smoothly traverse the code and not the tagbar window.
The above functionality is similar to [[ and ]], however it works correctly only with C and C++ files. Java files tend to jump to top and bottom of the file and not to their respective functions and variables.
Is there a way to use tagbar's existing functionality so I can remap [[ ]] and move to next tag without going into tagbar window (and hence not closing it).
Thanks!