In putting together and addon for blender to integrate neovim.

enter image description here Where I'm at with it, github colo imported to blender text editor from nvim_gtk

One component is grabbing the current colorscheme of a running vim and importing it into blender's text editor theme.

So far I have some re code that looks at the return of hi and follows links if need be till I get a guifg or guibg

# vim is a pynvim.api.nvim.Nvim object
vim_color = vim.command_output(f"highlight {g}")

which for g = "pythonBuiltin" returns

pythonBuiltin xxx links to GruvboxOrange

and so on

GruvboxOrange xxx ctermfg=208 guifg=#fe8019

in which case I can get the RGB colour for blender from the hex. Other colour codes not so easy. And the code is getting unwieldly.

Could you point me to a more direct way, possibly a plugin, to get the RGB value of a highlight?

2 Answers 2


Consider using the synIDattr() function, which can take special attributes such as fg# and bg# to return RGB for attributes, when a GUI is running.

"fg#"   like "fg", but for the GUI and the GUI
        is running the name in "#RRGGBB" form
"bg#"   like "fg#" for "bg"
"sp#"   like "fg#" for "sp"

The first argument to this function is a numeric {synID}, if you have a file styled with syntax elements you can look up the id from a specific position in the file.

If you want to find all syntax groups, then perhaps you could iterate them starting from 1 and looking up the name with synIDattr(..., 'name') to build a full map from name to RGB attributes.

For instance, to get the RGB for the foreground color of pythonComment, you can use the following command:

echo synIDattr(synIDtrans(hlID("pythonComment")), "fg#")
  • 1
    You bloody beauty. I had begun recreating the wheel. So easy to find when you know where to look,... the answers pop strait from the docs :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg#") Thankyou that works like a treat!!!
    – batFINGER
    Jul 28, 2019 at 3:14
  • I'm glad this helped! I happened to be in fact looking at something similar earlier this week (debugging syntax, so looking at how to see highlight group for a position) so I stared at these docs for a while. Good luck with your blender integration!
    – filbranden
    Jul 28, 2019 at 3:28
  • 1
    This has got it echo synIDattr(synIDtrans(hlID("pythonComment")), "fg#")
    – batFINGER
    Jul 28, 2019 at 7:08
  • I didn't know about hlID(), so glad I learned it from this question, thanks for that! Incorporated it into the answer.
    – filbranden
    Jul 28, 2019 at 11:31

I don't know about any plugins for this but it should be easy to code up lookup tables for the other codes.

The decimal numbers, like 208 in your example, are 256-color palette codes. It's easy to find translations to/from hex code. Like the top of the google search for 256 color to hex.

The spelled-out colors (e.g. DarkSeaGreen4) are system dependent. You didn't mention what system you're using, I don't think. But for *nix that same translation page includes spelled colors, too.. For windows start with :h win32-colors and go from there.

  • On Ubuntu. Thanks. I was afraid it would come down to LUTs. ... so I'm going to be slow about accepting that fate lol. Find using matplotlib.colors methods covers most named colors eg these but will need to delve into what, for example LUT 4 represents . Was hoping there may be some sneaky way to get a rgb from a "live" hightlight.
    – batFINGER
    Jul 28, 2019 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.