Open
Description
This is meant to be a tracking issue for taking injections into account for all tree-sitter features. There are three separate APIs we need to use injections robustly:
- Run queries across injection layers. Highlights do this correctly but indent and textobject queries currently run only against the root layer. Run textobject queries across injections #9320 will add the necessary API here which indents can build off of.
- Operate on the proper
tree_sitter::Tree
of the layer the input positions/bytes are within. Callers currently useSyntax::tree
, so they only operate on the root. This is a little broad but Select subtree within injections in:tree-sitter-subtree
#9309 initially added the function to make this possible, Respect injections when using the syntax tree's root node #9424 and Cross injection layers in tree-sitter motions #5176 improve the situation, and ultimately this will be fixed once we update the indentation system to respect injection layers. ThenSyntax::tree
should be removed. - Use the language configuration for the layer the input positions/bytes are within. This applies to things like auto-pairs and comment tokens, for example Determine comment tokens from injection layers #7364. We don't have an API for this yet but see Determine comment tokens from injection layers #7364 (comment) for an outline on how it should work.
Feature-wise:
- highlights
- textobjects (Run textobject queries across injections #9320)
- indents (Use configured indent-style from language within language blocks #13337)
- comment tokens
- auto-pairs
-
:reflow
text-width - bracket matching (Respect injections when using the syntax tree's root node #9424)
- tree-sitter motions
A-p
/A-o
/A-i
/A-n
(Cross injection layers in tree-sitter motions #5176) -
:tree-sitter-subtree
(Select subtree within injections in:tree-sitter-subtree
#9309) -
:tree-sitter-highlight-name
(Respect injections when using the syntax tree's root node #9424) -
move_parent_node_start
/move_parent_node_end
(Respect injections when using the syntax tree's root node #9424)
The changes build on one another somewhat, so we will need to wait until the changes for the first API and the third API are merged in order to fix indentation.