From d22240591c2accdc94de466f7352ee56c399a796 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 27 Jul 2020 17:38:32 -0500 Subject: [PATCH] Docs: document the `set!` predicate I was looking for something like this, I searched the documentation, but I found it in https://github.com/tree-sitter/tree-sitter-javascript/blob/master/queries/injections.scm#L15 --- docs/section-4-syntax-highlighting.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/section-4-syntax-highlighting.md b/docs/section-4-syntax-highlighting.md index 0182704b..cbf97b66 100644 --- a/docs/section-4-syntax-highlighting.md +++ b/docs/section-4-syntax-highlighting.md @@ -385,6 +385,14 @@ The following query would specify that the contents of the heredoc should be par (heredoc_end) @injection.language) @injection.content ``` +You can also force the language using the `#set!` predicate. +For example, this will force the language to be always `ruby`. + +``` +((heredoc_body) @injection.content + (#set! injection.language "ruby")) +``` + ## Unit Testing Tree-sitter has a built-in way to verify the results of syntax highlighting. The interface is based on [Sublime Text's system](https://www.sublimetext.com/docs/3/syntax.html#testing) for testing highlighting.