{ "name": "Go", "scopeName": "source.go", "patterns": [ { "include": "#receiver_function_declaration" }, { "include": "#plain_function_declaration" }, { "include": "#basic_things" }, { "include": "#exported_variables" }, { "name": "meta.preprocessor.go.import", "begin": "^[[:blank:]]*(import)\\b\\s+", "end": "(?=(?://|/\\*))|$", "patterns": [ { "name": "string.quoted.double.import.go", "begin": "\"", "end": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.go" } } } ], "beginCaptures": { "1": { "name": "keyword.control.import.go" } } }, { "include": "#block" }, { "include": "#root_parens" }, { "include": "#function_calls" } ], "repository": { "access": { "name": "variable.other.dot-access.go", "match": "(?\u003c=\\.)[[:alpha:]_][[:alnum:]_]*\\b(?!\\s*\\()" }, "basic_things": { "patterns": [ { "include": "#comments" }, { "include": "#initializers" }, { "include": "#access" }, { "include": "#strings" }, { "include": "#keywords" } ] }, "block": { "name": "meta.block.go", "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#block_innards" } ], "beginCaptures": { "0": { "name": "punctuation.section.block.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.section.block.end.go" } } }, "block_innards": { "patterns": [ { "include": "#function_block_innards" }, { "include": "#exported_variables" } ] }, "comments": { "patterns": [ { "name": "comment.block.go", "match": "^/\\* =(\\s*.*?)\\s*= \\*/$\\n?", "captures": { "1": { "name": "meta.toc-list.banner.block.go" } } }, { "name": "comment.block.go", "begin": "/\\*", "end": "\\*/", "captures": { "0": { "name": "punctuation.definition.comment.go" } } }, { "name": "invalid.illegal.stray-comment-end.go", "match": "\\*/.*\\n" }, { "name": "comment.line.double-slash.banner.go", "match": "^(//) =(\\s*.*?)\\s*=\\s*$\\n?", "captures": { "1": { "name": "punctuation.definition.comment.go" }, "2": { "name": "meta.toc-list.banner.line.go" } } }, { "begin": "(^[ \\t]+)?(?=//)", "end": "(?!\\G)", "patterns": [ { "name": "comment.line.double-slash.go", "begin": "//", "end": "\\n", "patterns": [ { "name": "punctuation.separator.continuation.go", "match": "(?\u003e\\\\\\s*\\n)" } ], "beginCaptures": { "0": { "name": "punctuation.definition.comment.go" } } } ], "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.go" } } } ] }, "exported_variables": { "name": "variable.exported.go", "match": "(?\u003c=\\s|\\[\\])([[:upper:]][[:alnum:]_]*)(?=\\W+)" }, "fn_parens": { "name": "meta.parens.go", "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#basic_things" }, { "include": "#function_calls" } ], "beginCaptures": { "0": { "name": "punctuation.section.parens.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.section.parens.end.go" } } }, "function_block": { "name": "meta.block.go", "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#function_block_innards" } ], "beginCaptures": { "0": { "name": "punctuation.section.function-block.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.section.function-block.end.go" } } }, "function_block_innards": { "patterns": [ { "include": "#basic_things" }, { "match": "(\\s*)\\b(new|c(lose|ap)|p(anic|rint(ln)?)|len|make|append)(?:\\b|\\()", "captures": { "1": { "name": "punctuation.whitespace.support.function.leading.go" }, "2": { "name": "support.function.builtin.go" } } }, { "include": "#function_block" }, { "include": "#function_calls" }, { "include": "#fn_parens" } ] }, "function_calls": { "name": "meta.function-call.go", "match": "(?x)\n (?: (?= \\s ) (?:(?\u003c=else|new|return) | (?\u003c!\\w)) (\\s+) )?\n (\\b\n (?!(for|if|else|switch|return)\\s*\\()\n (?:[[:alpha:]_][[:alnum:]_]*+\\b) # method name\n )\n \\s*(\\()\n ", "captures": { "1": { "name": "punctuation.whitespace.function-call.leading.go" }, "2": { "name": "support.function.any-method.go" }, "3": { "name": "punctuation.definition.parameters.go" } } }, "initializers": { "patterns": [ { "name": "meta.initialization.explicit.go", "match": "^[[:blank:]]*(var)\\s+((?:[[:alpha:]_][[:alnum:]_]*)(?:,\\s+[[:alpha:]_][[:alnum:]_]*)*)", "captures": { "1": { "name": "keyword.control.go" }, "2": { "patterns": [ { "name": "variable.other.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] } } }, { "name": "meta.initialization.short.go", "match": "((?:[[:alpha:]_][[:alnum:]_]*)(?:\\s*,\\s+[[:alpha:]_][[:alnum:]_]*)*)\\s*(:=)", "captures": { "1": { "patterns": [ { "name": "variable.other.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] }, "2": { "name": "keyword.operator.go" } } } ] }, "keywords": { "patterns": [ { "name": "keyword.control.go", "match": "\\b(s(elect|witch)|c(ontinue|ase)|type|i(nterface|f|mport)|def(er|ault)|package|else|var|f(or|unc|allthrough)|r(eturn|ange)|go(to)?|break)\\b" }, { "name": "storage.type.go", "match": "(\\b|(?\u003c=\\]))(int(16|8|32|64)?|uint(16|8|32|64|ptr)?|float(32|64)|complex(64|128)|b(yte|ool)|string|error|struct)\\b" }, { "name": "storage.modifier.go", "match": "\\b(c(onst|han)|map)\\b" }, { "name": "constant.language.go", "match": "\\b(nil|true|false|iota)\\b" }, { "name": "constant.numeric.go", "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b" }, { "name": "keyword.operator.channel.go", "match": "\\\u003c\\-" } ] }, "plain_function_declaration": { "name": "meta.function.plain.go", "begin": "(?x)\n \t (^[[:blank:]]*(func)\\s*\n \t (?: ([[:alpha:]_][[:alnum:]_]*)? ) # name of function is optional\n \t (?: \\( ((?:[\\[\\]\\w\\d\\s\\/,._*\u0026\u003c\u003e-]|(?:interface\\{\\}))*)? \\) ) # required braces for parameters (even if empty)\n \t \\s*\n \t (?: \\(? ((?:[\\[\\]\\w\\d\\s,._*\u0026\u003c\u003e-]|(?:interface\\{\\}))*) \\)? )? # optional return types, optionally within braces\n )\n \t ", "end": "(?\u003c=\\})", "patterns": [ { "include": "#comments" }, { "include": "#storage_type" }, { "include": "#storage_modifier" }, { "include": "#function_block" } ], "beginCaptures": { "1": { "name": "meta.function.declaration.go" }, "2": { "name": "keyword.control.go" }, "3": { "name": "entity.name.function.go" }, "4": { "patterns": [ { "name": "variable.parameters.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] }, "5": { "patterns": [ { "name": "variable.return-types.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] } } }, "receiver_function_declaration": { "name": "meta.function.receiver.go", "begin": "(?x)\n \t (\n (func)\\s*\n \t (\n \t (?: \\( ((?:[\\[\\]\\w\\d\\s,._*\u0026\u003c\u003e-]|(?:interface\\{\\}))*) \\)\\s+ ) # receiver variable declarations, in brackets\n \t (?: ([[:alpha:]_][[:alnum:]_]*)? ) # name of function is optional\n \t )\n \t (?: \\( ((?:[\\[\\]\\w\\d\\s,._*\u0026\u003c\u003e-]|(?:interface\\{\\}))*)? \\) ) # required braces for parameters (even if empty)\n \t \\s*\n \t (?: \\(? ((?:[\\[\\]\\w\\d\\s,._*\u0026\u003c\u003e-]|(?:interface\\{\\}))*) \\)? )? # optional return types, optionally within braces\n )\n \t ", "end": "(?\u003c=\\})", "patterns": [ { "include": "#comments" }, { "include": "#storage_type" }, { "include": "#storage_modifier" }, { "include": "#function_block" } ], "beginCaptures": { "1": { "name": "meta.function.receiver.declaration.go" }, "2": { "name": "keyword.control.go" }, "3": { "name": "entity.name.function.go.full-name" }, "4": { "patterns": [ { "name": "variable.receiver.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] }, "5": { "name": "entity.name.function.go.name" }, "6": { "patterns": [ { "name": "variable.parameters.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] }, "7": { "patterns": [ { "name": "variable.return-types.go", "match": "[[:alpha:]_][[:alnum:]_]*" } ] } } }, "root_parens": { "name": "meta.parens.go", "begin": "\\(", "end": "(?\u003c=\\()(\\))?|(?:\\))", "patterns": [ { "include": "#basic_things" }, { "include": "#exported_variables" }, { "include": "#function_calls" } ], "endCaptures": { "1": { "name": "meta.parens.empty.go" } } }, "string_escaped_char": { "patterns": [ { "name": "constant.character.escape.go", "match": "\\\\(\\\\|[abfnrutv'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|[0-7]{3})" }, { "name": "invalid.illegal.unknown-escape.go", "match": "\\\\." } ] }, "string_placeholder": { "patterns": [ { "name": "constant.other.placeholder.go", "match": "(?x)%\n (\\d+\\$)? # field (argument #)\n [#0\\- +']* # flags\n [,;:_]? # separator character (AltiVec)\n ((-?\\d+)|\\*(-?\\d+\\$)?)? # minimum field width\n (\\.((-?\\d+)|\\*(-?\\d+\\$)?)?)? # precision\n [diouxXDOUeEfFgGaAcCsSpnvtTbyYhHmMzZq%] # conversion type\n " }, { "name": "invalid.illegal.placeholder.go", "match": "%" } ] }, "strings": { "patterns": [ { "name": "string.quoted.double.go", "begin": "\"", "end": "\"", "patterns": [ { "include": "#string_placeholder" }, { "include": "#string_escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.go" } } }, { "name": "string.quoted.single.go", "begin": "'", "end": "'", "patterns": [ { "include": "#string_escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.go" } } }, { "name": "string.quoted.raw.go", "begin": "`", "end": "`", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.go" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.go" } } } ] } } }