mgedmin / taghelper.vim

vim plugin that shows the current function/tag in the statusline
7 stars 1 forks source link

Make different colors when unfocused #4

Open RyannDaGreat opened 2 months ago

RyannDaGreat commented 2 months ago

Hi! Is it possible to make this have different colors when unfocused?

mgedmin commented 2 months ago

It should be possible, but might not necessarily be easy.

First, taghelper itself doesn't do anything about colors. The README suggests using %1* which will use the User1 highlight group and apply it on top of the StatusLine/StatusLineNC highlighting. So if you don't set foreground/background/attributes in your User1, those will be inherited from StatusLine/StatusLineNC and can differ between focused and unfocused windows.

The harder option is to change the &statusline to use different highlight groups for active and inactive windows, e.g. User1/User2, or arbitrarily named highlight groups. I don't consider myself an expert in this; I have played with a custom statusline and ended up using a bunch of autocommands to :setlocal statusline=... to different (computed) statuslines for active and inactive windows. I remember trying to avoid that by using %!, but that didn't work (the statusline wasn't re-evaluated and re-drawn when I switched windows). Maybe %{% win_getid() == g:actual_curwin ? '%1*' : '%2*' %} would work? I don't remember trying '%{%...%}`. I suspect it didn't exist back when I tried my custom statusline experiments.

Apologies, this is probably not very helpful.

mgedmin commented 2 months ago

If I had to do this again, and didn't have the time/desire to write my own underdocumented statusline plugin, I'd investigate one of the existing plugins (airline/lightline) and see how hard it is to add a custom section with custom highlighting.

(And then document it in the README of taghelper.vim. If you do go in that direction and figure something out, please share!)