How do I see exactly which highlight groups are responsible for the color of the character under the cursor in Neovim?
Answer
:Inspect
Explanation
When customizing a colorscheme or debugging unexpected syntax colors, it's difficult to know which highlight group to override. Neovim 0.9+ provides :Inspect, which opens a floating window listing every highlight layer stacked on the character under the cursor — treesitter captures, legacy syntax groups, LSP semantic tokens, and any extmark-based highlights — along with their resolved colors and where they come from.
How it works
Position the cursor on any character and run :Inspect. Neovim shows a popup like:
Treesitter
@function.call → Function guifg=#82aaff
Syntax
Function
Identifier
Each layer is listed with its priority. The winning group (the one actually rendered) appears at the top. Linked highlight groups show the chain: @function.call → Function means @function.call links to the built-in Function group.
Example workflow
If a keyword looks the wrong color:
- Move the cursor onto the keyword
- Run
:Inspect - Note the top highlight group — e.g.,
@keyword.returnlinked toStatement - Override in your config:
:highlight @keyword.return guifg=#ff9e64
Tips
- Pair with
:InspectTreeto see the full treesitter parse tree and understand which node type generated the highlight - For scripting equivalents in older Vim/Neovim, use
synID(),synIDtrans(), andsynIDattr()to query highlight info programmatically :Inspectworks even for highlights applied by LSP (semantic tokens) which are invisible to:syntax list- This command is available in Neovim 0.9+ only; classic Vim does not have it