-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support combined injections #1378
Comments
This stems from a hack in
helix/helix-core/src/syntax.rs Lines 1111 to 1157 in a4641a8
But this is sidestepped for the root layer: helix/helix-core/src/syntax.rs Lines 492 to 511 in a4641a8
So combined injections only work on nested grammars. |
I'm working on a rewrite that will be able to incrementally update all the layers. This should resolve this issue (and #1151) |
(Work is ongoing in https://github.com/helix-editor/helix/tree/incremental) |
Merged into master in 7c9ebd0 ! Would you be interested in adding https://github.com/tree-sitter/tree-sitter-embedded-template & eex now? |
(H)eex still has some bugs in my local testing (unrelated to combined injections, needs a fix in the elixir grammar) but embedded-template should be good to go. The only weird thing with it currently has injections for different languages so the one grammar is used for erb and ejs with different injections queries between them https://github.com/tree-sitter/tree-sitter-embedded-template/tree/d21df11b0ecc6fd211dbe11278e92ef67bd17e97/queries is there a way to specify a config like this in |
I should be able to add https://github.com/elixir-lang/tree-sitter-iex though which is perfect for combined injections |
The combined injections work quite well so I'm gonna close this out. Thanks @archseer!! |
I think we chatted about this on the matrix a while back. I wanted to make an issue just to make sure it doesn't get lost.
There are a few grammars that would benefit from being able to combine the injections. Mostly it's templating languages like heex (#881) or tree-sitter-embedded-template (erb and some js templates), but also now git-diff (#1373) (which I wrote as a line-based grammar so it would work out-of-the-box without combined injections).
What are combined injections?...
From the tree-sitter docs:
So you can write a query in a language's
injections.scm
that does a(#set! injection.combined)
, and all matching nodes will be parsed together.As a practical example, the git-commit grammar would parse a document like this one:
like so:
And if you had an
injections.scm
like so:Then the
message
nodes would be parsed as if they were one continuousmessage
node spanning multiple lines. This ends up being important for template languages which usually have control flow spanning multiple nodes, like so:Here the two directive nodes need to be combined for the contained do-end block to be parsed as a pair.
I'm interested in taking a stab at this but I don't really know where to begin. I suspect I probably don't have the rust chops to take this on :P
The text was updated successfully, but these errors were encountered: