Extending injections for first and third party syntax extensions?

Hi

Before tree-sitter I had this feature request which is now sort of technically possible to implement.

But is there a way for us to extend the injections for the core syntaxes as well as the third party syntaxes?

To give an example, please consider this:

<div x-data="javascript">

In Neovim you can just extend the html injections, and add your own on the top it. Of course that editor is very customisable, and requires each user getting their hands dirty, changing the queries in the tree-sitter-html folder manually.

Here is an example for, how one can add that injection support that works across the board.

;; extends

; AlpineJS attributes
(attribute
  (attribute_name) @_attr
    (#lua-match? @_attr "^x%-%l")
  (quoted_attribute_value
    (attribute_value) @injection.content)
  (#set! injection.language "javascript"))

Correct me if I am wrong, but reading the documentations, I don’t think this is currently possibly? there is no way for us to tell Nova, the injection.scm written in Queries/ folder for this extension, is for html syntax or any other languages.

So in summary, basically what I ideally want to be able to do is the following in the AlpineJS extension which is a "completion extension "and NOT a “syntax extension”:

  1. write a injection.scm into my Queries/ folder
  2. Somehow tell Nova, “extend the injections for the html files with the injection.scm (or any other syntaxes)”

Thanks
Emran

I would like to add a correction to this “Feature Request”.

After a discussion with a seasoned NeoVim user, I realised this statement was wrong

In Neovim you can just extend the html injections, and add your own on the top it. Of course that editor is very customisable, and requires each user getting their hands dirty, changing the queries in the tree-sitter-html folder manually.

The actual installed parsers are never touched! The “extended queries live in the NeoVim runtime path”, which is an after/ folder, for example ~/.config/nvim/after/queries/html/injections.scm. Basically the user can add their own queries in this folder, to add or override the provided queries by the parser.

It would actually be very handy if Nova supports a similar feature. maybe a subfolder with the name of the parser in the Queries, that would add on top of the built-in parser

Here is an example of why this feature is required and is already supported in NeoVim. This allows new injection areas to be added semantically and extremely valuable when it comes to implementing injections for frameworks.