Skip to content

Respect injections in tree-sitter features #9425

Open
@the-mikedavis

Description

@the-mikedavis

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:

  1. 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.
  2. Operate on the proper tree_sitter::Tree of the layer the input positions/bytes are within. Callers currently use Syntax::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. Then Syntax::tree should be removed.
  3. 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:

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions