Skip to content

Commit 56ee080

Browse files
committed
Much better
1 parent 0a3a97d commit 56ee080

13 files changed

+123
-113
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 0.0.8
4+
- Updated icon.
5+
- Improved highlighting for type params.
6+
37
## 0.0.7
48
- Fixed issue where `.` wasn't highlighted when preceded by a paren.
59
- Added items to todo.txt.
@@ -18,7 +22,7 @@
1822

1923
## 0.0.5
2024
- Fixed an issue with comments.
21-
- defined `,` as `punctuation.comma`.
25+
- Defined `,` as `punctuation.comma`.
2226
- Defined `;` as `punctuation.terminaor`.
2327
- Defined `::` as *path* operator.
2428
- Defined `=>` as *match* operator.

assets/rust.old.png

7 KB
Loading

assets/rust.png

-67 Bytes
Loading

assets/rust.svg

+1-1
Loading

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "vscode-rust-syntax",
33
"displayName": "vscode-rust-syntax",
4-
"description": "Syntax highlighting for Rust. (WIP)",
5-
"version": "0.0.7",
4+
"description": "Syntax highlighting for Rust.",
5+
"version": "0.0.8",
66
"publisher": "dunstontc",
77
"repository": {
88
"type": "git",

src/syntax/keyword.json5 renamed to src/good/keyword.json5

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
"name": "keyword.other.unsafe.rust",
1111
"match": "\\b(unsafe)\\b"
1212
},
13-
{
14-
"comment": "Reserved keyword",
15-
"name": "invalid.deprecated.rust",
16-
"match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b"
17-
},
1813
{
1914
"name": "keyword.control.rust",
2015
"match": "\\b(break|continue|else|if|in|for|loop|match|return|while)\\b"
@@ -28,9 +23,14 @@
2823
"match": "\\b(where)\\b"
2924
},
3025
{
31-
"name": "keyword.operator.as.rust",
26+
"name": "keyword.other.as.rust",
3227
"match": "(\\b(as)\\b)"
3328
},
29+
{
30+
"comment": "Reserved keyword",
31+
"name": "invalid.deprecated.rust",
32+
"match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b"
33+
},
3434
]
3535
}
3636
}

src/good/operator.json5

+25
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,31 @@
7676
"name": "keyword.operator.comparison.rust", // Second group because of regex precedence
7777
"match": "\\B(<=|>=)\\B",
7878
},
79+
// =============================================
80+
// {
81+
// // "name": "string.quoted.double.rust",
82+
// "begin": "^(use)\\s((\\w+)(::))+({)",
83+
// "beginCaptures": {
84+
// "1": {"name": "keyword.other.rust"},
85+
// "2": {"name": "entity.name.type.module.rust"},
86+
// "3": {"name": "entity.name.lifetime.rust"},
87+
// },
88+
// "end": "\"",
89+
// "patterns": [
90+
// {
91+
// "name": "constant.character.escape.rust",
92+
// "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)"
93+
// },
94+
// {
95+
// "name": "constant.other.placeholder.rust",
96+
// "match": "{}"
97+
// },
98+
// {
99+
// "name": "constant.other.placeholder.rust",
100+
// "match": "{:\\?}"
101+
// },
102+
// ]
103+
// },
79104
]
80105
}
81106
}

src/good/punctuation.json5

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"name": "punctuation.other.comma.rust",
1515
"match": ","
1616
},
17-
{
18-
"name": "punctuation.other.curly.rust",
19-
"match": "[{}]"
20-
},
17+
// {
18+
// "name": "punctuation.other.curly.rust",
19+
// "match": "[{}]"
20+
// },
2121
{
2222
"name": "punctuation.other.paren.rust",
2323
"match": "[)(]"

src/good/type.json5

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
"match": "\\b(ToOwned|ToString|FromStr)\\b"
3636
},
3737
// {
38+
// "match": "([<])(\\w+)([>])",
39+
// "captures": {
40+
// "1": {"name": "punctuation.definition.type.rust"},
41+
// "2": {"name": "entity.name.type.rust"},
42+
// "3": {"name": "punctuation.definition.type.rust"}
43+
// }
44+
// },
45+
// {
3846
// "match": "(<)('[a-zA-Z_][a-zA-Z0-9_]*)(>)",
3947
// "captures": {
4048
// "1": {"name": "punctuation.definition.type.rust"},

src/syntax/entity.json5

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@
7777
// },
7878
// },
7979
// },
80+
// {
8081
{
8182
"comment": "Type declaration",
82-
"begin": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
83-
"end": "[\\{\\(;]",
84-
"beginCaptures": {
83+
"match": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]+)",
84+
"captures": {
8585
"1": {
8686
"name": "storage.type.rust"
8787
},

src/syntax/storage.json5

+14
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@
3838
"name": "storage.type.rust",
3939
"match": "\\b(enum|impl|struct|trait|union)\\b"
4040
},
41+
{
42+
"name": "storage.modifier.lifetime.rust",
43+
"match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b",
44+
"captures": {
45+
"1": {"name": "entity.name.lifetime.rust"}
46+
}
47+
},
48+
{
49+
"match": "&('([a-zA-Z_][a-zA-Z0-9_]*))\\b",
50+
"captures": {
51+
"1": {"name": "storage.modifier.lifetime.rust"},
52+
"2": {"name": "entity.name.lifetime.rust"}
53+
}
54+
},
4155
]
4256
}
4357
}

