Skip to content

Commit

Permalink
Merge pull request #504 from thetarnav/new-file-tags-grammar
Browse files Browse the repository at this point in the history
Adds grammar for new file-tags and shabang comments
  • Loading branch information
DanielGavin authored Sep 15, 2024
2 parents 4102eff + 3d3c0fc commit 7e6b688
Showing 1 changed file with 48 additions and 26 deletions.
74 changes: 48 additions & 26 deletions editors/vscode/syntaxes/odin.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,54 @@
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Odin",
"patterns": [
{ "include": "#file-tags" },
{ "include": "#package-name-declaration" },
{ "include": "#import-declaration" },
{ "include": "#statements" }
],
"repository": {
"file-tags": {
"name": "comment.line.double-slash.odin",
"begin": "#\\+[A-Za-z_][A-Za-z0-9_\\-]*",
"beginCaptures": {"0": {"name": "entity.name.tag.odin"}},
"patterns": [{
"name": "punctuation.odin",
"match": ","
}, {
"name": "keyword.operator.logical.odin",
"match": "!"
}, {
"name": "entity.other.attribute-name.odin",
"match": "[A-Za-z_][A-Za-z0-9_\\-]*"
}],
"end": "\n"
},
"package-name-declaration": {
"match": "^\\s*(package)\\s+([A-Za-z_]\\w*)",
"captures": {
"1": { "name": "keyword.control.odin" },
"2": { "name": "entity.name.type.module.odin" }
}
},
"import-declaration": {
"name": "meta.import.odin",
"begin": "\\b(import|foreign\\s+import)\\b",
"beginCaptures": {"0": {"name": "keyword.control.import.odin"}},
"end": "(?=^|;)",
"patterns": [
{ "name": "entity.name.alias.odin",
"begin": "\\b[A-Za-z_]\\w*",
"beginCaptures": {"0": {"name": "entity.name.namespace.odin"}},
"end": "(?=^|;)",
"patterns": [
{"include": "#strings"},
{"include": "#comments"}
]
},
{"include": "#strings"},
{"include": "#comments"}
]
},
"statements": {
"patterns": [
{ "include": "#attribute" },
Expand Down Expand Up @@ -243,32 +286,6 @@
{ "include": "#type-name" }
]
},
"package-name-declaration": {
"match": "^\\s*(package)\\s+([A-Za-z_]\\w*)",
"captures": {
"1": { "name": "keyword.control.odin" },
"2": { "name": "entity.name.type.module.odin" }
}
},
"import-declaration": {
"name": "meta.import.odin",
"begin": "\\b(import|foreign\\s+import)\\b",
"beginCaptures": {"0": {"name": "keyword.control.import.odin"}},
"end": "(?=^|;)",
"patterns": [
{ "name": "entity.name.alias.odin",
"begin": "\\b[A-Za-z_]\\w*",
"beginCaptures": {"0": {"name": "entity.name.namespace.odin"}},
"end": "(?=^|;)",
"patterns": [
{"include": "#strings"},
{"include": "#comments"}
]
},
{"include": "#strings"},
{"include": "#comments"}
]
},
"map-bitset": {
"begin": "\\b(bit_set|map)\\b",
"beginCaptures": { "0": { "name": "storage.type.odin" } },
Expand Down Expand Up @@ -361,6 +378,11 @@
"begin": "//",
"beginCaptures": {"0": {"name": "punctuation.definition.comment.odin"}},
"end": "\n"
}, {
"name": "comment.line.shebang.odin",
"begin": "#!",
"beginCaptures": {"0": {"name": "punctuation.definition.comment.odin"}},
"end": "\n"
}
]
},
Expand Down

0 comments on commit 7e6b688

Please sign in to comment.