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

allow tagbar to run even in diff window #613

Open damnskippy opened 4 years ago

damnskippy commented 4 years ago

It seems tagbar is disallowed if vim is set to diff mode: https://github.com/majutsushi/tagbar/blob/f1bea00e5be714b14c7401f86a32aed558b0b415/autoload/tagbar.vim#L3138

Is it possible have a user setting to allow tagbar in diff mode as well? For instance, I currently rely on tagbar#currenttag() to set the context in the statusline. While doing diff especially more than any other time, the current tag is useful to have while going through a long file full of differences to see the current function tag that is currently being displayed by vim diff.

Thanks.

alerque commented 4 years ago

Have you tried just dropping that block entirely and seeing how it works? We might consider just allowing it by default, but it would be nice to understand what the restriction was about in the first place and what the other side effect are that might be unwanted.

alerque commented 4 years ago

I assume this might get complicated because we already don't deal with splits very well, and even switching buffers is bumpy.

damnskippy commented 4 years ago

Yes dropping the block works fine. It's perfectly reasonable that someone wouldn't want to open a tagbar split in the case of a diff window, and this is likely the reason. However tagbar is not even proceeding to load the tags in this case because diff is set to true i.e. tagbar is completely shut off and unavailable. What I was suggesting is that if there's a user setting allow_tagbar_in_diff the user then has a choice, they can choose to not open the tagbar window but tagbar is still available if the user wants to. And the tagbar APIs like currenttag continue to be availalble as well.

alerque commented 4 years ago

I definitely see the use case for this, and yes we should make a way for it to happen.

In my case by far the most common diff split I have open is using :Gdiff from vim fugitive. We will need to figure out how to **avoid*** generating tags for buffers that are not backed by actual files.