I'm working on adding an automatic highlight for my current line in Vim, that matches the current mode color used in the status line. So far I haven't had much success if finding a way to get what that current color is.
The colors for the status line are being set based on the current theme, so I'd rather set my current line color dynamically rather than hard coding it.
For example, a few of my mode colors are:
Normal = Blue
Insert = Green
Visual = Red
I'd like to be able to retrieve the exact color codes used for those highlights from the current theme, so that I can set up a few simple autocommands to use them for mode switches.
Is there a way to easily retrieve these colors?
You can query the colors and attributes of a highlight group via synIDattr()
; you can find an example at :help hlID()
.
If you intend to use the cursorline feature and have a single-colored statusline that gets its StatusLine
highlight group changed dynamically by autocmds, simply linking both (:hi link CursorLine StatusLine
) might already work.
PS: I personally would find it highlight confusing if the same colored line could either represent the current line or one of the horizontal separators between windows, but your mileage obviously varies...