How do I know the specific color value that the current color scheme uses for certain things?

I need this to finish the plugin that I am doing to change the colors of the status line depending on the mode.

However, I ran into an obvious problem, how do I know which topic the user is using? And even if I knew that I could not create specific colors for each topic.

So, how do you know the foreground and background colors used by the current theme for the status line, for example.

EDIT 1:

If I wasn’t clear, I’m looking for a way to find out ctermfg / bg and guifg / bg for certain things. Right now the status line. :)

EDIT 2:

Apparently, if I do :hi StatusLine , I get what I need, however I need to refine it to get only the value, not all. I think I will have to use some regular expression to find out the meaning. If anyone knows a simpler way, share it (or if you already understood this with a regex). Thanks!

+6
source share
2 answers

You can use the synIDattr() function to request various attributes (for example, foreground and background colors) of syntax highlighting. To determine the identifier of the highlighted group, you can use hlID() . See :help hlID() :

 :echo synIDattr(synIDtrans(hlID('StatusLine')), 'fg') 
+11
source

You can get the background with

 :echo &background 

according to :help background should be a foreground parameter, but it does not work for me.

Edit: There are guibg , guifg , ctermbg and ctermfg in :hi[glight]

+1
source

All Articles