diff --git a/extensions/go/syntaxes/go.json b/extensions/go/syntaxes/go.json index 21be4436592..0cfcf1940ad 100644 --- a/extensions/go/syntaxes/go.json +++ b/extensions/go/syntaxes/go.json @@ -95,7 +95,7 @@ }, { "comment": "Function declarations", - "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?([a-zA-Z_]\\w*)(?=\\())?", + "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?(\\w+)(?=\\())?", "captures": { "1": { "name": "keyword.function.go" @@ -111,19 +111,37 @@ ] }, "3": { - "name": "entity.name.function" + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", + "name": "entity.name.function.go" + } + ] } } }, { "comment": "Functions", - "match": "(\\bfunc\\b)|([a-zA-Z_]\\w*)(?=\\()", + "match": "(\\bfunc\\b)|(\\w+)(?=\\()", "captures": { "1": { "name": "keyword.function.go" }, "2": { - "name": "support.function.go" + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", + "name": "support.function.go" + } + ] } } }, @@ -143,157 +161,111 @@ "name": "constant.language.go" }, { - "comment": "Package declarations", - "match": "(?<=package)\\s+([a-zA-Z_]\\w*)", - "captures": { - "1": { - "name": "entity.name.package.go" - } - } - }, - { - "comment": "Single line import declarations", - "match": "(?<=import)(\\s+((?!\\s+\")[^\\s]*)?\\s*)((\")([^\"]*)(\"))", - "captures": { - "2": { - "name": "entity.alias.import.go" - }, - "3": { - "name": "string.quoted.double.go" - }, - "4": { - "name": "punctuation.definition.string.begin.go" - }, - "5": { - "name": "entity.name.import.go" - }, - "6": { - "name": "punctuation.definition.string.end.go" - } - } - }, - { - "comment": "Multiline import declarations", - "begin": "(?<=import)\\s+(\\()", + "begin": "\\b(package)\\s+", "beginCaptures": { "1": { - "name": "punctuation.other.bracket.round.go" + "name": "keyword.package.go" } }, + "end": "(?!\\G)", "patterns": [ { - "match": "((?!\\s+\")[^\\s]*)?\\s+((\")([^\"]*)(\"))", - "captures": { - "1": { - "name": "entity.alias.import.go" - }, - "2": { - "name": "string.quoted.double.go" - }, - "3": { - "name": "punctuation.definition.string.begin.go" - }, - "4": { - "name": "entity.name.import.go" - }, - "5": { - "name": "punctuation.definition.string.end.go" - } - } + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" }, { - "include": "#comments" + "match": "\\w+", + "name": "entity.name.package.go" } - ], - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.other.bracket.round.go" - } - } + ] }, { - "comment": "Type declarations", - "match": "(?<=type)\\s+([a-zA-Z_]\\w*)", - "captures": { + "begin": "\\b(type)\\s+", + "beginCaptures": { "1": { + "name": "keyword.type.go" + } + }, + "end": "(?!\\G)", + "patterns": [ + { + "match": "\\d\\w*", + "name": "invalid.illegal.identifier.go" + }, + { + "match": "\\w+", "name": "entity.name.type.go" } - } + ] }, { - "comment": "Shorthand variable declaration and assignments", - "match": "[a-zA-Z_]\\w*(?:,\\s*[a-zA-Z_]\\w*)*(?=\\s*:=)", - "captures": { - "0": { - "patterns": [ - { - "match": "[a-zA-Z_]\\w*", - "name": "variable.other.assignment.go" - }, - { - "include": "#delimiters" - } - ] - } - } - }, - { - "comment": "Assignments to existing variables", - "match": "(?