ap / vim-buftabline

Forget Vim tabs – now you can have buffer tabs
http://www.vim.org/scripts/script.php?script_id=5057
MIT License
782 stars 75 forks source link

Current Buffer not highlighted when using NerdTree #55

Closed jensbambauer closed 5 years ago

jensbambauer commented 6 years ago

Hi, cool plugin, exactly what I was looking for.

Using NerdTree the current open buffer is not highlighted when the focus is not on NerdTree but on the opened buffer. Is there a way to fix this?

Focus on the buffer: screen shot 2018-04-12 at 19 25 23

Focus on NerdTree: screen shot 2018-04-12 at 19 30 35

ap commented 6 years ago

No, that’s just how the colorscheme you’re using looks:

In the second screenshot, none of your actual buffers has focus. The focus in that screenshot is on an unlisted buffer created by NERDTree. Compare the output of :ls and :ls! to see what I mean. BufTabLine doesn’t show unlisted buffers. So all visible listed buffers are highlighted like the completion menu selection, which in your colorscheme has that dark on bluish look.

As for the colorscheme definitions used by BufTabLine – plain Vim unfortunately only defines two highlight group for tabs: one for the selected tab and one for other tabs. But BufTabLine needs a third option… so I filled it in by taking one of the completion menu highlight groups. Whether that will work well with any given colorscheme is basically a crapshoot… but most of the time it seems to work well enough that nobody notices.

If you want to keep using this colorscheme and you don’t like how it looks, you can petition the author of the colorscheme to support BufTabLine explicitly – it sets up its own highlight groups for that purpose, documented under :help buftabline-colors. Alternatively, if you don’t want to do that, or if you can’t, you can redefine the colors yourself in your vimrc, as documented in :help :hi-link (with available highlight groups listed in :help highlight-groups).

Does that help?

jensbambauer commented 6 years ago

That makes sense, thank you. I got confused because the blue background looks like this should be selected.

For now I'll add hi default link BufTabLineActive TabLineSel hi default link BufTabLineCurrent PmenuSel

to my vimrc. Is that a bad idea?

ap commented 6 years ago

No, that’s almost exactly right, just without the default keyword.

The purpose of default is to say that this link doesn’t override an already-created link without the default keyword, if there is one. The idea is that colorschemes and plugins etc should create default links while the user’s configuration creates non-default links, and that way the user’s links won’t get overridden regardless of the load order of everything. Basically you can think of default like an equivalent to !important in CSS, just with the opposite effect on priority (!unimportant?).

At least, that’s the intended usage. I don’t know if that mechanism ever made all that much sense (you can put your hi link commands after your colorscheme command, after all), but in today’s world of bundles/packages, it seems particularly obsolete – a special one-off mechanism to work around load order just for colorscheme stuff, from an older time when you would just dump everything straight into ~/.vim/colors/ and ~/.vim/plugin etc and hope for the best.

But… since it’s designed that way… might as well use it like that, even when it doesn’t end up mattering in practice.