preservim / tagbar

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

How to get back the old default (botright vertical) window position? #650

Closed RoDuth closed 4 years ago

RoDuth commented 4 years ago

My vimscript is a little rusty so I may be missing something obvious here. Can i get my normal botright vertical tagbar window position back somehow?

I was always happy with the default window position for tagbar and never changed it in my .vimrc. It seems to me that since #630 the default position is now rightbelow verical (i.e. right of the current window when opening tagbar) rather than botright vertical, as it was always before, (i.e. far right of the vim window).

From a quick glance at the help for g:tagbar_position and 4e7e1990429a4b4d7191719c40b23d9a084c237a I can't see a way to get back the original default behavior using settings in my .vimrc. But as I said it's been a while since I looked at any vimscript so forgive me if I've missed something obvious.

(For now I've reverted to before 4e7e1990429a4b4d7191719c40b23d9a084c237a.)

RoDuth commented 4 years ago

Take that back. Rather than revert I've just changed line: https://github.com/majutsushi/tagbar/blob/e5c864738db6135a27b6373585d6f4987ffdddb5/autoload/tagbar.vim#L883 to let openpos = 'botright '

All is back to my expected behaviour....

Is this small change acceptable to the original intent of #630?

alerque commented 4 years ago

I'll be honest in my usage the change was a Noop (the window appears in the same place as before with default settings) and I'm not sure even from your description what the actual difference in practice is.

Hey @raven42 does this mean anything to you?

RoDuth commented 4 years ago

The main issue is that the tagbar window now appears between splits/windows if you have several open at a time. I.e. I have 3 vertical splits/windows open with related files. I open tagbar while in the first split/window (furthest left). Now tagbar is between split 1 and 2 and I still have split 3 on the far right. If I switch between the 1st split and the furthest right (i.e. now <C-w>4w) the tagbar window remains between the 1st and 2nd split but now shows the outline for the 3rd split (Furthest right). So you now have something that could be described as: file1 | tagbar (showing outlining for file3) | file2 | file3. I find that confusing.

The old behaviour was that no matter what split/window you where in when you opened tagbar it would always be on the far right of the vim screen (i.e. file1 | file2 | file3 | tagbar).

Quickest way to see what I mean: Open vim then: :vsp :vsp :TagbarOpen and note where the tagbar window is. (if for any reason it is on the far right for you due to a vimrc setting, try <C-w>1w before opening Tagbar.)

RoDuth commented 4 years ago

screenshot for clarity:

Screen Shot 2020-08-30 at 11 42 07 pm

Note that the cursor is in the window on the far right (numbered 4) and tagbar is displaying this file's outline in window 2nd from the left (numbered 2).

Previously tagbar would have always been on the far right position (window numbered 4), e.g.:

Screen Shot 2020-08-31 at 12 05 19 am

Of course the cursor is in the far left window/split here (numbered 1) and tagbar is on the far right of the screen showing it's outline.

I hope that all makes some sense.

raven42 commented 4 years ago

I've been able to confirm the bahavior @RoDuth has mentioned. I'll have to look into a better way to handle this then. The main purpose of #630 was to work with a window manager plugin I was developing https://github.com/raven42/devpanel-vim. With the open position using 'rightbelow' or 'leftabove', It allows the window placement how I was wanting like this:

+----------+---------------+
| NERDTree | Edit Window   |
|          |               |
|          |               |
+----------+               |
| Tagbar   |               |
|          |               |
|          |               |
+----------+---------------+

If I change this to 'botright' and 'topleft', then I end up with this type of window positioning.

+----------+---------------+
| NERDTree | Edit Window   |
|          |               |
|          |               |
+----------+---------------+
| Tagbar                   |
|                          |
|                          |
+--------------------------+

I can look at adding a more direct option using the full syntax for 'topleft' / 'botright' / 'leftabove' / 'rightbelow' with a default of 'botright' so the behavior is the same as the old default.

RoDuth commented 4 years ago

I can look at adding a more direct option using the full syntax for 'topleft' / 'botright' / 'leftabove' / 'rightbelow' with a default of 'botright' so the behavior is the same as the old default.

Yes please, exactly what I thought. If openpos was to just equal what is set in g:tagbar_position you could have any of these arrangement options.

Interesting to see your reasoning for what you wanted (tagbar under NERDTree), makes a little more sense to me now.

alerque commented 4 years ago

Thanks for the extra explanation @RoDuth, I see the problem now too. I use both splits and tagbar extensively but don't mix and match my usage at all. I agree the default should be as you describe because having tagbar update for panes on both sides of it is confusing.

It looks like @raven42 is on this for now, let me know if you need anything from me.