From 5dadffc771754be293f3e5c8c4e7701ea2fde548 Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Sat, 20 Apr 2024 13:11:04 +0200 Subject: Add improved grammars for import declarations highlights namespace that the import provides --- editors/vscode/syntaxes/odin.tmLanguage.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index bd41c02..b3d5886 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -4,6 +4,7 @@ "name": "Odin", "patterns": [ { "include": "#package-name-declaration" }, + { "include": "#import-declaration" }, { "include": "#statements" } ], "repository": { @@ -217,6 +218,32 @@ "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": "string.import.odin", + "match": "([\"`])([\\w\\.]*[/:])*([A-Za-z_]\\w*)([\"`])", + "captures": { + "1": {"name": "punctuation.definition.string.begin.odin"}, + "3": {"name": "entity.name.namespace.odin"}, + "4": {"name": "punctuation.definition.string.end.odin"} + } + }, + { "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": "#comments" } + ] + }, "map-bitset": { "begin": "\\b(bit_set|map)\\b", "beginCaptures": { "0": { "name": "storage.type.odin" } }, -- cgit v1.2.3