src/syntax/unsorted.json5

-30
This file was deleted.

syntaxes/rust.tmLanguage.json

+55-66
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
{
22
"repository": {
3+
"keyword": {
4+
"patterns": [
5+
{
6+
"name": "variable.language.self.rust",
7+
"match": "\\b(self)\\b"
8+
},
9+
{
10+
"name": "keyword.other.unsafe.rust",
11+
"match": "\\b(unsafe)\\b"
12+
},
13+
{
14+
"name": "keyword.control.rust",
15+
"match": "\\b(break|continue|else|if|in|for|loop|match|return|while)\\b"
16+
},
17+
{
18+
"name": "keyword.other.rust",
19+
"match": "\\b(crate|extern|ref|use|super|move)\\b"
20+
},
21+
{
22+
"name": "keyword.other.where.rust",
23+
"match": "\\b(where)\\b"
24+
},
25+
{
26+
"name": "keyword.other.as.rust",
27+
"match": "(\\b(as)\\b)"
28+
},
29+
{
30+
"comment": "Reserved keyword",
31+
"name": "invalid.deprecated.rust",
32+
"match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b"
33+
}
34+
]
35+
},
336
"meta": {
437
"patterns": [
538
{
@@ -95,10 +128,6 @@
95128
"name": "punctuation.other.comma.rust",
96129
"match": ","
97130
},
98-
{
99-
"name": "punctuation.other.curly.rust",
100-
"match": "[{}]"
101-
},
102131
{
103132
"name": "punctuation.other.paren.rust",
104133
"match": "[)(]"
@@ -143,9 +172,8 @@
143172
},
144173
{
145174
"comment": "Type declaration",
146-
"begin": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
147-
"end": "[\\{\\(;]",
148-
"beginCaptures": {
175+
"match": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]+)",
176+
"captures": {
149177
"1": {
150178
"name": "storage.type.rust"
151179
},
@@ -359,39 +387,6 @@
359387
}
360388
]
361389
},
362-
"keyword": {
363-
"patterns": [
364-
{
365-
"name": "variable.language.self.rust",
366-
"match": "\\b(self)\\b"
367-
},
368-
{
369-
"name": "keyword.other.unsafe.rust",
370-
"match": "\\b(unsafe)\\b"
371-
},
372-
{
373-
"comment": "Reserved keyword",
374-
"name": "invalid.deprecated.rust",
375-
"match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b"
376-
},
377-
{
378-
"name": "keyword.control.rust",
379-
"match": "\\b(break|continue|else|if|in|for|loop|match|return|while)\\b"
380-
},
381-
{
382-
"name": "keyword.other.rust",
383-
"match": "\\b(crate|extern|ref|use|super|move)\\b"
384-
},
385-
{
386-
"name": "keyword.other.where.rust",
387-
"match": "\\b(where)\\b"
388-
},
389-
{
390-
"name": "keyword.operator.as.rust",
391-
"match": "(\\b(as)\\b)"
392-
}
393-
]
394-
},
395390
"storage": {
396391
"patterns": [
397392
{
@@ -429,6 +424,26 @@
429424
{
430425
"name": "storage.type.rust",
431426
"match": "\\b(enum|impl|struct|trait|union)\\b"
427+
},
428+
{
429+
"name": "storage.modifier.lifetime.rust",
430+
"match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b",
431+
"captures": {
432+
"1": {
433+
"name": "entity.name.lifetime.rust"
434+
}
435+
}
436+
},
437+
{
438+
"match": "&('([a-zA-Z_][a-zA-Z0-9_]*))\\b",
439+
"captures": {
440+
"1": {
441+
"name": "storage.modifier.lifetime.rust"
442+
},
443+
"2": {
444+
"name": "entity.name.lifetime.rust"
445+
}
446+
}
432447
}
433448
]
434449
},
@@ -465,32 +480,6 @@
465480
"match": "\\b(Some)"
466481
}
467482
]
468-
},
469-
"unsorted": {
470-
"patterns": [
471-
{
472-
"comment": "Named lifetime",
473-
"name": "storage.modifier.lifetime.rust",
474-
"match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b",
475-
"captures": {
476-
"1": {
477-
"name": "entity.name.lifetime.rust"
478-
}
479-
}
480-
},
481-
{
482-
"comment": "Reference with named lifetime",
483-
"match": "&('([a-zA-Z_][a-zA-Z0-9_]*))\\b",
484-
"captures": {
485-
"1": {
486-
"name": "storage.modifier.lifetime.rust"
487-
},
488-
"2": {
489-
"name": "entity.name.lifetime.rust"
490-
}
491-
}
492-
}
493-
]
494483
}
495484
},
496485
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",

0 commit comments

Comments
 (0)