Is it possible to highlight the background differently for a Tree Sitter injected language?

I have enabled a basic language injection for Vimscript in Lua (credit to @tami6:matrix.org for the idea):

((function_call
   (field_expression) @_vim_cmd
   (arguments (string) @vim))
 (#eq? @_vim_cmd "vim.cmd"))

Is it possible to assign a special highlight group only to this injected part? I want to give the embedded Vimscript a slight gray background, to distinguish it from the surrounding Lua.

Current output (default color scheme, light background):

I want to add a special highlight group to the Vimscript inside vim.cmd [[ ... ]], so I can create visual separation from the rest of the file.

Hey, that’s some nice tricks that you show here, and I think that we can include that in nvim-treesitter btw.

Regarding the colorof the background, I don’t think we have a proper way to change that now, appart (maybe) from something that bfredl did for dynamic themes. I’ll see how we can hack that on and come back to you when I have a solution for this !

Don’t get too eager :laughing: I just had to disable this because of what (I think) is a mutual and infinite recursion between a Lua injection in the Vimscript queries. Making a minimal reproducing config and filing a bug report is on my to-do list.

something that bfredl did for dynamic themes

Do you have a link to this? I assume it uses extmarks?