{ "name": "V", "scopeName": "source.v", "patterns": [ { "include": "#comments" }, { "include": "#as-is" }, { "include": "#attributes" }, { "include": "#assignment" }, { "include": "#module-decl" }, { "include": "#import-decl" }, { "include": "#include-decl" }, { "include": "#flag-decl" }, { "include": "#brackets" }, { "include": "#builtin-fix" }, { "include": "#escaped-fix" }, { "include": "#operators" }, { "include": "#function-limited-overload-decl" }, { "include": "#function-extend-decl" }, { "include": "#function-decl" }, { "include": "#function-exist" }, { "include": "#generic" }, { "include": "#constants" }, { "include": "#type" }, { "include": "#enum" }, { "include": "#interface" }, { "include": "#struct" }, { "include": "#keywords" }, { "include": "#storage" }, { "include": "#numbers" }, { "include": "#strings" }, { "include": "#types" } ], "repository": { "as-is": { "begin": "\\s+(as|is)\\s+", "end": "([\\w.]*)", "beginCaptures": { "1": { "name": "keyword.$1.v" } }, "endCaptures": { "1": { "name": "entity.name.alias.v" } } }, "assignment": { "name": "meta.definition.variable.v", "match": "([\\w.]+)\\s*((?:\\:|\\+|\\-|\\*|\\/|\\%|\\\u0026|\\||\\^)?=)\\s*(?=.+)", "captures": { "1": { "patterns": [ { "include": "#illegal-name" }, { "name": "variable.assignment.other.v", "match": "\\w+" } ] }, "2": { "patterns": [ { "include": "#operators" } ] } } }, "attributes": { "name": "meta.definition.attribute.v", "match": "^\\s*((\\[)(deprecated|unsafe_fn|typedef|live|inline|flag)(\\]))", "captures": { "1": { "name": "meta.function.attribute.v" }, "2": { "name": "punctuation.definition.begin.bracket.square.v" }, "3": { "name": "storage.modifier.attribute.v" }, "4": { "name": "punctuation.definition.end.bracket.square.v" } } }, "brackets": { "patterns": [ { "begin": "{", "end": "}", "patterns": [ { "include": "$self" } ], "beginCaptures": { "0": { "name": "punctuation.definition.bracket.curly.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.bracket.curly.end.v" } } }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "$self" } ], "beginCaptures": { "0": { "name": "punctuation.definition.bracket.round.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.bracket.round.end.v" } } }, { "begin": "\\[", "end": "\\]", "patterns": [ { "include": "$self" } ], "beginCaptures": { "0": { "name": "punctuation.definition.bracket.square.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.bracket.square.end.v" } } } ] }, "builtin-fix": { "patterns": [ { "patterns": [ { "name": "storage.modifier.v", "match": "(const)(?=\\s*\\()" }, { "name": "keyword.$1.v", "match": "\\b(fn|type|enum|struct|interface|map|assert|sizeof)\\b(?=\\s*\\()" } ] }, { "patterns": [ { "name": "keyword.control.v", "match": "(\\$if|\\$else)(?=\\s*\\()" }, { "name": "keyword.control.v", "match": "\\b(as|in|is|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\\b(?=\\s*\\()" } ] }, { "patterns": [ { "name": "meta.expr.numeric.cast.v", "match": "(i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64))(?=\\s*\\()", "captures": { "1": { "name": "storage.type.numeric.v" } } }, { "name": "meta.expr.bool.cast.v", "match": "(bool|byte|byteptr|charptr|voidptr|string|ustring|rune)(?=\\s*\\()", "captures": { "1": { "name": "storage.type.$1.v" } } } ] } ] }, "comments": { "patterns": [ { "name": "comment.block.documentation.v", "begin": "/\\*", "end": "\\*/", "patterns": [ { "include": "#comments" } ], "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.comment.end.v" } } }, { "name": "comment.line.double-slash.v", "begin": "//", "end": "$", "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.v" } } } ] }, "constants": { "name": "constant.language.v", "match": "\\b(true|false|none)\\b" }, "enum": { "name": "meta.definition.enum.v", "match": "^\\s*(?:(pub)?\\s+)?(enum)\\s+(?:\\w+\\.)?(\\w*)", "captures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "storage.type.enum.v" }, "3": { "name": "entity.name.enum.v" } } }, "escaped-fix": { "name": "meta.escaped.keyword.v", "match": "((?:@)(?:mut|var|pub|fn|unsafe|module|import|as|const|map|assert|sizeof|type|struct|interface|enum|in|is|or|match|if|else|for|go|goto|defer|return|i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64)|bool|byte|byteptr|charptr|voidptr|string|ustring|rune))", "captures": { "0": { "name": "keyword.other.escaped.v" } } }, "flag-decl": { "name": "meta.flag.v", "begin": "^\\s*(#flag)", "end": "\\s+(.*?)$", "beginCaptures": { "1": { "name": "keyword.flag.v" } }, "endCaptures": { "1": { "name": "string.quoted.single.v" } } }, "function-decl": { "name": "meta.definition.function.v", "begin": "^\\s*(pub)?\\s*(fn)\\s+", "end": "(?:(?:C\\.)?)(\\w+)\\s*((?\u003c=[\\w\\s+])(\\\u003c)(\\w+)(\\\u003e))?", "beginCaptures": { "1": { "name": "storage.modifier.v" }, "2": { "name": "keyword.function.v" } }, "endCaptures": { "1": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.function.v", "match": "\\w+" } ] }, "2": { "patterns": [ { "include": "#generic" } ] } } }, "function-exist": { "name": "meta.support.function.v", "match": "(\\w+)((?\u003c=[\\w\\s+])(\\\u003c)(\\w+)(\\\u003e))?(?=\\s*\\()", "captures": { "0": { "name": "meta.function.call.v" }, "1": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.function.v", "match": "\\w+" } ] }, "2": { "patterns": [ { "include": "#generic" } ] } } }, "function-extend-decl": { "name": "meta.definition.function.v", "match": "^\\s*(pub)?\\s*(fn)\\s*(\\()([^\\)]*)(\\))\\s*(?:(?:C\\.)?)(\\w+)\\s*((?\u003c=[\\w\\s+])(\\\u003c)(\\w+)(\\\u003e))?", "captures": { "1": { "name": "storage.modifier.v" }, "2": { "name": "keyword.function.v" }, "3": { "name": "punctuation.definition.bracket.round.begin.v" }, "4": { "patterns": [ { "include": "#brackets" }, { "include": "#storage" }, { "include": "#generic" }, { "include": "#types" }, { "include": "#punctuation" } ] }, "5": { "name": "punctuation.definition.bracket.round.end.v" }, "6": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.function.v", "match": "\\w+" } ] }, "7": { "patterns": [ { "include": "#generic" } ] } } }, "function-limited-overload-decl": { "name": "meta.definition.function.v", "match": "^\\s*(pub)?\\s*(fn)\\s*(\\()([^\\)]*)(\\))\\s*([\\+\\-\\*\\/])?\\s*(\\()([^\\)]*)(\\))\\s*(?:(?:C\\.)?)(\\w+)", "captures": { "1": { "name": "storage.modifier.v" }, "10": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.function.v", "match": "\\w+" } ] }, "2": { "name": "keyword.function.v" }, "3": { "name": "punctuation.definition.bracket.round.begin.v" }, "4": { "patterns": [ { "include": "#brackets" }, { "include": "#storage" }, { "include": "#generic" }, { "include": "#types" }, { "include": "#punctuation" } ] }, "5": { "name": "punctuation.definition.bracket.round.end.v" }, "6": { "patterns": [ { "include": "#operators" } ] }, "7": { "name": "punctuation.definition.bracket.round.begin.v" }, "8": { "patterns": [ { "include": "#brackets" }, { "include": "#storage" }, { "include": "#generic" }, { "include": "#types" }, { "include": "#punctuation" } ] }, "9": { "name": "punctuation.definition.bracket.round.end.v" } } }, "generic": { "patterns": [ { "name": "meta.definition.generic.v", "match": "(?\u003c=[\\w\\s+])(\\\u003c)(\\w+)(\\\u003e)", "captures": { "1": { "name": "punctuation.definition.bracket.angle.begin.v" }, "2": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.generic.v", "match": "\\w+" } ] }, "3": { "name": "punctuation.definition.bracket.angle.end.v" } } } ] }, "illegal-name": { "name": "invalid.illegal.v", "match": "\\d\\w+" }, "import-decl": { "name": "meta.import.v", "begin": "^\\s*(import)\\s+", "end": "([\\w.]+)", "beginCaptures": { "1": { "name": "keyword.import.v" } }, "endCaptures": { "1": { "name": "entity.name.import.v" } } }, "include-decl": { "patterns": [ { "name": "meta.include.v", "begin": "^\\s*(#include)", "end": "\\s+([0-9a-zA-Z_]+)", "beginCaptures": { "1": { "name": "keyword.include.v" } }, "endCaptures": { "1": { "name": "entity.include.additional.value.v" } } }, { "name": "meta.include.v", "begin": "^\\s*(#include)", "end": "\\s+(([\\\u003c\"])\\s*(.*)([\\\u003e\"]))", "beginCaptures": { "1": { "name": "keyword.include.v" } }, "endCaptures": { "1": { "name": "string.quoted.double.v" } } } ] }, "interface": { "name": "meta.definition.interface.v", "match": "^\\s*(?:(pub)?\\s+)?(interface)\\s+(\\w*)", "captures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "keyword.interface.v" }, "3": { "patterns": [ { "include": "#illegal-name" }, { "name": "entity.name.interface.v", "match": "\\w+" } ] } } }, "keywords": { "patterns": [ { "name": "keyword.control.v", "match": "(\\$if|\\$else)" }, { "name": "keyword.control.v", "match": "\\b(as|it|is|in|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\\b" }, { "name": "keyword.$1.v", "match": "\\b(fn|type|enum|struct|interface|map|assert|sizeof)\\b" } ] }, "module-decl": { "name": "meta.module.v", "begin": "^\\s*(module)\\s+", "end": "([\\w.]+)", "beginCaptures": { "1": { "name": "keyword.module.v" } }, "endCaptures": { "1": { "name": "entity.name.module.v" } } }, "numbers": { "patterns": [ { "name": "constant.numeric.float.v", "match": "(?:(?:[-]?)(?:[0-9e]*)(?:[.]){1}(?:[0-9]+))" }, { "name": "constant.numeric.exponental.v", "match": "[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)" }, { "name": "constant.numeric.binary.v", "match": "\\b(?:0[b])(?:[0-1]+)" }, { "name": "constant.numeric.octal.v", "match": "\\b(?:0[o])(?:[0-7]+)" }, { "name": "constant.numeric.hex.v", "match": "\\b(?:0[x])(?:[0-9a-fA-F]+)" }, { "name": "constant.numeric.integer.v", "match": "\\b(?:[-]?)(?:[0-9]+)" } ] }, "operators": { "patterns": [ { "name": "keyword.operator.arithmethic.v", "match": "(\\+|\\-|\\*|\\/|\\%|\\+\\+|\\-\\-)" }, { "name": "keyword.operator.assignment.v", "match": "(\\:\\=|\\=|\\+\\=|\\-\\=|\\*\\=|\\/\\=|\\%\\=|\\\u0026\\=|\\|\\=|\\^\\=|\\\u0026\\\u0026\\=|\\|\\|\\=|\\\u003e\\\u003e\\=|\\\u003c\\\u003c\\=)" }, { "name": "keyword.operator.bitwise.v", "match": "(\\\u0026|\\||\\^|\u003c(?!\u003c)|\u003e(?!\u003e))" }, { "name": "keyword.operator.logical.v", "match": "(\\\u0026\\\u0026|\\|\\||\\!)" }, { "name": "keyword.operator.relation.v", "match": "(\\=\\=|\\!\\=|\\\u003e|\\\u003c|\\\u003e\\=|\\\u003c\\=)" } ] }, "punctuation": { "patterns": [ { "name": "punctuation.delimiter.period.dot.v", "match": "\\." }, { "name": "punctuation.delimiter.comma.v", "match": "," }, { "name": "punctuation.separator.key-value.colon.v", "match": ":" }, { "name": "punctuation.definition.other.semicolon.v", "match": ";" }, { "name": "punctuation.definition.other.questionmark.v", "match": "\\?" } ] }, "storage": { "name": "storage.modifier.v", "match": "\\b(const|mut|var|pub)\\b" }, "string-escaped-char": { "patterns": [ { "name": "constant.character.escape.v", "match": "\\\\([0-7]{3}|[\\$abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})" }, { "name": "invalid.illegal.unknown-escape.v", "match": "\\\\[^0-7\\$xuUabfnrtv\\'\"]" } ] }, "string-interpolation": { "name": "meta.string.interpolation.v", "match": "(\\$([\\w.]+|\\{.*?\\}))", "captures": { "1": { "patterns": [ { "name": "invalid.illegal.v", "match": "\\$\\d[\\.\\w]+" }, { "name": "variable.other.interpolated.v", "match": "\\$([\\.\\w]+|\\{.*?\\})" } ] } } }, "string-placeholder": { "name": "constant.other.placeholder.v", "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]" }, "strings": { "patterns": [ { "name": "string.quoted.raw.v", "begin": "`", "end": "`", "patterns": [ { "include": "#string-escaped-char" }, { "include": "#string-interpolation" }, { "include": "#string-placeholder" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.raw.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.raw.end.v" } } }, { "name": "string.quoted.single.v", "begin": "'", "end": "'", "patterns": [ { "include": "#string-escaped-char" }, { "include": "#string-interpolation" }, { "include": "#string-placeholder" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.single.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.single.end.v" } } }, { "name": "string.quoted.double.v", "begin": "\"", "end": "\"", "patterns": [ { "include": "#string-escaped-char" }, { "include": "#string-interpolation" }, { "include": "#string-placeholder" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.double.begin.v" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.double.end.v" } } } ] }, "struct": { "patterns": [ { "name": "meta.definition.struct.v", "begin": "^\\s*(?:(mut|var|pub(?:\\s+mut|var)?|__global)\\s+)?(struct)\\s+([\\w.]+)\\s*({)", "end": "\\s*(})", "patterns": [ { "include": "#struct-access-modifier" }, { "match": "\\b(\\w+)\\s+([\\w\\[\\]\\*\u0026.]+)(?:\\s*(=)\\s*((?:.(?=$|//|/\\*))*+))?", "captures": { "1": { "name": "variable.other.property.v" }, "2": { "patterns": [ { "include": "#numbers" }, { "include": "#brackets" }, { "include": "#types" }, { "name": "storage.type.other.v", "match": "\\w+" } ] }, "3": { "name": "keyword.operator.assignment.v" }, "4": { "patterns": [ { "include": "$self" } ] } } }, { "include": "#types" }, { "include": "$self" } ], "beginCaptures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "storage.type.struct.v" }, "3": { "name": "entity.name.struct.v" }, "4": { "name": "punctuation.definition.bracket.curly.begin.v" } }, "endCaptures": { "1": { "name": "punctuation.definition.bracket.curly.end.v" } } }, { "name": "meta.definition.struct.v", "match": "^\\s*(?:(mut|var|pub(?:\\s+mut|var)?|__global))\\s+?(struct)\\s+(?:\\s+([\\w.]+))?", "captures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "storage.type.struct.v" }, "3": { "name": "entity.name.struct.v" } } } ] }, "struct-access-modifier": { "match": "(?\u003c=\\s|^)(mut|var|pub(?:\\s+mut|var)?|__global)(:|\\b)", "captures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "punctuation.separator.struct.key-value.v" } } }, "type": { "name": "meta.definition.type.v", "match": "^\\s*(?:(pub)?\\s+)?(type)\\s+(\\w*)\\s+(?:\\w+\\.+)?(\\w*)", "captures": { "1": { "name": "storage.modifier.$1.v" }, "2": { "name": "storage.type.type.v" }, "3": { "patterns": [ { "include": "#illegal-name" }, { "include": "#types" }, { "name": "entity.name.type.v", "match": "\\w+" } ] }, "4": { "patterns": [ { "include": "#illegal-name" }, { "include": "#types" }, { "name": "entity.name.type.v", "match": "\\w+" } ] } } }, "types": { "patterns": [ { "name": "storage.type.numeric.v", "match": "\\b(i(8|16|nt|64|128)|u(8|16|32|64|128)|f(32|64))\\b" }, { "name": "storage.type.$1.v", "match": "\\b(bool|byte|byteptr|charptr|voidptr|string|ustring|rune)\\b" } ] } } }