{ "information_for_contributors": [ "This file has been converted from https://github.com/atom/language-go/blob/master/grammars/go.cson", "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." ], "scopeName": "source.go", "name": "Go", "comment": "Go language", "fileTypes": [ "go" ], "foldingStartMarker": "({|\\()\\s*$", "foldingStopMarker": "(}|\\))\\s*$", "patterns": [ { "include": "#comments" }, { "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" } ] }, { "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" } ] }, { "comment": "Syntax error receiving channels", "match": "<\\-([\\t ]+)chan\\b", "captures": { "1": { "name": "invalid.illegal.receive-channel.go" } } }, { "comment": "Syntax error sending channels", "match": "\\bchan([\\t ]+)<-", "captures": { "1": { "name": "invalid.illegal.send-channel.go" } } }, { "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" }, { "comment": "Built-in functions", "match": "\\b(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\\b(?=\\()", "name": "support.function.builtin.go" }, { "comment": "Function declarations", "match": "^(\\bfunc\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?(\\w+)(?=\\())?", "captures": { "1": { "name": "keyword.function.go" }, "2": { "patterns": [ { "include": "#brackets" }, { "include": "#operators" } ] }, "3": { "patterns": [ { "match": "\\d\\w*", "name": "invalid.illegal.identifier.go" }, { "match": "\\w+", "name": "entity.name.function.go" } ] } } }, { "comment": "Functions", "match": "(\\bfunc\\b)|(\\w+)(?=\\()", "captures": { "1": { "name": "keyword.function.go" }, "2": { "patterns": [ { "match": "\\d\\w*", "name": "invalid.illegal.identifier.go" }, { "match": "\\w+", "name": "support.function.go" } ] } } }, { "comment": "Floating-point literals", "match": "(\\.\\d+([Ee][-+]\\d+)?i?)\\b|\\b\\d+\\.\\d*(([Ee][-+]\\d+)?i?\\b)?", "name": "constant.numeric.floating-point.go" }, { "comment": "Integers", "match": "\\b((0x[0-9a-fA-F]+)|(0[0-7]+i?)|(\\d+([Ee]\\d+)?i?)|(\\d+[Ee][-+]\\d+i?))\\b", "name": "constant.numeric.integer.go" }, { "comment": "Language constants", "match": "\\b(true|false|nil|iota)\\b", "name": "constant.language.go" }, { "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.package.go" } ] }, { "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" } ] }, { "begin": "\\b(import)\\s+", "beginCaptures": { "1": { "name": "keyword.import.go" } }, "end": "(?!\\G)", "patterns": [ { "include": "#imports" } ] }, { "begin": "\\b(var)\\s+", "beginCaptures": { "1": { "name": "keyword.var.go" } }, "end": "(?!\\G)", "patterns": [ { "include": "#variables" } ] }, { "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": [ { "match": "\\'(\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})|\\p{Any})\\'", "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" } ] }, "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%tbcdoqxXUbeEfFgGsp]", "name": "constant.other.placeholder.go" } ] }, "variables": { "patterns": [ { "match": "(\\w+(?:,\\s*\\w+)*)(\\s+\\*?\\w+(?:\\.\\w+)?\\s*)?(?=\\s*=)", "captures": { "1": { "patterns": [ { "match": "\\d\\w*", "name": "invalid.illegal.identifier.go" }, { "match": "\\w+", "name": "variable.other.assignment.go" }, { "include": "#delimiters" } ] }, "2": { "patterns": [ { "include": "$self" } ] } } }, { "match": "(\\w+(?:,\\s*\\w+)*)(\\s+(\\[(\\d*|\\.\\.\\.)\\])*\\*?\\w+(?:\\.\\w+)?\\s*[^=].*)", "captures": { "1": { "patterns": [ { "match": "\\d\\w*", "name": "invalid.illegal.identifier.go" }, { "match": "\\w+", "name": "variable.other.declaration.go" }, { "include": "#delimiters" } ] }, "2": { "patterns": [ { "include": "$self" } ] } } }, { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.other.bracket.round.go" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.other.bracket.round.go" } }, "patterns": [ { "include": "$self" }, { "include": "#variables" } ] } ] } } }