I need this in order to finish a plugin I'm making in order to change the colors of the statusline depending on the mode.
However I've run across an obvious problem, how would I know what theme the user is using? And even if I knew I can't make specific colors for each theme.
So, how to know the foreground and background colors that the current theme is using for the statusline for example.
EDIT 1:
In case I wasn't clear, I'm looking for a way to find out the ctermfg
/bg
and guifg
/bg
for certain stuff. Right now the statusline. :)
EDIT 2:
Apparently if I do :hi StatusLine
I get what I need, however I need to refine it to get only the value, and not all of it. Guess I'll have to use some regex to find out the value. If anybody knows an easier way please share it (or if you already figured it out with the regex). Thanks!
You can use the synIDattr()
function to query the various attributes (like foreground and background color) of syntax highlighting. To determine the ID of the highlight group, hlID()
can be used. See :help hlID()
:
:echo synIDattr(synIDtrans(hlID('StatusLine')), 'fg')