Skip to content

Commit 35b0d66

Browse files
committed
Auto merge of rust-lang#16541 - Veykril:highlight-rustdoc, r=Veykril
Highlight rustdoc Updated version of rust-lang/rust-analyzer#16340
2 parents 1811210 + c6bb352 commit 35b0d66

File tree

5 files changed

+243
-0
lines changed

5 files changed

+243
-0
lines changed

editors/code/.vscodeignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
!ra_syntax_tree.tmGrammar.json
1313
!server
1414
!README.md
15+
!language-configuration-rustdoc.json
16+
!rustdoc-inject.json
17+
!rustdoc.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"comments": {
3+
"blockComment": ["<!--", "-->"]
4+
},
5+
"brackets": [
6+
["{", "}"],
7+
["[", "]"],
8+
["(", ")"]
9+
],
10+
"colorizedBracketPairs": [],
11+
"autoClosingPairs": [
12+
{ "open": "{", "close": "}" },
13+
{ "open": "[", "close": "]" },
14+
{ "open": "(", "close": ")" }
15+
],
16+
"surroundingPairs": [
17+
["(", ")"],
18+
["[", "]"],
19+
["`", "`"],
20+
["_", "_"],
21+
["*", "*"],
22+
["{", "}"],
23+
["'", "'"],
24+
["\"", "\""]
25+
],
26+
"folding": {
27+
"offSide": true,
28+
"markers": {
29+
"start": "^\\s*<!--\\s*#?region\\b.*-->",
30+
"end": "^\\s*<!--\\s*#?endregion\\b.*-->"
31+
}
32+
},
33+
"wordPattern": {
34+
"pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*",
35+
"flags": "ug"
36+
}
37+
}

editors/code/package.json

+28
Original file line numberDiff line numberDiff line change
@@ -1761,13 +1761,41 @@
17611761
"rs"
17621762
],
17631763
"configuration": "language-configuration.json"
1764+
},
1765+
{
1766+
"id": "rustdoc",
1767+
"extensions": [
1768+
".rustdoc"
1769+
],
1770+
"configuration": "./language-configuration-rustdoc.json"
17641771
}
17651772
],
17661773
"grammars": [
17671774
{
17681775
"language": "ra_syntax_tree",
17691776
"scopeName": "source.ra_syntax_tree",
17701777
"path": "ra_syntax_tree.tmGrammar.json"
1778+
},
1779+
{
1780+
"language": "rustdoc",
1781+
"scopeName": "text.html.markdown.rustdoc",
1782+
"path": "rustdoc.json",
1783+
"embeddedLanguages": {
1784+
"meta.embedded.block.html": "html",
1785+
"meta.embedded.block.markdown": "markdown",
1786+
"meta.embedded.block.rust": "rust"
1787+
}
1788+
},
1789+
{
1790+
"injectTo": [
1791+
"source.rust"
1792+
],
1793+
"scopeName": "comment.markdown-cell-inject.rustdoc",
1794+
"path": "rustdoc-inject.json",
1795+
"embeddedLanguages": {
1796+
"meta.embedded.block.rustdoc": "rustdoc",
1797+
"meta.embedded.block.rust": "rust"
1798+
}
17711799
}
17721800
],
17731801
"problemMatchers": [

editors/code/rustdoc-inject.json

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"injectionSelector": "L:source.rust -string -comment -meta.embedded.block.rustdoc.md",
3+
"patterns": [
4+
{
5+
"include": "#triple-slash"
6+
},
7+
{
8+
"include": "#double-slash-exclamation"
9+
},
10+
{
11+
"include": "#slash-start-exclamation"
12+
},
13+
{
14+
"include": "#slash-double-start"
15+
}
16+
],
17+
"repository": {
18+
"triple-slash": {
19+
"begin": "(^|\\G)\\s*(///) ?",
20+
"captures": {
21+
"2": {
22+
"name": "comment.line.double-slash.rust"
23+
}
24+
},
25+
"name": "comment.quote_code.triple-slash.rust",
26+
"contentName": "meta.embedded.block.rustdoc",
27+
"patterns": [
28+
{
29+
"include": "text.html.markdown.rustdoc"
30+
}
31+
],
32+
"while": "(^|\\G)\\s*(///) ?"
33+
},
34+
"double-slash-exclamation": {
35+
"begin": "(^|\\G)\\s*(//!) ?",
36+
"captures": {
37+
"2": {
38+
"name": "comment.line.double-slash.rust"
39+
}
40+
},
41+
"name": "comment.quote_code.double-slash-exclamation.rust",
42+
"contentName": "meta.embedded.block.rustdoc",
43+
"patterns": [
44+
{
45+
"include": "text.html.markdown.rustdoc"
46+
}
47+
],
48+
"while": "(^|\\G)\\s*(//!) ?"
49+
},
50+
"slash-start-exclamation": {
51+
"begin": "(^)(/\\*!) ?$",
52+
"captures": {
53+
"2": {
54+
"name": "comment.block.rust"
55+
}
56+
},
57+
"name": "comment.quote_code.slash-start-exclamation.rust",
58+
"contentName": "meta.embedded.block.rustdoc",
59+
"patterns": [
60+
{
61+
"include": "text.html.markdown.rustdoc"
62+
}
63+
],
64+
"end": "( ?)(\\*/)"
65+
},
66+
"slash-double-start": {
67+
"name": "comment.quote_code.slash-double-start-quote-star.rust",
68+
"begin": "(?:^)\\s*/\\*\\* ?$",
69+
"end": "\\*/",
70+
"patterns": [
71+
{
72+
"include": "#quote-star"
73+
}
74+
]
75+
},
76+
"quote-star": {
77+
"begin": "(^|\\G)\\s*(\\*(?!/)) ?",
78+
"captures": {
79+
"2": {
80+
"name": "comment.punctuation.definition.quote_code.slash-star.MR"
81+
}
82+
},
83+
"contentName": "meta.embedded.block.rustdoc",
84+
"patterns": [
85+
{
86+
"include": "text.html.markdown.rustdoc"
87+
}
88+
],
89+
"while": "(^|\\G)\\s*(\\*(?!/)) ?"
90+
}
91+
},
92+
"scopeName": "comment.markdown-cell-inject.rustdoc"
93+
}

