Exclude only named children without injection.include-children#3129
Conversation
|
If you want a node from the tree to be queryable, it should be named: that's the point of named nodes. I think you should restructure the grammar to expose the nodes you want to capture in queries. I can't test this at the moment but I suspect this breaks injections for some templating languages or maybe Rust macros? I'll give it a look when I have a chance |
That's my point. I expose Also notice how not excluding unnamed nodes is strictly more expressive. In a tree-sitter grammar an unnamed node can always be turned into a named one with
I'm gonna have a look myself too. If that's the case and the queries can't easily be changed to work with the new behavior: how do you feel about adding a |
|
It seems you're right. Many languages rely on excluding unnamed nodes for injecting the |
|
A separate property like include-unnamed sounds like a good addition to me 👍 |
574fac3 to
d32deb1
Compare
the-mikedavis
left a comment
There was a problem hiding this comment.
This looks good, thanks for working on it 👍
…-editor#3129) * Exclude only named children without injection.include-children * Add injection.include-unnamed-children parameter
This fixes problems arising in #3108.
The markdown parser needs to exclude children for language injection, but only named ones. This is different from the behavior in tree-sitter-highlight, but to me it seems more sensible.
To give a technical example: Otherwise there is almost no way to write something like
where
$._contentand the parentheses should be included and$.excludedexcluded. This is because there will always be'('and')'nodes as a child ofrule.