Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'book/src/guides/injection.md')
| -rw-r--r-- | book/src/guides/injection.md | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/book/src/guides/injection.md b/book/src/guides/injection.md index c94dadba..18c474cf 100644 --- a/book/src/guides/injection.md +++ b/book/src/guides/injection.md @@ -1,19 +1,14 @@ -## Adding Injection Queries +# Adding Injection Queries Writing language injection queries allows one to highlight a specific node as a different language. -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. -An example of a simple query that would highlight all strings as bash in Nix: +And example of a simple query that would highlight all strings as bash in Nix: ```scm ((string_expression (string_fragment) @injection.content) (#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 @@ -59,7 +54,4 @@ The first argument (a capture) must be equal to the second argument The first argument (a capture) must match the regex given in the second argument (a string). -- `#any-of?` (standard): -The first argument (a capture) must be one of the other arguments (strings). - -[upstream-docs]: https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#language-injection +[upstream-docs]: http://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection |