Make language injections easier by making nodes anonymous #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Without
heredoc_line
andshell_fragment
being present in a tree it's much easier to add language injections, for example, with bash:With the way it's implemented right now it doesn't seem to be possible to do these kinds of injections correctly. There is a Neovim issue with a bit more details for
shell_command
injections nvim-treesitter/nvim-treesitter#6530Here are the injections used at the moment in nvim-treesitter:
There doesn't seem to be a better way to "join"
shell_fragment
nodes than usinginjection.combined
, which isn't quite great since it treats all of the scripts in the whole dockerfile as a single large script, breaking highlighting in a weird way. With these changes everyRUN
/CMD
/ENTRYPOINT
instruction can be injected independently, but without splitting it into different chunks betweenline_continuation
nodes.For heredoc,
include-children
is needed to highlight allheredoc_line
nodes, but it also includesheredoc_end
node, which isn't quite right. Injecting every heredoc asbash
is not itself correct though, but that's a different issue I think.Thanks for maintaining this project! 👍