preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.1k stars 485 forks source link

FR: Sidebar shown on the right of the current pane, when vim is split vertically #806

Open fvisin opened 2 years ago

fvisin commented 2 years ago

When vim is split vertically (multiple panes), the sidebar always shows in the rightmost part of the window. It would be useful to have an option to show the sidebar on the right of the pane it was opened in.

Example: with two panes, and tagbar opened in the first pane:

Current behavior:

|        |        |         |
| pane 1 | pane 2 | sidebar |    
|        |        |         |    

Desired behavior:

|        |         |        |
| pane 1 | sidebar | pane 2 |    
|        |         |        |    

Additionally, it would be very helpful to have a way to make the pane the tagbar relates to fixed (currently tagbar shows the tags of the pane with the active focus. I would rather have the tagbar stay keep its focus and potentially open a second one in the second pane if I need it)

raven42 commented 2 years ago

The window position can be controlled via the g:tagbar_position configuration. You can look at the help for :help split for more info about the possible values for the window position, but based on the example you provided, I believe this is the setting you would be looking for:

let g:tagbar_position = 'rightbelow vertical'

Regarding the active focus, there is no option currently that disables only the s:AutoUpdate() call, but if you set the g:tagbar_no_autocmds option, then that will disable the autoupdate as well as some other commands related to cursor movement and such. That might get the behavior you want. Currently tagbar is setup to only operate on the active file being operated on. So when you change to a different window with a different file, the active file in vim also changes. We might be able to do something to change this, but it would require a little bit of a rework.

fvisin commented 2 years ago

Thank you for the immediate reply!! I confirm that the g:tagbar_position setting does exactly what I wanted, thank you! I am not sure what keyword I used to search the docs, but somehow I missed that.

For what concerns preventing updates when the focus changes, I want to keep autoupdate so setting g:tagbar_no_autocmds won't work for me.

If you find the time to work on this feature, it would be great if opening tagbar from pane 1 and then again from pane 2 led to this:

|        |           |        |           |    
| pane 1 | sidebar 1 | pane 2 | sidebar 2 | 
|        |           |        |           |    

i.e., each pane is considered independently, and the sidebar associated to the pane currently in focus can be opened or closed with :TagbarToggle.