{ "name": "Zig", "scopeName": "source.zig", "patterns": [ { "include": "#main" } ], "repository": { "block": { "contentName": "meta.block.zig", "begin": "([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")?\\s*(\\{)", "end": "(\\})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "storage.type.zig" }, "2": { "name": "punctuation.section.braces.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } }, "character_escapes": { "patterns": [ { "name": "constant.character.escape.newline.zig", "match": "\\\\n" }, { "name": "constant.character.escape.carrigereturn.zig", "match": "\\\\r" }, { "name": "constant.character.escape.tabulator.zig", "match": "\\\\t" }, { "name": "constant.character.escape.backslash.zig", "match": "\\\\\\\\" }, { "name": "constant.character.escape.single-quote.zig", "match": "\\\\'" }, { "name": "constant.character.escape.double-quote.zig", "match": "\\\\\\\"" }, { "name": "constant.character.escape.hexidecimal.zig", "match": "\\\\x[a-fA-F0-9]{2}" }, { "name": "constant.character.escape.hexidecimal.zig", "match": "\\\\u\\{[a-fA-F0-9]{1,6}\\}" } ] }, "comments": { "patterns": [ { "name": "comment.line.todo.zig", "match": "TODO" }, { "name": "comment.line.zig", "begin": "//[^/]", "end": "$\\n?", "patterns": [ { "include": "#todo" } ] }, { "name": "comment.line.documentation.zig", "begin": "///", "end": "$\\n?" } ] }, "constants": { "patterns": [ { "name": "constant.language.zig", "match": "\\b(null|undefined|true|false)\\b" }, { "name": "constant.numeric.integer.zig", "match": "\\b(?\u003c!\\.)(-?[0-9]+)(?!\\.)\\b" }, { "name": "constant.numeric.integer.hexadecimal.zig", "match": "\\b(?\u003c!\\.)(0x[a-fA-F0-9]+)(?!\\.)\\b" }, { "name": "constant.numeric.integer.octal.zig", "match": "\\b(?\u003c!\\.)(0o[0-7]+)(?!\\.)\\b" }, { "name": "constant.numeric.integer.binary.zig", "match": "\\b(?\u003c!\\.)(0b[01]+)(?!\\.)\\b" }, { "name": "constant.numeric.float.zig", "match": "(?\u003c!\\.)(-?\\b[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)(?!\\.)\\b" }, { "name": "constant.numeric.float.hexadecimal.zig", "match": "(?\u003c!\\.)(-?\\b0x[a-fA-F0-9]+(?:\\.[a-fA-F0-9]+)?[pP]?(?:[+-]?[0-9]+)?)(?!\\.)\\b" } ] }, "container_decl": { "patterns": [ { "contentName": "meta.union", "begin": "(?:([a-zA-Z_]\\w*|@\\\".+\\\")\\s*=\\s*)?\\b(packed|extern)?\\b\\s*(union\\b)(?:(\\()([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")(\\)))?\\s*({)", "end": "(})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "entity.name.union.zig" }, "2": { "name": "storage.modifier.zig" }, "3": { "name": "storage.type.union.zig" }, "4": { "name": "punctuation.section.parens.begin.zig" }, "5": { "name": "storage.type.zig" }, "6": { "name": "punctuation.section.parens.end.zig" }, "7": { "name": "punctuation.section.braces.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } }, { "contentName": "meta.struct.zig", "begin": "(?:([a-zA-Z_]\\w*|@\\\".+\\\")\\s*=\\s*)?\\b(packed|extern)?\\b\\s*(struct)\\s*({)", "end": "(})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "entity.name.struct.zig" }, "2": { "name": "storage.modifier.zig" }, "3": { "name": "storage.type.struct.zig" }, "4": { "name": "punctuation.section.braces.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } }, { "contentName": "meta.enum.zig", "begin": "(?:([a-zA-Z_]\\w*|@\\\".+\\\")\\s*=\\s*)?\\b(extern)?\\b\\s*(enum\\b)(?:(\\()([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")(\\)))?\\s*({)", "end": "(})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "entity.name.enum.zig" }, "2": { "name": "storage.modifier.zig" }, "3": { "name": "storage.type.enum.zig" }, "4": { "name": "punctuation.section.parens.begin.zig" }, "5": { "name": "storage.type.zig" }, "6": { "name": "punctuation.section.parens.end.zig" }, "7": { "name": "punctuation.section.braces.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } }, { "contentName": "meta.error.zig", "begin": "(?:([a-zA-Z_]\\w*|@\\\".+\\\")\\s*=\\s*)?\\b(error)\\b\\s*({)", "end": "(})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "entity.name.error.zig" }, "2": { "name": "storage.type.error.zig" }, "3": { "name": "punctuation.section.braces.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } }, { "match": "\\b(error)(\\.)([a-zA-Z_]\\w*|@\\\".+\\\")", "captures": { "1": { "name": "storage.type.error.zig" }, "2": { "name": "punctuation.accessor.zig" }, "3": { "name": "entity.name.error.zig" } } } ] }, "field_decl": { "contentName": "storage.type.zig", "begin": "([a-zA-Z_]\\w*|@\\\".+\\\")\\s*(:)\\s*", "end": "(?:(,)|(?:\\n|\\r))", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "variable.other.member.zig" }, "2": { "name": "punctuation.terminator.zig" } }, "endCaptures": { "1": { "name": "punctuation.separator.zig" } } }, "func_call": { "contentName": "meta.function-call.zig", "begin": "([a-zA-Z_]\\w*|@\\\".+\\\")(\\()", "end": "(\\))", "patterns": [ { "include": "#main" }, { "match": "(?:(,)|(?:\\)))", "captures": { "1": { "name": "punctuation.separator.zig" }, "2": { "name": "punctuation.section.parens.end.zig" } } } ], "beginCaptures": { "1": { "name": "variable.function.zig" }, "2": { "name": "punctuation.section.parens.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.parens.end.zig" } } }, "keywords": { "patterns": [ { "name": "keyword.control.zig", "match": "\\b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\\b" }, { "name": "keyword.control.async.zig", "match": "\\b(async|await|suspend|resume|cancel)\\b" }, { "name": "keyword.control.conditional.zig", "match": "\\b(if|else|switch|try|catch|orelse)\\b" }, { "name": "keyword.control.import.zig", "match": "(?\u003c!\\w)(@import|@cImport|@cInclude)\\b" }, { "name": "keyword.other.usingnamespace.zig", "match": "\\busingnamespace\\b" }, { "name": "keyword.other.test.zig", "match": "\\btest\\b" } ] }, "label": { "patterns": [ { "name": "entity.name.label.zig", "match": "(?\u003c!\\w):([a-zA-Z_]\\w*|@\\\".+\\\")" }, { "begin": "([a-zA-Z_]\\w*|@\\\".+\\\"):\\s*(?:({)|(while|for))", "end": "(})", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "entity.name.label.zig" }, "2": { "name": "punctuation.section.braces.begin.zig" }, "3": { "name": "keyword.control.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.braces.end.zig" } } } ] }, "main": { "patterns": [ { "contentName": "meta.parameters.zig", "begin": "\\b(fn)(\\()", "end": "(\\))\\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")?", "patterns": [ { "match": "([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")(,)?", "captures": { "1": { "name": "storage.type.zig" }, "2": { "name": "punctuation.separator.zig" } } } ], "beginCaptures": { "1": { "name": "storage.type.function.zig" }, "2": { "name": "punctuation.section.parens.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.parens.end.zig" }, "2": { "name": "storage.type.zig" } } }, { "contentName": "meta.function.parameters.zig", "begin": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")(\\()", "end": "(?\u003c=\\))\\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")?", "patterns": [ { "include": "#param_list" } ], "beginCaptures": { "1": { "name": "storage.type.function.zig" }, "2": { "name": "entity.name.function.zig" }, "3": { "name": "punctuation.section.parens.begin.zig" } }, "endCaptures": { "1": { "name": "storage.type.zig" } } }, { "match": "\\b(const|var)\\s+([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")\\s*(:)\\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")\\s*(=)", "captures": { "1": { "name": "storage.modifier.zig" }, "2": { "name": "variable.other.zig" }, "3": { "name": "punctuation.terminator.zig" }, "4": { "name": "storage.type.zig" }, "5": { "name": "keyword.operator.assignment.zig" } } }, { "include": "#func_call" }, { "include": "#label" }, { "include": "#punctuation" }, { "include": "#storage_modifier" }, { "include": "#container_decl" }, { "include": "#constants" }, { "include": "#comments" }, { "include": "#strings" }, { "include": "#storage" }, { "include": "#keywords" }, { "include": "#operators" }, { "include": "#support" }, { "include": "#field_decl" }, { "include": "#block" } ] }, "operators": { "patterns": [ { "name": "keyword.operator.zig", "match": "\\b!\\b" }, { "name": "keyword.operator.logical.zig", "match": "(==|(?:!|\u003e|\u003c)=?)" }, { "name": "keyword.operator.word.zig", "match": "\\b(and|or)\\b" }, { "name": "keyword.operator.assignment.zig", "match": "((?:(?:\\+|-|\\*)\\%?|/|%|\u003c\u003c|\u003e\u003e|\u0026|\\|(?=[^\\|])|\\^)?=)" }, { "name": "keyword.operator.arithmetic.zig", "match": "((?:\\+|-|(?\u003c=\\w)\\s*\\*)\\%?|/(?!/)|%)" }, { "name": "keyword.operator.bitwise.zig", "match": "(\u003c\u003c|\u003e\u003e|\u0026(?=\\W)|\\|(?=[^\\|])|\\^|~)" }, { "name": "keyword.operator.other.zig", "match": "(\\+\\+|\\*\\*|-\u003e|\\.\\?|\\.\\*|\u0026(?=\\w)|\\?|\\|\\||\\.\\.|\\.\\.\\.)" } ] }, "param_list": { "contentName": "storage.type.zig", "begin": "(comptime|noalias)?\\s*([a-zA-Z_][a-zA-Z0-9_.]*|@\\\".+\\\")\\s*(:)\\s*", "end": "(?:(,)|(?:\\)))", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "storage.modifier.zig" }, "2": { "name": "variable.parameter.zig" }, "3": { "name": "punctuation.terminator.zig" } }, "endCaptures": { "1": { "name": "punctuation.separator.zig" }, "2": { "name": "punctuation.section.parens.end.zig" } } }, "punctuation": { "patterns": [ { "name": "punctuation.separator.zig", "match": "," }, { "name": "punctuation.terminator.zig", "match": ";" }, { "contentName": "meta.group.zig", "begin": "(\\()", "end": "(\\))", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "punctuation.section.parens.begin.zig" } }, "endCaptures": { "1": { "name": "punctuation.section.parens.end.zig" } } } ] }, "storage": { "patterns": [ { "name": "storage.type.zig", "match": "\\b(bool|void|noreturn|type|anyerror|promise)\\b" }, { "name": "storage.type.integer.zig", "match": "\\b(?\u003c!\\.)([iu][0-9]\\d*|[iu]size|comptime_int)\\b" }, { "name": "storage.type.float.zig", "match": "\\b(f16|f32|f64|f128|comptime_float)\\b" }, { "name": "storage.type.c_compat.zig", "match": "\\b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\\b" } ] }, "storage_modifier": { "name": "storage.modifier.zig", "match": "\\b(const|var|extern|packed|export|pub|noalias|inline|comptime|nakedcc|stdcallcc|volatile|align|linksection|threadlocal|allowzero)\\b" }, "strings": { "patterns": [ { "name": "string.quoted.single.zig", "begin": "\\'", "end": "\\'", "patterns": [ { "include": "#character_escapes" }, { "name": "invalid.illegal.character.zig", "match": "\\\\[^\\'][^\\']*?" } ] }, { "name": "string.quoted.double.zig", "begin": "c?\\\"", "end": "\\\"", "patterns": [ { "include": "#character_escapes" }, { "name": "invalid.illegal.character.zig", "match": "\\\\[^\\'][^\\']*?" } ] }, { "name": "string.quoted.other.zig", "begin": "c?\\\\\\\\", "end": "$\\n?" } ] }, "support": { "name": "support.function.zig", "match": "(?\u003c!\\w)@[^\\\"\\d][a-zA-Z_]\\w*\\b" } } }