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 | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/book/src/guides/injection.md b/book/src/guides/injection.md index c94dadba..0a1d2c9a 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 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 @@ -62,4 +57,4 @@ 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 |