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

Improve the documentation for colorscheme customization #85

Open ZaneBartlett1 opened 1 year ago

ZaneBartlett1 commented 1 year ago

Hello,

Thanks a ton for the pluggin, I really love it! The one thing that I was hoping I might be able to configure is this blue highlighting I'm getting from having netrw and a terminal open - image

I understand it probably has something to do with the fact they're kind of hidden buffers it seems? I looked at what's configurable here but honestly have never messed with colors or anything like that and really just want to turn the highlighting off as whatever buffertab is darkened does correctly correspond to the buffer in focus. Any help is much appreciated!

ap commented 1 year ago

Hi, sorry I didn’t realize how long this has been waiting for a response.

Basically the way color schemes in Vim work is that things like UI elements and parsed bits of syntax use symbolic names, and color schemes assign colors to these symbolic names, but symbolic names can also be linked to another symbolic name. And the linked bit of the documentation describes the symbolic names that BufTabLine declares, plus which well-known symbolic names it defaults links them to. That way BufTabLine automatically picks up colors defined by your color scheme which will hopefully fit together well. But sometimes they don’t, and then you can assign a color to one of BufTabLine’s symbolic names directly which overrides the linkage. So you can certainly override the blue highlight with something else.

What commands did you run to get this set of buffers? I’m trying to figure out what kind of buffer is being highlighted in blue.

ZaneBartlett1 commented 1 year ago

No problem at all! If this ends up being a huge thing I'd honestly be okay with just closing this. I recently moved to nvim and use a different pluggin to handle buffers. Although I'm trying to make my config usable to others and still suggest this pluggin for a more streamlined set up, as it really is plug and play. I do get the same issue on nvim as vim though, so I'd be interested in knowing how to solve this so that I can add that to the ReadMe, but not at a large expense of your time!

If it's the case that this wouldn't be a large ask, on nvim I'm running :Lexplore|wincmd l|10split|terminal. I forget if the command is the exact same on vim though because the terminals are handled differently. In both cases though I'm fairly confident it's the emulated terminal buffer that's being highlighted blue. If I switch focus to the terminal, buftabline shows that I'm focused on the buffer that is highlighted blue at that point. Let me know if there's anything else helpful I can provide on my end! Here's the current config I'm using for nvim if that's any help https://github.com/ZaneBartlett1/nvim

FriendlyTroll commented 1 year ago

Just info for anyone running into this issue:

I wanted a similar solution to this, but only to reverse the highlighting around, so that the blue highlight represents the active tab, so I used this .vimrc snippet :

...
" color scheme
colorscheme onedark
" buftabline custom highlight
" this has to be applied after colorscheme
highlight TabLineSel term=bold ctermfg=236 ctermbg=39
highlight PmenuSel ctermfg=145 ctermbg=237
...

You can play around with the numbers to get different colors. You can also show the current highlight mappings by running :hi

Might be good to add info about this in the README, as this could be a common thing people would want.

ap commented 1 year ago

@FriendlyTroll That’s not a good way of doing this. Buftabline is piggybacking on TabLineSel and PmenuSel in order to integrate with everything else, but those have other meanings as well, so you’re messing with more than you intend. Instead you should override just Buftabline’s own custom names, which are documented in :help buftabline-colors.

But a better way still is not to define specific colors but to reuse one from your colorscheme. You can do this by browsing :help highlight-groups, which lists the standard highlight group names and conveniently highlights them by themselves, so it’s kinda like a color swatch. Find a highlight group name with a color that makes sense, then put hi link BufTabLineActive ThatOtherGroup in your vimrc.

(Yes, this should be in the docs, this last part in particular. I didn’t have a good user-friendly results-oriented way of explaining this process until just now.)

FriendlyTroll commented 11 months ago

Hi ap, sorry for the late reply.

Thanks for the info, you are right my way is not the optimal one. I did try your suggestion, however in my testing the BufTabLineActive controls the non-focused tab and the BufTabLineCurrent controls the active buffer, here's the config part

highlight link BufTabLineCurrent WildMenu
highlight link BufTabLineActive Search

which gets me this Screenshot from 2023-07-24 10-49-24 debian11.yml is the current focused buffer, the other one is in vertical split.

Anyway it works now, and thanks for the lesson in vim highlighting :-D

ap commented 11 months ago

Sorry for the late reply.

Have you seen how late some of my replies are? 😛

Anyway it works now, and thanks for the lesson in vim highlighting :-D

Happy to provide. 🙂