docs: another injection query example (#13312)

pull/13310/head
Niklas Gruhn 2025-04-09 14:30:11 +02:00 committed by GitHub
parent d24e4fcf0f
commit 8b952bb1d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -4,11 +4,16 @@ Writing language injection queries allows one to highlight a specific node as a
In addition to the [standard][upstream-docs] language injection options used by tree-sitter, there In addition to the [standard][upstream-docs] language injection options used by tree-sitter, there
are a few Helix specific extensions that allow for more control. are a few Helix specific extensions that allow for more control.
And example of a simple query that would highlight all strings as bash in Nix: An example of a simple query that would highlight all strings as bash in Nix:
```scm ```scm
((string_expression (string_fragment) @injection.content) ((string_expression (string_fragment) @injection.content)
(#set! injection.language "bash")) (#set! injection.language "bash"))
``` ```
Another example is this query, which highlights links in comments and keywords like "TODO", by reusing the dedicated "comment" language:
```
((comment) @injection.content
(#set! injection.language "comment"))
```
## Capture Types ## Capture Types