Skip to content

Commit 3d3c0fc

Browse files
committed
Add grammar for new file-tags and shabang comments
1 parent 4102eff commit 3d3c0fc

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

editors/vscode/syntaxes/odin.tmLanguage.json

+48-26
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,54 @@
33
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
44
"name": "Odin",
55
"patterns": [
6+
{ "include": "#file-tags" },
67
{ "include": "#package-name-declaration" },
78
{ "include": "#import-declaration" },
89
{ "include": "#statements" }
910
],
1011
"repository": {
12+
"file-tags": {
13+
"name": "comment.line.double-slash.odin",
14+
"begin": "#\\+[A-Za-z_][A-Za-z0-9_\\-]*",
15+
"beginCaptures": {"0": {"name": "entity.name.tag.odin"}},
16+
"patterns": [{
17+
"name": "punctuation.odin",
18+
"match": ","
19+
}, {
20+
"name": "keyword.operator.logical.odin",
21+
"match": "!"
22+
}, {
23+
"name": "entity.other.attribute-name.odin",
24+
"match": "[A-Za-z_][A-Za-z0-9_\\-]*"
25+
}],
26+
"end": "\n"
27+
},
28+
"package-name-declaration": {
29+
"match": "^\\s*(package)\\s+([A-Za-z_]\\w*)",
30+
"captures": {
31+
"1": { "name": "keyword.control.odin" },
32+
"2": { "name": "entity.name.type.module.odin" }
33+
}
34+
},
35+
"import-declaration": {
36+
"name": "meta.import.odin",
37+
"begin": "\\b(import|foreign\\s+import)\\b",
38+
"beginCaptures": {"0": {"name": "keyword.control.import.odin"}},
39+
"end": "(?=^|;)",
40+
"patterns": [
41+
{ "name": "entity.name.alias.odin",
42+
"begin": "\\b[A-Za-z_]\\w*",
43+
"beginCaptures": {"0": {"name": "entity.name.namespace.odin"}},
44+
"end": "(?=^|;)",
45+
"patterns": [
46+
{"include": "#strings"},
47+
{"include": "#comments"}
48+
]
49+
},
50+
{"include": "#strings"},
51+
{"include": "#comments"}
52+
]
53+
},
1154
"statements": {
1255
"patterns": [
1356
{ "include": "#attribute" },
@@ -243,32 +286,6 @@
243286
{ "include": "#type-name" }
244287
]
245288
},
246-
"package-name-declaration": {
247-
"match": "^\\s*(package)\\s+([A-Za-z_]\\w*)",
248-
"captures": {
249-
"1": { "name": "keyword.control.odin" },
250-
"2": { "name": "entity.name.type.module.odin" }
251-
}
252-
},
253-
"import-declaration": {
254-
"name": "meta.import.odin",
255-
"begin": "\\b(import|foreign\\s+import)\\b",
256-
"beginCaptures": {"0": {"name": "keyword.control.import.odin"}},
257-
"end": "(?=^|;)",
258-
"patterns": [
259-
{ "name": "entity.name.alias.odin",
260-
"begin": "\\b[A-Za-z_]\\w*",
261-
"beginCaptures": {"0": {"name": "entity.name.namespace.odin"}},
262-
"end": "(?=^|;)",
263-
"patterns": [
264-
{"include": "#strings"},
265-
{"include": "#comments"}
266-
]
267-
},
268-
{"include": "#strings"},
269-
{"include": "#comments"}
270-
]
271-
},
272289
"map-bitset": {
273290
"begin": "\\b(bit_set|map)\\b",
274291
"beginCaptures": { "0": { "name": "storage.type.odin" } },
@@ -361,6 +378,11 @@
361378
"begin": "//",
362379
"beginCaptures": {"0": {"name": "punctuation.definition.comment.odin"}},
363380
"end": "\n"
381+
}, {
382+
"name": "comment.line.shebang.odin",
383+
"begin": "#!",
384+
"beginCaptures": {"0": {"name": "punctuation.definition.comment.odin"}},
385+
"end": "\n"
364386
}
365387
]
366388
},

0 commit comments

Comments
 (0)