Skip to content

Commit 0380d98

Browse files
committed
highlight rustdoc
1 parent 1c9bb31 commit 0380d98

File tree

4 files changed

+257
-0
lines changed

4 files changed

+257
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"comments": {
3+
"blockComment": [
4+
"<!--",
5+
"-->"
6+
]
7+
},
8+
"brackets": [
9+
["{", "}"],
10+
["[", "]"],
11+
["(", ")"]
12+
],
13+
"colorizedBracketPairs": [
14+
],
15+
"autoClosingPairs": [
16+
{
17+
"open": "{",
18+
"close": "}"
19+
},
20+
{
21+
"open": "[",
22+
"close": "]"
23+
},
24+
{
25+
"open": "(",
26+
"close": ")"
27+
},
28+
{
29+
"open": "<",
30+
"close": ">",
31+
"notIn": [
32+
"string"
33+
]
34+
}
35+
],
36+
"surroundingPairs": [
37+
["(", ")"],
38+
["[", "]"],
39+
["`", "`"],
40+
["_", "_"],
41+
["*", "*"],
42+
["{", "}"],
43+
["'", "'"],
44+
["\"", "\""]
45+
],
46+
"folding": {
47+
"offSide": true,
48+
"markers": {
49+
"start": "^\\s*<!--\\s*#?region\\b.*-->",
50+
"end": "^\\s*<!--\\s*#?endregion\\b.*-->"
51+
}
52+
},
53+
"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" },
54+
}

editors/code/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,41 @@
17291729
"rs"
17301730
],
17311731
"configuration": "language-configuration.json"
1732+
},
1733+
{
1734+
"id": "rustdoc",
1735+
"extensions": [
1736+
".rustdoc"
1737+
],
1738+
"configuration": "./language-configuration-rustdoc.json"
17321739
}
17331740
],
17341741
"grammars": [
17351742
{
17361743
"language": "ra_syntax_tree",
17371744
"scopeName": "source.ra_syntax_tree",
17381745
"path": "ra_syntax_tree.tmGrammar.json"
1746+
},
1747+
{
1748+
"language": "rustdoc",
1749+
"scopeName": "text.html.markdown.rustdoc",
1750+
"path": "rustdoc.json",
1751+
"embeddedLanguages": {
1752+
"meta.embedded.block.html": "html",
1753+
"meta.embedded.block.markdown": "markdown",
1754+
"meta.embedded.block.rust": "rust"
1755+
}
1756+
},
1757+
{
1758+
"injectTo": [
1759+
"source.rust"
1760+
],
1761+
"scopeName": "comment.markdown-cell-inject.rustdoc",
1762+
"path": "rustdoc-inject.json",
1763+
"embeddedLanguages": {
1764+
"meta.embedded.block.rustdoc": "rustdoc",
1765+
"meta.embedded.block.rust": "rust"
1766+
}
17391767
}
17401768
],
17411769
"problemMatchers": [

editors/code/rustdoc-inject.json

Lines changed: 93 additions & 0 deletions
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

Lines changed: 82 additions & 0 deletions
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)