From 0380d982f9cf6cd49de3ea009f37bdc18e30e81f Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 10 Jan 2024 21:55:41 +0800 Subject: [PATCH 1/5] highlight rustdoc --- .../code/language-configuration-rustdoc.json | 54 +++++++++++ editors/code/package.json | 28 ++++++ editors/code/rustdoc-inject.json | 93 +++++++++++++++++++ editors/code/rustdoc.json | 82 ++++++++++++++++ 4 files changed, 257 insertions(+) create mode 100644 editors/code/language-configuration-rustdoc.json create mode 100644 editors/code/rustdoc-inject.json create mode 100644 editors/code/rustdoc.json diff --git a/editors/code/language-configuration-rustdoc.json b/editors/code/language-configuration-rustdoc.json new file mode 100644 index 000000000000..d7cbf2a0d24c --- /dev/null +++ b/editors/code/language-configuration-rustdoc.json @@ -0,0 +1,54 @@ +{ + "comments": { + "blockComment": [ + "" + ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "colorizedBracketPairs": [ + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" + }, + { + "open": "[", + "close": "]" + }, + { + "open": "(", + "close": ")" + }, + { + "open": "<", + "close": ">", + "notIn": [ + "string" + ] + } + ], + "surroundingPairs": [ + ["(", ")"], + ["[", "]"], + ["`", "`"], + ["_", "_"], + ["*", "*"], + ["{", "}"], + ["'", "'"], + ["\"", "\""] + ], + "folding": { + "offSide": true, + "markers": { + "start": "^\\s*", + "end": "^\\s*" + } + }, + "wordPattern": { "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", "flags": "ug" }, +} diff --git a/editors/code/package.json b/editors/code/package.json index 8307f6833e6f..351370a09673 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -1729,6 +1729,13 @@ "rs" ], "configuration": "language-configuration.json" + }, + { + "id": "rustdoc", + "extensions": [ + ".rustdoc" + ], + "configuration": "./language-configuration-rustdoc.json" } ], "grammars": [ @@ -1736,6 +1743,27 @@ "language": "ra_syntax_tree", "scopeName": "source.ra_syntax_tree", "path": "ra_syntax_tree.tmGrammar.json" + }, + { + "language": "rustdoc", + "scopeName": "text.html.markdown.rustdoc", + "path": "rustdoc.json", + "embeddedLanguages": { + "meta.embedded.block.html": "html", + "meta.embedded.block.markdown": "markdown", + "meta.embedded.block.rust": "rust" + } + }, + { + "injectTo": [ + "source.rust" + ], + "scopeName": "comment.markdown-cell-inject.rustdoc", + "path": "rustdoc-inject.json", + "embeddedLanguages": { + "meta.embedded.block.rustdoc": "rustdoc", + "meta.embedded.block.rust": "rust" + } } ], "problemMatchers": [ diff --git a/editors/code/rustdoc-inject.json b/editors/code/rustdoc-inject.json new file mode 100644 index 000000000000..45ca2fa96bc2 --- /dev/null +++ b/editors/code/rustdoc-inject.json @@ -0,0 +1,93 @@ +{ + "injectionSelector": "L:source.rust -string -comment -meta.embedded.block.rustdoc.md", + "patterns": [ + { + "include": "#triple-slash" + }, + { + "include": "#double-slash-exclamation" + }, + { + "include": "#slash-start-exclamation" + }, + { + "include": "#slash-double-start" + } + ], + "repository": { + "triple-slash": { + "begin": "(^|\\G)\\s*(///) ?", + "captures": { + "2": { + "name": "comment.line.double-slash.rust" + } + }, + "name": "comment.quote_code.triple-slash.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(///) ?" + }, + "double-slash-exclamation": { + "begin": "(^|\\G)\\s*(//!) ?", + "captures": { + "2": { + "name": "comment.line.double-slash.rust" + } + }, + "name": "comment.quote_code.double-slash-exclamation.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(//!) ?" + }, + "slash-start-exclamation": { + "begin": "(^)(/\\*!) ?$", + "captures": { + "2": { + "name": "comment.block.rust" + } + }, + "name": "comment.quote_code.slash-start-exclamation.rust", + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "end": "( ?)(\\*/)" + }, + "slash-double-start": { + "name": "comment.quote_code.slash-double-start-quote-star.rust", + "begin": "(?:^)\\s*/\\*\\* ?$", + "end": "\\*/", + "patterns": [ + { + "include": "#quote-star" + } + ] + }, + "quote-star": { + "begin": "(^|\\G)\\s*(\\*(?!/)) ?", + "captures": { + "2": { + "name": "comment.punctuation.definition.quote_code.slash-star.MR" + } + }, + "contentName": "meta.embedded.block.rustdoc", + "patterns": [ + { + "include": "text.html.markdown.rustdoc" + } + ], + "while": "(^|\\G)\\s*(\\*(?!/)) ?" + } + }, + "scopeName": "comment.markdown-cell-inject.rustdoc" +} \ No newline at end of file diff --git a/editors/code/rustdoc.json b/editors/code/rustdoc.json new file mode 100644 index 000000000000..230d2de1cfac --- /dev/null +++ b/editors/code/rustdoc.json @@ -0,0 +1,82 @@ +{ + "name": "rustdoc", + "patterns": [ + { + "include": "#fenced_code_block" + }, + { + "include": "#markdown" + } + ], + "scopeName": "text.html.markdown.rustdoc", + "repository": { + "markdown":{ + "patterns": [ + { + "include": "text.html.markdown" + } + ] + }, + "fenced_code_block":{ + "patterns": [ + { + "include": "#fenced_code_block_rust" + }, + { + "include": "#fenced_code_block_unknown" + } + ] + }, + "fenced_code_block_rust": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(rust|not run|not_run)?((\\s+|:|,|\\{|\\?)[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.rust", + "patterns": [ + { + "include": "source.rust" + } + ] + } + ] + }, + "fenced_code_block_unknown": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?=([^`~]+)?$)", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language" + } + }, + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "name": "markup.fenced_code.block.markdown" + } + } +} \ No newline at end of file From 1040c0091e40e1e2e9131ceda62ad885dbbcf55f Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Tue, 16 Jan 2024 21:20:22 +0800 Subject: [PATCH 2/5] reformat --- .../code/language-configuration-rustdoc.json | 30 ++++--------------- editors/code/rustdoc.json | 4 +-- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/editors/code/language-configuration-rustdoc.json b/editors/code/language-configuration-rustdoc.json index d7cbf2a0d24c..a1d2a90aeacb 100644 --- a/editors/code/language-configuration-rustdoc.json +++ b/editors/code/language-configuration-rustdoc.json @@ -1,9 +1,6 @@ { "comments": { - "blockComment": [ - "" - ] + "blockComment": [""] }, "brackets": [ ["{", "}"], @@ -13,25 +10,10 @@ "colorizedBracketPairs": [ ], "autoClosingPairs": [ - { - "open": "{", - "close": "}" - }, - { - "open": "[", - "close": "]" - }, - { - "open": "(", - "close": ")" - }, - { - "open": "<", - "close": ">", - "notIn": [ - "string" - ] - } + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "<", "close": ">", "notIn": [ "string" ] } ], "surroundingPairs": [ ["(", ")"], @@ -50,5 +32,5 @@ "end": "^\\s*" } }, - "wordPattern": { "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", "flags": "ug" }, + "wordPattern": { "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", "flags": "ug" } } diff --git a/editors/code/rustdoc.json b/editors/code/rustdoc.json index 230d2de1cfac..a149af47efdc 100644 --- a/editors/code/rustdoc.json +++ b/editors/code/rustdoc.json @@ -10,14 +10,14 @@ ], "scopeName": "text.html.markdown.rustdoc", "repository": { - "markdown":{ + "markdown": { "patterns": [ { "include": "text.html.markdown" } ] }, - "fenced_code_block":{ + "fenced_code_block": { "patterns": [ { "include": "#fenced_code_block_rust" From 32a140944f60671d60a2959ee991274ea8c6d145 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Tue, 16 Jan 2024 23:46:59 +0800 Subject: [PATCH 3/5] add files to .vscodeignore --- editors/code/.vscodeignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editors/code/.vscodeignore b/editors/code/.vscodeignore index 09dc27056b37..5c48205694fe 100644 --- a/editors/code/.vscodeignore +++ b/editors/code/.vscodeignore @@ -12,3 +12,6 @@ !ra_syntax_tree.tmGrammar.json !server !README.md +!language-configuration-rustdoc.json +!rustdoc-inject.json +!rustdoc.json From d24db9f2c394c9b558908dd832fbe9be26c24a85 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 12 Feb 2024 15:58:17 +0100 Subject: [PATCH 4/5] Run npm run format --- editors/code/language-configuration-rustdoc.json | 10 ++++++---- editors/code/rustdoc-inject.json | 2 +- editors/code/rustdoc.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/editors/code/language-configuration-rustdoc.json b/editors/code/language-configuration-rustdoc.json index a1d2a90aeacb..8474180e7b0f 100644 --- a/editors/code/language-configuration-rustdoc.json +++ b/editors/code/language-configuration-rustdoc.json @@ -7,13 +7,12 @@ ["[", "]"], ["(", ")"] ], - "colorizedBracketPairs": [ - ], + "colorizedBracketPairs": [], "autoClosingPairs": [ { "open": "{", "close": "}" }, { "open": "[", "close": "]" }, { "open": "(", "close": ")" }, - { "open": "<", "close": ">", "notIn": [ "string" ] } + { "open": "<", "close": ">", "notIn": ["string"] } ], "surroundingPairs": [ ["(", ")"], @@ -32,5 +31,8 @@ "end": "^\\s*" } }, - "wordPattern": { "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", "flags": "ug" } + "wordPattern": { + "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", + "flags": "ug" + } } diff --git a/editors/code/rustdoc-inject.json b/editors/code/rustdoc-inject.json index 45ca2fa96bc2..7a4498fea9d0 100644 --- a/editors/code/rustdoc-inject.json +++ b/editors/code/rustdoc-inject.json @@ -90,4 +90,4 @@ } }, "scopeName": "comment.markdown-cell-inject.rustdoc" -} \ No newline at end of file +} diff --git a/editors/code/rustdoc.json b/editors/code/rustdoc.json index a149af47efdc..cecfae9d753e 100644 --- a/editors/code/rustdoc.json +++ b/editors/code/rustdoc.json @@ -79,4 +79,4 @@ "name": "markup.fenced_code.block.markdown" } } -} \ No newline at end of file +} From c6bb35269c1fe4adc60cbfdab1cc819ba4cb35cf Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 12 Feb 2024 16:01:14 +0100 Subject: [PATCH 5/5] Remove autoclosing pair <> in rustdoc --- editors/code/language-configuration-rustdoc.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editors/code/language-configuration-rustdoc.json b/editors/code/language-configuration-rustdoc.json index 8474180e7b0f..c905d3b60674 100644 --- a/editors/code/language-configuration-rustdoc.json +++ b/editors/code/language-configuration-rustdoc.json @@ -11,8 +11,7 @@ "autoClosingPairs": [ { "open": "{", "close": "}" }, { "open": "[", "close": "]" }, - { "open": "(", "close": ")" }, - { "open": "<", "close": ">", "notIn": ["string"] } + { "open": "(", "close": ")" } ], "surroundingPairs": [ ["(", ")"],