mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
2669 lines
61 KiB
JSON
2669 lines
61 KiB
JSON
{
|
|
"information_for_contributors": [
|
|
"This file has been converted from https://github.com/worlpaker/go-syntax/blob/master/syntaxes/go.tmLanguage.json",
|
|
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
|
|
"Once accepted there, we are happy to receive an update request."
|
|
],
|
|
"version": "https://github.com/worlpaker/go-syntax/commit/4014e9376f32e5317eb0c6be286db7ffcba838f9",
|
|
"name": "Go",
|
|
"scopeName": "source.go",
|
|
"patterns": [
|
|
{
|
|
"include": "#statements"
|
|
}
|
|
],
|
|
"repository": {
|
|
"statements": {
|
|
"patterns": [
|
|
{
|
|
"include": "#package_name"
|
|
},
|
|
{
|
|
"include": "#import"
|
|
},
|
|
{
|
|
"include": "#syntax_errors"
|
|
},
|
|
{
|
|
"include": "#group-functions"
|
|
},
|
|
{
|
|
"include": "#group-types"
|
|
},
|
|
{
|
|
"include": "#group-variables"
|
|
}
|
|
]
|
|
},
|
|
"group-functions": {
|
|
"comment": "all statements related to functions",
|
|
"patterns": [
|
|
{
|
|
"include": "#function_declaration"
|
|
},
|
|
{
|
|
"include": "#functions_inline"
|
|
},
|
|
{
|
|
"include": "#functions"
|
|
},
|
|
{
|
|
"include": "#built_in_functions"
|
|
},
|
|
{
|
|
"include": "#support_functions"
|
|
}
|
|
]
|
|
},
|
|
"group-types": {
|
|
"comment": "all statements related to types",
|
|
"patterns": [
|
|
{
|
|
"include": "#other_struct_interface_expressions"
|
|
},
|
|
{
|
|
"include": "#struct_variables_types"
|
|
},
|
|
{
|
|
"include": "#interface_variables_types"
|
|
},
|
|
{
|
|
"include": "#single_type"
|
|
},
|
|
{
|
|
"include": "#multi_types"
|
|
},
|
|
{
|
|
"include": "#struct_interface_declaration"
|
|
},
|
|
{
|
|
"include": "#double_parentheses_types"
|
|
},
|
|
{
|
|
"include": "#switch_types"
|
|
},
|
|
{
|
|
"include": "#type-declarations"
|
|
}
|
|
]
|
|
},
|
|
"group-variables": {
|
|
"comment": "all statements related to variables",
|
|
"patterns": [
|
|
{
|
|
"include": "#after_control_variables"
|
|
},
|
|
{
|
|
"include": "#var_const_single_assignment"
|
|
},
|
|
{
|
|
"include": "#var_assignment"
|
|
},
|
|
{
|
|
"include": "#var_other_assignment"
|
|
},
|
|
{
|
|
"include": "#var_const_multi_assignment"
|
|
},
|
|
{
|
|
"include": "#other_variables"
|
|
}
|
|
]
|
|
},
|
|
"type-declarations": {
|
|
"comment": "includes all type declarations",
|
|
"patterns": [
|
|
{
|
|
"include": "#language_constants"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#map_other_types"
|
|
},
|
|
{
|
|
"include": "#brackets"
|
|
},
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"include": "#runes"
|
|
},
|
|
{
|
|
"include": "#storage_types"
|
|
},
|
|
{
|
|
"include": "#raw_strings_literals"
|
|
},
|
|
{
|
|
"include": "#string_literals"
|
|
},
|
|
{
|
|
"include": "#numeric_literals"
|
|
},
|
|
{
|
|
"include": "#terminators"
|
|
}
|
|
]
|
|
},
|
|
"type-declarations-without-brackets": {
|
|
"comment": "includes all type declarations without brackets (in some cases, brackets need to be captured manually)",
|
|
"patterns": [
|
|
{
|
|
"include": "#language_constants"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#map_other_types"
|
|
},
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"include": "#runes"
|
|
},
|
|
{
|
|
"include": "#storage_types"
|
|
},
|
|
{
|
|
"include": "#raw_strings_literals"
|
|
},
|
|
{
|
|
"include": "#string_literals"
|
|
},
|
|
{
|
|
"include": "#numeric_literals"
|
|
},
|
|
{
|
|
"include": "#terminators"
|
|
}
|
|
]
|
|
},
|
|
"parameter-variable-types": {
|
|
"comment": "function and generic parameter types",
|
|
"patterns": [
|
|
{
|
|
"match": "\\{",
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
},
|
|
{
|
|
"match": "\\}",
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
},
|
|
{
|
|
"begin": "(?:([\\w\\.\\*]+)?(\\[))",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#generic_param_types"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function_param_types"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"language_constants": {
|
|
"comment": "Language constants",
|
|
"match": "\\b(true|false|nil|iota)\\b",
|
|
"name": "constant.language.go"
|
|
},
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.block.go",
|
|
"begin": "(\\/\\*)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "punctuation.definition.comment.go"
|
|
}
|
|
},
|
|
"end": "(\\*\\/)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.definition.comment.go"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "comment.line.double-slash.go",
|
|
"begin": "(\\/\\/)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "punctuation.definition.comment.go"
|
|
}
|
|
},
|
|
"end": "(?:\\n|$)"
|
|
}
|
|
]
|
|
},
|
|
"map_other_types": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Other map type names (struct/interface)",
|
|
"match": "(?:(\\bmap\\b)(\\[(?:.*)\\])?((?!\\bfunc\\b|\\bstruct\\b)[\\w\\.\\*]+)?)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.map.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"match": "\\[",
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\]",
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\{",
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
},
|
|
{
|
|
"match": "\\}",
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
},
|
|
{
|
|
"match": "\\(",
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
},
|
|
{
|
|
"match": "\\)",
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"brackets": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\{",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
}
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "\\[",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"delimiters": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\,",
|
|
"name": "punctuation.other.comma.go"
|
|
},
|
|
{
|
|
"match": "\\.(?!\\.\\.)",
|
|
"name": "punctuation.other.period.go"
|
|
},
|
|
{
|
|
"match": ":(?!=)",
|
|
"name": "punctuation.other.colon.go"
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Flow control keywords",
|
|
"match": "\\b(break|case|continue|default|defer|else|fallthrough|for|go|goto|if|range|return|select|switch)\\b",
|
|
"name": "keyword.control.go"
|
|
},
|
|
{
|
|
"match": "\\bchan\\b",
|
|
"name": "keyword.channel.go"
|
|
},
|
|
{
|
|
"match": "\\bconst\\b",
|
|
"name": "keyword.const.go"
|
|
},
|
|
{
|
|
"match": "\\bvar\\b",
|
|
"name": "keyword.var.go"
|
|
},
|
|
{
|
|
"match": "\\bfunc\\b",
|
|
"name": "keyword.function.go"
|
|
},
|
|
{
|
|
"match": "\\binterface\\b",
|
|
"name": "keyword.interface.go"
|
|
},
|
|
{
|
|
"match": "\\bmap\\b",
|
|
"name": "keyword.map.go"
|
|
},
|
|
{
|
|
"match": "\\bstruct\\b",
|
|
"name": "keyword.struct.go"
|
|
},
|
|
{
|
|
"match": "\\bimport\\b",
|
|
"name": "keyword.control.import.go"
|
|
},
|
|
{
|
|
"match": "\\btype\\b",
|
|
"name": "keyword.type.go"
|
|
}
|
|
]
|
|
},
|
|
"operators": {
|
|
"comment": "Note that the order here is very important!",
|
|
"patterns": [
|
|
{
|
|
"match": "((?:\\*|&)+)(?:(?!\\d)(?=(?:[\\w\\[\\]])|(?:\\<\\-)))",
|
|
"name": "keyword.operator.address.go"
|
|
},
|
|
{
|
|
"match": "<\\-",
|
|
"name": "keyword.operator.channel.go"
|
|
},
|
|
{
|
|
"match": "\\-\\-",
|
|
"name": "keyword.operator.decrement.go"
|
|
},
|
|
{
|
|
"match": "\\+\\+",
|
|
"name": "keyword.operator.increment.go"
|
|
},
|
|
{
|
|
"match": "(==|!=|<=|>=|<(?!<)|>(?!>))",
|
|
"name": "keyword.operator.comparison.go"
|
|
},
|
|
{
|
|
"match": "(&&|\\|\\||!)",
|
|
"name": "keyword.operator.logical.go"
|
|
},
|
|
{
|
|
"match": "(=|\\+=|\\-=|\\|=|\\^=|\\*=|/=|:=|%=|<<=|>>=|&\\^=|&=)",
|
|
"name": "keyword.operator.assignment.go"
|
|
},
|
|
{
|
|
"match": "(\\+|\\-|\\*|/|%)",
|
|
"name": "keyword.operator.arithmetic.go"
|
|
},
|
|
{
|
|
"match": "(&(?!\\^)|\\||\\^|&\\^|<<|>>|\\~)",
|
|
"name": "keyword.operator.arithmetic.bitwise.go"
|
|
},
|
|
{
|
|
"match": "\\.\\.\\.",
|
|
"name": "keyword.operator.ellipsis.go"
|
|
}
|
|
]
|
|
},
|
|
"runes": {
|
|
"patterns": [
|
|
{
|
|
"begin": "'",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.begin.go"
|
|
}
|
|
},
|
|
"end": "'",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.end.go"
|
|
}
|
|
},
|
|
"name": "string.quoted.rune.go",
|
|
"patterns": [
|
|
{
|
|
"match": "\\G(\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})|.)(?=')",
|
|
"name": "constant.other.rune.go"
|
|
},
|
|
{
|
|
"match": "[^']+",
|
|
"name": "invalid.illegal.unknown-rune.go"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"storage_types": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\bbool\\b",
|
|
"name": "storage.type.boolean.go"
|
|
},
|
|
{
|
|
"match": "\\bbyte\\b",
|
|
"name": "storage.type.byte.go"
|
|
},
|
|
{
|
|
"match": "\\berror\\b",
|
|
"name": "storage.type.error.go"
|
|
},
|
|
{
|
|
"match": "\\b(complex(64|128)|float(32|64)|u?int(8|16|32|64)?)\\b",
|
|
"name": "storage.type.numeric.go"
|
|
},
|
|
{
|
|
"match": "\\brune\\b",
|
|
"name": "storage.type.rune.go"
|
|
},
|
|
{
|
|
"match": "\\bstring\\b",
|
|
"name": "storage.type.string.go"
|
|
},
|
|
{
|
|
"match": "\\buintptr\\b",
|
|
"name": "storage.type.uintptr.go"
|
|
},
|
|
{
|
|
"match": "\\bany\\b",
|
|
"name": "entity.name.type.any.go"
|
|
}
|
|
]
|
|
},
|
|
"raw_strings_literals": {
|
|
"comment": "Raw string literals",
|
|
"begin": "`",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.begin.go"
|
|
}
|
|
},
|
|
"end": "`",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.end.go"
|
|
}
|
|
},
|
|
"name": "string.quoted.raw.go",
|
|
"patterns": [
|
|
{
|
|
"include": "#string_placeholder"
|
|
}
|
|
]
|
|
},
|
|
"string_literals": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Interpreted string literals",
|
|
"begin": "\"",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.begin.go"
|
|
}
|
|
},
|
|
"end": "\"",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.end.go"
|
|
}
|
|
},
|
|
"name": "string.quoted.double.go",
|
|
"patterns": [
|
|
{
|
|
"include": "#string_escaped_char"
|
|
},
|
|
{
|
|
"include": "#string_placeholder"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"string_escaped_char": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})",
|
|
"name": "constant.character.escape.go"
|
|
},
|
|
{
|
|
"match": "\\\\[^0-7xuUabfnrtv\\'\"]",
|
|
"name": "invalid.illegal.unknown-escape.go"
|
|
}
|
|
]
|
|
},
|
|
"string_placeholder": {
|
|
"patterns": [
|
|
{
|
|
"match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGspw]",
|
|
"name": "constant.other.placeholder.go"
|
|
}
|
|
]
|
|
},
|
|
"numeric_literals": {
|
|
"match": "(?<!\\w)\\.?\\d(?:(?:[0-9a-zA-Z_\\.])|(?<=[eEpP])[+-])*",
|
|
"captures": {
|
|
"0": {
|
|
"patterns": [
|
|
{
|
|
"begin": "(?=.)",
|
|
"end": "(?:\\n|$)",
|
|
"patterns": [
|
|
{
|
|
"match": "(?:(?:(?:(?:(?:\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)((?:(?<=[0-9])\\.|\\.(?=[0-9])))([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)?(?:(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)))?(i(?!\\w))?(?:\\n|$)|\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|\\G((?:(?<=[0-9])\\.|\\.(?=[0-9])))([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?:(?<!_)([eE])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)))?(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)((?:(?<=[0-9a-fA-F])\\.|\\.(?=[0-9a-fA-F])))([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)?(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))|(\\G0[xX])((?:(?<=[0-9a-fA-F])\\.|\\.(?=[0-9a-fA-F])))([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(?<!_)([pP])(\\+?)(\\-?)((?:[0-9](?:[0-9]|(?:(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*))(i(?!\\w))?(?:\\n|$))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "constant.numeric.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"3": {
|
|
"name": "constant.numeric.decimal.point.go"
|
|
},
|
|
"4": {
|
|
"name": "constant.numeric.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"5": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"6": {
|
|
"name": "keyword.other.unit.exponent.decimal.go"
|
|
},
|
|
"7": {
|
|
"name": "keyword.operator.plus.exponent.decimal.go"
|
|
},
|
|
"8": {
|
|
"name": "keyword.operator.minus.exponent.decimal.go"
|
|
},
|
|
"9": {
|
|
"name": "constant.numeric.exponent.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"10": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"11": {
|
|
"name": "constant.numeric.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"12": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"13": {
|
|
"name": "keyword.other.unit.exponent.decimal.go"
|
|
},
|
|
"14": {
|
|
"name": "keyword.operator.plus.exponent.decimal.go"
|
|
},
|
|
"15": {
|
|
"name": "keyword.operator.minus.exponent.decimal.go"
|
|
},
|
|
"16": {
|
|
"name": "constant.numeric.exponent.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"17": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"18": {
|
|
"name": "constant.numeric.decimal.point.go"
|
|
},
|
|
"19": {
|
|
"name": "constant.numeric.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"20": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"21": {
|
|
"name": "keyword.other.unit.exponent.decimal.go"
|
|
},
|
|
"22": {
|
|
"name": "keyword.operator.plus.exponent.decimal.go"
|
|
},
|
|
"23": {
|
|
"name": "keyword.operator.minus.exponent.decimal.go"
|
|
},
|
|
"24": {
|
|
"name": "constant.numeric.exponent.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"25": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"26": {
|
|
"name": "keyword.other.unit.hexadecimal.go"
|
|
},
|
|
"27": {
|
|
"name": "constant.numeric.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"28": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"29": {
|
|
"name": "constant.numeric.hexadecimal.go"
|
|
},
|
|
"30": {
|
|
"name": "constant.numeric.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"31": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"32": {
|
|
"name": "keyword.other.unit.exponent.hexadecimal.go"
|
|
},
|
|
"33": {
|
|
"name": "keyword.operator.plus.exponent.hexadecimal.go"
|
|
},
|
|
"34": {
|
|
"name": "keyword.operator.minus.exponent.hexadecimal.go"
|
|
},
|
|
"35": {
|
|
"name": "constant.numeric.exponent.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"36": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"37": {
|
|
"name": "keyword.other.unit.hexadecimal.go"
|
|
},
|
|
"38": {
|
|
"name": "constant.numeric.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"39": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"40": {
|
|
"name": "keyword.other.unit.exponent.hexadecimal.go"
|
|
},
|
|
"41": {
|
|
"name": "keyword.operator.plus.exponent.hexadecimal.go"
|
|
},
|
|
"42": {
|
|
"name": "keyword.operator.minus.exponent.hexadecimal.go"
|
|
},
|
|
"43": {
|
|
"name": "constant.numeric.exponent.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"44": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"45": {
|
|
"name": "keyword.other.unit.hexadecimal.go"
|
|
},
|
|
"46": {
|
|
"name": "constant.numeric.hexadecimal.go"
|
|
},
|
|
"47": {
|
|
"name": "constant.numeric.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"48": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"49": {
|
|
"name": "keyword.other.unit.exponent.hexadecimal.go"
|
|
},
|
|
"50": {
|
|
"name": "keyword.operator.plus.exponent.hexadecimal.go"
|
|
},
|
|
"51": {
|
|
"name": "keyword.operator.minus.exponent.hexadecimal.go"
|
|
},
|
|
"52": {
|
|
"name": "constant.numeric.exponent.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"53": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"match": "(?:(?:(?:\\G(?=[0-9.])(?!0[xXbBoO])([0-9](?:[0-9]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$)|(\\G0[bB])_?([01](?:[01]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$))|(\\G0[oO]?)_?((?:[0-7]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))+)(i(?!\\w))?(?:\\n|$))|(\\G0[xX])_?([0-9a-fA-F](?:[0-9a-fA-F]|((?<=[0-9a-fA-F])_(?=[0-9a-fA-F])))*)(i(?!\\w))?(?:\\n|$))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "constant.numeric.decimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"3": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"4": {
|
|
"name": "keyword.other.unit.binary.go"
|
|
},
|
|
"5": {
|
|
"name": "constant.numeric.binary.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"6": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"7": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"8": {
|
|
"name": "keyword.other.unit.octal.go"
|
|
},
|
|
"9": {
|
|
"name": "constant.numeric.octal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"10": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"11": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
},
|
|
"12": {
|
|
"name": "keyword.other.unit.hexadecimal.go"
|
|
},
|
|
"13": {
|
|
"name": "constant.numeric.hexadecimal.go",
|
|
"patterns": [
|
|
{
|
|
"match": "(?<=[0-9a-fA-F])_(?=[0-9a-fA-F])",
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"14": {
|
|
"name": "punctuation.separator.constant.numeric.go"
|
|
},
|
|
"15": {
|
|
"name": "keyword.other.unit.imaginary.go"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"match": "(?:(?:[0-9a-zA-Z_\\.])|(?<=[eEpP])[+-])+",
|
|
"name": "invalid.illegal.constant.numeric.go"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"terminators": {
|
|
"comment": "Terminators",
|
|
"match": ";",
|
|
"name": "punctuation.terminator.go"
|
|
},
|
|
"package_name": {
|
|
"patterns": [
|
|
{
|
|
"comment": "package name",
|
|
"begin": "\\b(package)\\s+",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.package.go"
|
|
}
|
|
},
|
|
"end": "(?!\\G)",
|
|
"patterns": [
|
|
{
|
|
"match": "\\d\\w*",
|
|
"name": "invalid.illegal.identifier.go"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.package.go"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"import": {
|
|
"comment": "import",
|
|
"patterns": [
|
|
{
|
|
"comment": "import",
|
|
"begin": "\\b(import)\\s+",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.control.import.go"
|
|
}
|
|
},
|
|
"end": "(?!\\G)",
|
|
"patterns": [
|
|
{
|
|
"include": "#imports"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"imports": {
|
|
"comment": "import package(s)",
|
|
"patterns": [
|
|
{
|
|
"match": "(\\s*[\\w\\.]+)?\\s*((\")([^\"]*)(\"))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.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"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.imports.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.imports.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#imports"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"function_declaration": {
|
|
"comment": "Function declarations",
|
|
"begin": "(?:^(\\bfunc\\b)(?:\\s*(\\([^\\)]+\\)\\s*)?(?:(\\w+)(?=\\(|\\[))?))",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.function.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"match": "(?:(\\w+(?:\\s+))?((?:[\\w\\.\\*]+)(?:\\[(?:(?:(?:[\\w\\.\\*]+)(?:\\,\\s+)?)+)?\\])?))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "variable.parameter.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\d\\w*",
|
|
"name": "invalid.illegal.identifier.go"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.function.go"
|
|
}
|
|
]
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
}
|
|
]
|
|
},
|
|
"end": "(?:(?<=\\))\\s*((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?!(?:[\\[\\]\\*]+)?(?:\\bstruct\\b|\\binterface\\b))[\\w\\.\\-\\*\\[\\]]+)?\\s*(?=\\{))",
|
|
"endCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function_param_types"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "(?:([\\w\\.\\*]+)?(\\[))",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#generic_param_types"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"comment": "single function as a type returned type(s) declaration",
|
|
"match": "(?:(?<=\\))\\s+((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?[\\w\\*\\.\\[\\]\\<\\>\\-]+(?:\\s*)(?:\\/(?:\\/|\\*).*)?)$)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"function_param_types": {
|
|
"comment": "function parameter variables and types",
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variables_types"
|
|
},
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"comment": "struct type declaration",
|
|
"match": "((?:(?:\\w+\\,\\s*)+)?\\w+)\\s+(?=(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\[\\]\\*]+)?\\bstruct\\b\\s*\\{)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.parameter.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "multiple parameters one type -with multilines",
|
|
"match": "(?:(?:(?<=\\()|^\\s*)((?:(?:\\w+\\,\\s*)+)(?:/(?:/|\\*).*)?)$)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.parameter.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "multiple params and types | multiple params one type | one param one type",
|
|
"match": "(?:((?:(?:\\w+\\,\\s*)+)?\\w+)(?:\\s+)((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\[\\]\\.\\*]+)?(?:(?:\\bfunc\\b\\((?:[^\\)]+)?\\))(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*))+(?:(?:(?:[\\w\\*\\.\\[\\]]+)|(?:\\((?:[^\\)]+)?\\))))?)|(?:(?:[\\[\\]\\*]+)?[\\w\\*\\.]+(?:\\[(?:[^\\]]+)\\])?(?:[\\w\\.\\*]+)?)+)))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.parameter.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"comment": "other types",
|
|
"match": "([\\w\\.]+)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"generic_param_types": {
|
|
"comment": "generic parameter variables and types",
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"comment": "multiple parameters one type -with multilines",
|
|
"match": "(?:(?:(?<=\\()|^\\s*)((?:(?:\\w+\\,\\s*)+)(?:/(?:/|\\*).*)?)$)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.parameter.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "multiple params and types | multiple types one param",
|
|
"match": "(?:((?:(?:\\w+\\,\\s*)+)?\\w+)(?:\\s+)((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\[\\]\\.\\*]+)?(?:(?:\\bfunc\\b\\((?:[^\\)]+)?\\))(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*))+(?:(?:(?:[\\w\\*\\.]+)|(?:\\((?:[^\\)]+)?\\))))?)|(?:(?:(?:[\\w\\*\\.\\~]+)|(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\]))(?:[\\w\\.\\*]+)?)+)))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.parameter.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"comment": "other types",
|
|
"match": "([\\w\\.]+)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"functions": {
|
|
"comment": "Functions",
|
|
"begin": "(?:(\\bfunc\\b)(?=\\())",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.function.go"
|
|
}
|
|
},
|
|
"end": "(?:(?<=\\))(\\s*(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?((?:(?:\\s*(?:(?:[\\[\\]\\*]+)?[\\w\\.\\*]+)?(?:(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\])|(?:\\((?:[^\\)]+)?\\)))?(?:[\\w\\.\\*]+)?)(?:\\s*)(?=\\{))|(?:\\s*(?:(?:(?:[\\[\\]\\*]+)?(?!\\bfunc\\b)(?:[\\w\\.\\*]+)(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\])?(?:[\\w\\.\\*]+)?)|(?:\\((?:[^\\)]+)?\\)))))?)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
}
|
|
]
|
|
},
|
|
"functions_inline": {
|
|
"comment": "functions in-line with multi return types",
|
|
"match": "(?:(\\bfunc\\b)((?:\\((?:.*)\\))(?:\\s+)(?:\\((?:.*)\\)))(?:\\s+)(?=\\{))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.function.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function_param_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": "\\[",
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\]",
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\{",
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
},
|
|
{
|
|
"match": "\\}",
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"support_functions": {
|
|
"comment": "Support Functions",
|
|
"match": "(?:(?:((?<=\\.)\\w+)|(\\w+))(\\[(?:.*)?\\])?(?=\\())",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.function.support.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\d\\w*",
|
|
"name": "invalid.illegal.identifier.go"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.function.support.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"match": "\\[",
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\]",
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"other_struct_interface_expressions": {
|
|
"patterns": [
|
|
{
|
|
"include": "#storage_types"
|
|
},
|
|
{
|
|
"include": "#label_loop_variable"
|
|
},
|
|
{
|
|
"include": "#property_variables"
|
|
},
|
|
{
|
|
"include": "#switch_select_case_variables"
|
|
},
|
|
{
|
|
"include": "#after_control_variables"
|
|
},
|
|
{
|
|
"comment": "struct expression before curly bracket",
|
|
"match": "((?:(?:\\w+\\.)+)?\\w+)(\\[(?:[^\\]]+)?\\])?(?=\\{)(?<!\\bstruct\\b|\\binterface\\b|\\bnil\\b|\\belse\\b|\\bif\\b|\\bfor\\b|\\bselect\\b|\\bswitch\\b|\\brange\\b|\\bcase\\b|\\bgo\\b|\\bdefault\\b|\\bdefer\\b|\\breturn\\b)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\[",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "struct/interface types in-line (type assertion) | switch type keyword",
|
|
"match": "(?:(?<=\\.\\()(?:(\\btype\\b)|((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?[\\w\\.\\[\\]\\*]+))(?=\\)))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.type.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"struct_variables_types": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Struct variable type",
|
|
"begin": "(\\bstruct\\b)\\s*(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.struct.go"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variables_types_fields"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
],
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"struct_variables_types_fields": {
|
|
"comment": "Struct variable type fields",
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variable_types_fields_multi"
|
|
},
|
|
{
|
|
"comment": "one line - single type",
|
|
"match": "(?:(?<=\\{)\\s*((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\w\\.\\*\\[\\]]+))\\s*(?=\\}))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "one line - property variables and types",
|
|
"match": "(?:(?<=\\{)\\s*((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\w\\.\\*\\[\\]]+))\\s*(?=\\}))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.property.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "one line with semicolon(;) without formatting gofmt - single type | property variables and types",
|
|
"match": "(?:(?<=\\{)((?:\\s*(?:(?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?(?:(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\w\\.\\*\\[\\]\\(\\)\\{\\}]+)(?:\\;)?))+)\\s*(?=\\}))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\w\\.\\*\\[\\]]+)(?:\\;)?))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.property.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "one type only",
|
|
"match": "(?:((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?<!\\,\\s*)(?:[\\w\\.\\*]+)\\s*(?:(?:(?:\".*\")|(?:\\`.*\\`))\\s*)?(?:/(?:/|\\*).*)?)$)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "property variables and types",
|
|
"match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))([\\s\\S]+))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.property.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"struct_variable_types_fields_multi": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Struct variable for struct in struct types",
|
|
"begin": "(?:\\s*)?([\\s\\,\\w]+)(?:\\s+)(?:(?:[\\[\\]\\*])+)?(\\bstruct\\b)\\s*(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.property.go"
|
|
},
|
|
"2": {
|
|
"name": "keyword.struct.go"
|
|
},
|
|
"3": {
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
}
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variables_types_fields"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"interface_variables_types": {
|
|
"patterns": [
|
|
{
|
|
"comment": "interface variable types",
|
|
"begin": "(\\binterface\\b)\\s*(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.interface.go"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function_param_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"include": "#support_functions"
|
|
},
|
|
{
|
|
"comment": "single declaration | with or declarations",
|
|
"match": "((?:\\s+\\|)?(?:[\\w\\.\\[\\]\\*]+)(?:\\s+\\|)?)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#generic_types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
],
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"single_type": {
|
|
"patterns": [
|
|
{
|
|
"comment": "single type declaration",
|
|
"match": "(?:(?:^|\\s+)(\\btype\\b)(?:\\s*)([\\w\\.\\*]+)(\\[(?:.*)\\])?(?:\\s+)((?!(?:[\\[\\]\\*]+)?(?:\\bstruct\\b|\\binterface\\b))([\\s\\S]+)))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.type.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\[",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#generic_param_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"4": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\(",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function_param_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#generic_types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"multi_types": {
|
|
"patterns": [
|
|
{
|
|
"comment": "multi type declaration",
|
|
"begin": "(\\btype\\b)\\s*(\\()",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.type.go"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variables_types"
|
|
},
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
],
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "single type declaration with multi-lines generics",
|
|
"begin": "(?:(?:^|\\s+)(\\btype\\b)(?:\\s*)([\\w\\.\\*]+)(?=\\[))",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.type.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"end": "(?:(?<=\\])((?:\\s+)(?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?!(?:[\\[\\]\\*]+)?(?:\\bstruct\\b|\\binterface\\b|\\bfunc\\b))[\\w\\.\\-\\*\\[\\]]+))?)",
|
|
"endCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#struct_variables_types"
|
|
},
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"after_control_variables": {
|
|
"patterns": [
|
|
{
|
|
"comment": "After control variables, to not highlight as a struct/interface",
|
|
"match": "(?:(?<=\\brange\\b|\\bswitch\\b|\\;|\\bif\\b|\\bfor\\b|\\<|\\>|\\<\\=|\\>\\=|\\=\\=|\\!\\=|\\w(?:\\+|/|\\-|\\*|\\%)(?:\\=)?|\\|\\||\\&\\&)(?:\\s*)([[:alnum:]\\-\\_\\!\\.\\[\\]\\<\\>\\=\\*/\\+\\%\\:]+)(?:\\s*)(?=\\{))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"match": "\\[",
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "\\]",
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"syntax_errors": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Syntax error using slices",
|
|
"match": "\\[\\](\\s+)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "invalid.illegal.slice.go"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "Syntax error numeric literals",
|
|
"match": "\\b0[0-7]*[89]\\d*\\b",
|
|
"name": "invalid.illegal.numeric.go"
|
|
}
|
|
]
|
|
},
|
|
"built_in_functions": {
|
|
"comment": "Built-in functions",
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(append|cap|close|complex|copy|delete|imag|len|panic|print|println|real|recover|min|max|clear)\\b(?=\\()",
|
|
"name": "entity.name.function.support.builtin.go"
|
|
},
|
|
{
|
|
"comment": "new keyword",
|
|
"begin": "(?:(\\bnew\\b)(\\())",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "entity.name.function.support.builtin.go"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#functions"
|
|
},
|
|
{
|
|
"include": "#struct_variables_types"
|
|
},
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#generic_types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"comment": "make keyword",
|
|
"match": "(?:(\\bmake\\b)(?:(\\()((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\w\\.\\*\\[\\]\\{\\}]+)(?:\\[(?:[^\\]]+)?\\])?(?:[\\w\\.\\*\\[\\]\\{\\}]+)?)?((?:\\,\\s*[\\w\\.\\(\\)]+)+)?(\\))))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.function.support.builtin.go"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations-without-brackets"
|
|
},
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"4": {
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"5": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"struct_interface_declaration": {
|
|
"comment": "struct, interface type declarations",
|
|
"match": "(?:(?:^|\\s+)(\\btype\\b)(?:\\s+)([\\w\\.]+)(\\[(?:.*)\\])?)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.type.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\[",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.begin.bracket.square.go"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.square.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#generic_param_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"switch_types": {
|
|
"begin": "(?<=\\bswitch\\b)(?:\\s*)(?:(\\w+\\s*\\:\\=)?\\s*([\\w\\.\\*\\(\\)\\[\\]]+))(\\.\\(\\btype\\b\\)\\s*)(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.assignment.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#support_functions"
|
|
},
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"include": "#brackets"
|
|
},
|
|
{
|
|
"match": "\\btype\\b",
|
|
"name": "keyword.type.go"
|
|
}
|
|
]
|
|
},
|
|
"4": {
|
|
"name": "punctuation.definition.begin.bracket.curly.go"
|
|
}
|
|
},
|
|
"end": "(?:\\})",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.curly.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:^\\s*(\\bcase\\b))(?:\\s+)([\\w\\.\\,\\*\\=\\<\\>\\!\\s]+)(:)(\\s*/(?:/|\\*)\\s*.*)?$",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.control.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"name": "punctuation.other.colon.go"
|
|
},
|
|
"4": {
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"var_const_single_assignment": {
|
|
"comment": "var and const with single type assignment",
|
|
"match": "(?:(?<=\\bvar\\b|\\bconst\\b)(?:\\s*)([\\w\\.]+(?:(?:\\,\\s*[\\w\\.]+)+)?)(?:\\s*)(?:(?!(?:(?:[\\[\\]\\*]+)?\\bstruct\\b\\s*\\{)|(?:(?:[\\[\\]\\*]+)?\\bfunc\\b))((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\.\\*]+)?(?:\\[(?:.*)\\])?(?:[\\w\\.\\*]+)?))?\\s*(?:\\=)?))?)",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.assignment.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#generic_types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"var_assignment": {
|
|
"comment": "variable assignment",
|
|
"match": "(?<!var)\\s*(\\w+(?:\\.\\w+)*(?>,\\s*\\w+(?:\\.\\w+)*)*)(?=\\s*=(?!=))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\d\\w*",
|
|
"name": "invalid.illegal.identifier.go"
|
|
},
|
|
{
|
|
"match": "\\w+(?:\\.\\w+)*",
|
|
"name": "variable.other.assignment.go",
|
|
"captures": {
|
|
"0": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "#delimiters"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"var_other_assignment": {
|
|
"comment": "variable other assignment",
|
|
"match": "\\b\\w+(?:,\\s*\\w+)*(?=\\s*:=)",
|
|
"captures": {
|
|
"0": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\d\\w*",
|
|
"name": "invalid.illegal.identifier.go"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.other.assignment.go"
|
|
},
|
|
{
|
|
"include": "#delimiters"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"var_const_multi_assignment": {
|
|
"patterns": [
|
|
{
|
|
"comment": "var and const with multi type assignment",
|
|
"begin": "(?:(?<=\\bvar\\b|\\bconst\\b)(?:\\s*)(\\())",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"match": "(?:(?:^\\s+)([\\w\\.]+(?:(?:\\,\\s*[\\w\\.]+)+)?)(?:\\s*)((?:(?!(?:(?:[\\[\\]\\*]+)?\\bstruct\\b\\s*\\{)|(?:(?:[\\[\\]\\*]+)?\\bfunc\\b))((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\.\\*]+)?(?:\\[(?:.*)\\])?(?:[\\w\\.\\*]+)?))?\\s*(?:\\=)?))?))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#delimiters"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.assignment.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#generic_types"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"generic_types": {
|
|
"comment": "Generic support for all types",
|
|
"match": "(?:([\\w\\.\\*]+)(\\[(?:[^\\]]+)?\\]))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#parameter-variable-types"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"switch_select_case_variables": {
|
|
"comment": "variables after case control keyword in switch/select expression",
|
|
"match": "(?:(?:^\\s*(\\bcase\\b))(?:\\s+)([\\s\\S]+(?:\\:)\\s*(?:/(?:/|\\*).*)?)$)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.control.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"include": "#support_functions"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.other.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"property_variables": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Property variables in struct",
|
|
"match": "(?:((?:[\\w\\.]+)(?:\\:))(?!\\=))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.other.property.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"comment": "property variables as parameter field in struct initialization",
|
|
"match": "(?<=[\\w\\.]\\:)(?:\\s*)([\\w\\.\\*\\&\\[\\]]+)(\\.\\w+)(?![\\w\\.\\*\\&\\[\\]]*(?:\\{|\\())",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.property.field.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"label_loop_variable": {
|
|
"comment": "labeled loop variable name",
|
|
"match": "((?:^\\s*\\w+:\\s*$)|(?:^\\s*(?:\\bbreak\\b|\\bgoto\\b|\\bcontinue\\b)\\s+\\w+(?:\\s*/(?:/|\\*)\\s*.*)?$))",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "variable.other.label.go"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"double_parentheses_types": {
|
|
"comment": "double parentheses types",
|
|
"match": "(?:(?:(\\()([^\\)]+)(\\)))(?=\\((?:[\\w\\.\\*\\&]+)\\)))",
|
|
"captures": {
|
|
"1": {
|
|
"name": "punctuation.definition.begin.bracket.round.go"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#type-declarations"
|
|
},
|
|
{
|
|
"match": "\\w+",
|
|
"name": "entity.name.type.go"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"name": "punctuation.definition.end.bracket.round.go"
|
|
}
|
|
}
|
|
},
|
|
"other_variables": {
|
|
"match": "(?:\\w+)",
|
|
"name": "variable.other.go",
|
|
"patterns": [
|
|
{
|
|
"include": "#storage_types"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
} |