Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/markdown-rustdoc/injections.scm')
-rw-r--r--runtime/queries/markdown-rustdoc/injections.scm25
1 files changed, 25 insertions, 0 deletions
diff --git a/runtime/queries/markdown-rustdoc/injections.scm b/runtime/queries/markdown-rustdoc/injections.scm
new file mode 100644
index 00000000..0778125c
--- /dev/null
+++ b/runtime/queries/markdown-rustdoc/injections.scm
@@ -0,0 +1,25 @@
+; inherits: markdown
+
+; In Rust, it is common to have documentation code blocks not specify the
+; language, and it is assumed to be Rust if it is not specified.
+
+(fenced_code_block
+ (code_fence_content) @injection.content
+ (#set! injection.language "rust")
+ (#set! injection.include-unnamed-children))
+
+(fenced_code_block
+ (info_string
+ (language) @injection.language)
+ (code_fence_content) @injection.content (#set! injection.include-unnamed-children))
+
+(fenced_code_block
+ (info_string
+ (language) @__language)
+ (code_fence_content) @injection.content
+ ; list of attributes for Rust syntax highlighting:
+ ; https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#attributes
+ (#match? @__language
+ "(ignore|should_panic|no_run|compile_fail|standalone_crate|custom|edition*)")
+ (#set! injection.language "rust")
+ (#set! injection.include-unnamed-children))