I totally understand what you mean, or trying to do. Unfortunately it is the Nova API shortcoming … which is quite frustrating.
As you said easily achieved in VS Code. But having said that, IF Nova implements this, the Tree-Sitter is far more superior
To clear up the confusion, let me expand a bit more.
With markdown, the injection node is defined by the grammar, under
$.fenced_code_block_delimiter [It is defined as an external scanner it is not part of
As it is fundamental part of markdown, of course it makes sense to be part of the grammar.
Now that we have the facility. The injection happens sort of dynamic like this after capturing the node’s content. again defined in the markdown
; Fenced code blocks
(info_string (language) @injection.language)
Now in your case, this means, sending pull request to every single
tree-sitter repo and ask them to define
/*! */ or
<pre> in their grammar which is not practical… and to be honest not the best way anyways.
For example AlpineJS is used by many other frameworks, or even stand-alone. Rather than me changing the base
tree-sitter-html or any other framework, to define the
x-whatever and then inject JS inside it, Nova should give us a facility to “extend the injections” for the
html. Which is exactly what you need. The ability to extend the injection for
html or any language you want to implement your functionality.
To give you a concrete example of the end result, here is how it can be achieved in NeoVim. As the guts are out and ready for manipulation, here is how one user managed to get the AlpineJS injection working in any framework, language, basically everywhere that is being parsed as
html. But that meant him manually changing content of the
Look at the code example under “AlpineJS injection”. They are basically saying, in html if the attribute name is such and such, treat it’s attribute value’s content as
In your case you are doing the exact same thing, if it was allowed by Nova.
- grab the
$.tag_name and check if it is
- Somehow grab the first word that follows
- This might be your biggest hurdle. As when you write:
- The whole
html+content are grabbed as ONE node called
- Not sure if you can grab the first-word pre space/newline/tab using the tree-sittter query capture and then apply the language.
- Use whatever language captured, as an injected language, inside the
It is geniunely a valid request you have but, for some reason our hands are tight, and a bit more complicated than it needs to be… If supported it will give us all a super power though.
As long as I know, injections were a pain, in any code editor I have ever worked in with… we are so close to nailing it, with tree-sitter though. This is the best and closest we have been in fixing the injection hell!