about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Backx <andreas@backx.org>2023-05-21 16:25:47 +0100
committerAndreas Backx <andreas@backx.org>2023-05-21 17:34:42 +0100
commit09f624721cf1ea250aff6b76b465dfbc5c64bc56 (patch)
tree4a7e4518320f14b4fd2c89c8db9419c371330d38
parenta04d8456be1d289c814846178cc1ff63b4fc297b (diff)
downloadrust-09f624721cf1ea250aff6b76b465dfbc5c64bc56.tar.gz
rust-09f624721cf1ea250aff6b76b465dfbc5c64bc56.zip
[editors/code] add markdown syntax highlighting to doc comments
-rw-r--r--editors/code/package.json10
-rw-r--r--editors/code/rustdoc.markdown.injection.tmGrammar.json36
2 files changed, 46 insertions, 0 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index b4620243c9f..96d63b42393 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -1562,6 +1562,16 @@
                 "language": "ra_syntax_tree",
                 "scopeName": "source.ra_syntax_tree",
                 "path": "ra_syntax_tree.tmGrammar.json"
+            },
+            {
+                "scopeName": "rustdoc.markdown.injection",
+                "path": "rustdoc.markdown.injection.tmGrammar.json",
+                "injectTo": [
+                    "source.rust"
+                ],
+                "embeddedLanguages": {
+                    "meta.embedded.block.markdown": "text.html.markdown"
+                }
             }
         ],
         "problemMatchers": [
diff --git a/editors/code/rustdoc.markdown.injection.tmGrammar.json b/editors/code/rustdoc.markdown.injection.tmGrammar.json
new file mode 100644
index 00000000000..3ee49bff31e
--- /dev/null
+++ b/editors/code/rustdoc.markdown.injection.tmGrammar.json
@@ -0,0 +1,36 @@
+{
+    "scopeName": "rustdoc.markdown.injection",
+    "injectionSelector": "L:source.rust",
+    "patterns": [
+        {
+            "include": "#doc-comment-line"
+        },
+        {
+            "include": "#doc-comment-block"
+        }
+    ],
+    "repository": {
+        "doc-comment-line": {
+            "name": "comment.line.documentation.rust",
+            "begin": "^\\s*//(/|!)",
+            "while": "^\\s*//(/|!)",
+            "contentName": "meta.embedded.block.markdown",
+            "patterns": [
+                {
+                    "include": "text.html.markdown"
+                }
+            ]
+        },
+        "doc-comment-block": {
+            "name": "comment.block.documentation.rust",
+            "begin": "/\\*(\\*|!)",
+            "end": "\\s*\\*/",
+            "contentName": "meta.embedded.block.markdown",
+            "patterns": [
+                {
+                    "include": "text.html.markdown"
+                }
+            ]
+        }
+    }
+}