Understanding treesitter highlight groups

When I check the tree-sitter highlight groups with :Inspect I often see two different paths listed, for example @function.macro and @variable. I don’t know what this means, I suppose maybe it means there is a variable leaf inside a macro branch or something like that. Anyway, only the last listed highlight group is actually applied to text. This can be infuriating: it’s often not what I want and nothing I do seems to change it. It seems there is no way to specify a highlight group for say the intersection of two of these.

Is there any way to set the highlighting based on the full list given by :Inspect, or are you just completely hosed unless the treesitter is updated?

I’m curious if you ever figured this out. I believe the multi-entry response from :Inspect is indeed about nesting of nodes. :InspectTree is also useful in this case, although the node names that it shows are not highlight group names. I suspect you’d have to dig into the actual treesitter syntax files to check the mappings. I doubt that setting the highlight based on the full :Inspect response works; as you discovered, it is probably showing the group names from most generic to most specific (in whatever way the treesitter syntax file maintainer designed).

For what it’s worth, I’m also not entirely happy with the loss of configurability that the treesitter highlighting system brings. There are many more highlight groups for colorscheme maintainers to define, which I guess is justified (?) by having more semantically acurate highlight definitions. On top of that we have this complex logic for syntax → highlight group mappings. On the one hand, most of the time it “just works” and looks better (?) than the regex-based approach, but on the other – it is harder to customize.

But I could be wrong, I didn’t go too deep into treesitter stuff, only enough to update my own colorscheme to support the new base groups.

Not really. Treesitter still seems extremely mysterious to me, the ratio of how interested I am in it to how complicated it is is too small for me to ever understand it.