editors/code/rustdoc.json

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"name": "rustdoc",
3+
"patterns": [
4+
{
5+
"include": "#fenced_code_block"
6+
},
7+
{
8+
"include": "#markdown"
9+
}
10+
],
11+
"scopeName": "text.html.markdown.rustdoc",
12+
"repository": {
13+
"markdown": {
14+
"patterns": [
15+
{
16+
"include": "text.html.markdown"
17+
}
18+
]
19+
},
20+
"fenced_code_block": {
21+
"patterns": [
22+
{
23+
"include": "#fenced_code_block_rust"
24+
},
25+
{
26+
"include": "#fenced_code_block_unknown"
27+
}
28+
]
29+
},
30+
"fenced_code_block_rust": {
31+
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(rust|not run|not_run)?((\\s+|:|,|\\{|\\?)[^`~]*)?$)",
32+
"name": "markup.fenced_code.block.markdown",
33+
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
34+
"beginCaptures": {
35+
"3": {
36+
"name": "punctuation.definition.markdown"
37+
},
38+
"4": {
39+
"name": "fenced_code.block.language.markdown"
40+
},
41+
"5": {
42+
"name": "fenced_code.block.language.attributes.markdown"
43+
}
44+
},
45+
"endCaptures": {
46+
"3": {
47+
"name": "punctuation.definition.markdown"
48+
}
49+
},
50+
"patterns": [
51+
{
52+
"begin": "(^|\\G)(\\s*)(.*)",
53+
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
54+
"contentName": "meta.embedded.block.rust",
55+
"patterns": [
56+
{
57+
"include": "source.rust"
58+
}
59+
]
60+
}
61+
]
62+
},
63+
"fenced_code_block_unknown": {
64+
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?=([^`~]+)?$)",
65+
"beginCaptures": {
66+
"3": {
67+
"name": "punctuation.definition.markdown"
68+
},
69+
"4": {
70+
"name": "fenced_code.block.language"
71+
}
72+
},
73+
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
74+
"endCaptures": {
75+
"3": {
76+
"name": "punctuation.definition.markdown"
77+
}
78+
},
79+
"name": "markup.fenced_code.block.markdown"
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)