:echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
"fg" foreground color (GUI: color name used to set the color, cterm: color number as a string, term: empty string),"bg" is the background color (for example, with "fg").
More details
source share