Need suggestions on how to define custom treesitter highlight group

Hi, everyone.

I would like to define a highlight group that appears whenever there’s a @comment which contains the pattern ⤚*⤙, the highlight would only affect what is contained inside this pattern.
Initially I did:

highlight @commentedtopics guifg=red
syntax region @commentedtopics start="⤚" end="⤙"

This doesn’t work because treesitter overrides this pattern (and also doesn’t consider whether it’s inside a @comment or not).

From what I have read, I would need to create ~/.config/nvim/after/queries/filetype/highlights.scm for each filetype I intend to use my highlight, but I want to apply this thing globally.

Anyone knows how I can have a highlight that activates only when contained inside a @comment through treesitter?


Install the comment parser and add the custom query for that.

(You can’t mix and match syntax and @foo treesitter highlight groups.)