{ "fileTypes": [ "kt", "jetl", "jet" ], "name": "Kotlin", "patterns": [ { "include": "#comments" }, { "captures": { "1": { "name": "keyword.other.kotlin" }, "2": { "name": "entity.name.package.kotlin" } }, "match": "^\\s*(package)\\b(?:\\s*([^ ;$]+)\\s*)?" }, { "include": "#imports" }, { "include": "#statements" } ], "repository": { "classes": { "begin": "(?=\\s*(?:companion|class|object|trait))", "end": "}|(?=$)", "patterns": [ { "begin": "\\b(companion\\s*)?(class|object|trait)\\b", "beginCaptures": { "1": { "name": "keyword.other.kotlin" } }, "end": "(?=<|{|\\(|:)", "patterns": [ { "match": "\\b(object)\\b", "name": "keyword.other.kotlin" }, { "match": "\\w+", "name": "entity.name.type.class.kotlin" } ] }, { "begin": "<", "end": ">", "patterns": [ { "include": "#generics" } ] }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#parameters" } ] }, { "begin": "(:)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?={|$)", "patterns": [ { "match": "\\w+", "name": "entity.other.inherited-class.kotlin" }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#expressions" } ] } ] }, { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#statements" } ] } ] }, "comments": { "patterns": [ { "begin": "/\\*", "captures": { "0": { "name": "punctuation.definition.comment.kotlin" } }, "end": "\\*/", "name": "comment.block.kotlin" }, { "captures": { "1": { "name": "comment.line.double-slash.kotlin" }, "2": { "name": "punctuation.definition.comment.kotlin" } }, "match": "\\s*((//).*$\\n?)" } ] }, "constants": { "patterns": [ { "match": "\\b(true|false|null|this|super)\\b", "name": "constant.language.kotlin" }, { "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)([LlFfUuDd]|UL|ul)?\\b", "name": "constant.numeric.kotlin" }, { "match": "\\b([A-Z][A-Z0-9_]+)\\b", "name": "constant.other.kotlin" } ] }, "expressions": { "patterns": [ { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#expressions" } ] }, { "include": "#types" }, { "include": "#strings" }, { "include": "#constants" }, { "include": "#comments" }, { "include": "#keywords" } ] }, "functions": { "begin": "(?=\\s*(?:fun))", "end": "}|(?=$)", "patterns": [ { "begin": "\\b(fun)\\b", "beginCaptures": { "1": { "name": "keyword.other.kotlin" } }, "end": "(?=\\()", "patterns": [ { "begin": "<", "end": ">", "patterns": [ { "include": "#generics" } ] }, { "captures": { "2": { "name": "entity.name.function.kotlin" } }, "match": "([\\.<\\?>\\w]+\\.)?(\\w+)" } ] }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#parameters" } ] }, { "begin": "(:)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?={|=|$)", "patterns": [ { "include": "#types" } ] }, { "begin": "\\{", "end": "(?=\\})", "patterns": [ { "include": "#statements" } ] }, { "begin": "(=)", "beginCaptures": { "1": { "name": "keyword.operator.assignment.kotlin" } }, "end": "(?=$)", "patterns": [ { "include": "#expressions" } ] } ] }, "generics": { "patterns": [ { "begin": "(:)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?=,|>)", "patterns": [ { "include": "#types" } ] }, { "include": "#keywords" }, { "match": "\\w+", "name": "storage.type.generic.kotlin" } ] }, "getters-and-setters": { "patterns": [ { "begin": "\\b(get)\\b\\s*\\(\\s*\\)", "beginCaptures": { "1": { "name": "entity.name.function.kotlin" } }, "end": "\\}|(?=\\bset\\b)|$", "patterns": [ { "begin": "(=)", "beginCaptures": { "1": { "name": "keyword.operator.assignment.kotlin" } }, "end": "(?=$|\\bset\\b)", "patterns": [ { "include": "#expressions" } ] }, { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#expressions" } ] } ] }, { "begin": "\\b(set)\\b\\s*(?=\\()", "beginCaptures": { "1": { "name": "entity.name.function.kotlin" } }, "end": "\\}|(?=\\bget\\b)|$", "patterns": [ { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#parameters" } ] }, { "begin": "(=)", "beginCaptures": { "1": { "name": "keyword.operator.assignment.kotlin" } }, "end": "(?=$|\\bset\\b)", "patterns": [ { "include": "#expressions" } ] }, { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#expressions" } ] } ] } ] }, "imports": { "patterns": [ { "captures": { "1": { "name": "keyword.other.kotlin" }, "2": { "name": "keyword.other.kotlin" } }, "match": "^\\s*(import)\\s+[^ $]+\\s+(as)?" } ] }, "keywords": { "patterns": [ { "match": "\\b(var|val|public|private|protected|abstract|final|enum|open|attribute|annotation|override|inline|var|val|vararg|lazy|in|out|ref|internal|data)\\b", "name": "storage.modifier.kotlin" }, { "match": "\\b(try|catch|finally|throw)\\b", "name": "keyword.control.catch-exception.kotlin" }, { "match": "\\b(if|then|else|while|for|do|return|when|where|break|continue)\\b", "name": "keyword.control.kotlin" }, { "match": "\\b(in|is|as|assert)\\b", "name": "keyword.operator.kotlin" }, { "match": "(==|!=|<=|>=|<>|<|>)", "name": "keyword.operator.comparison.kotlin" }, { "match": "(=)", "name": "keyword.operator.assignment.kotlin" }, { "match": "(:)", "name": "keyword.operator.declaration.kotlin" }, { "match": "(\\.)", "name": "keyword.operator.dot.kotlin" }, { "match": "(\\-\\-|\\+\\+)", "name": "keyword.operator.increment-decrement.kotlin" }, { "match": "(\\-|\\+|\\*|\\/|%)", "name": "keyword.operator.arithmetic.kotlin" }, { "match": "(!|&&|\\|\\|)", "name": "keyword.operator.logical.kotlin" }, { "match": "(#)", "name": "keyword.operator.tuple.kotlin" }, { "match": "(;)", "name": "punctuation.terminator.kotlin" } ] }, "namespaces": { "patterns": [ { "match": "\\b(namespace)\\b", "name": "keyword.other.kotlin" }, { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#statements" } ] } ] }, "parameters": { "patterns": [ { "begin": "(:)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?=,|\\)|=)", "patterns": [ { "include": "#types" } ] }, { "begin": "(=)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?=,|\\))", "patterns": [ { "include": "#expressions" } ] }, { "include": "#keywords" }, { "match": "\\w+", "name": "variable.parameter.function.kotlin" } ] }, "statements": { "patterns": [ { "include": "#namespaces" }, { "include": "#typedefs" }, { "include": "#classes" }, { "include": "#functions" }, { "include": "#variables" }, { "include": "#getters-and-setters" }, { "include": "#expressions" } ] }, "strings": { "patterns": [ { "begin": "\"\"\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.kotlin" } }, "end": "\"\"\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.kotlin" } }, "name": "string.quoted.third.kotlin", "patterns": [ { "match": "(\\$\\w+|\\$\\{[^\\}]+\\})", "name": "variable.parameter.template.kotlin" }, { "match": "\\\\.", "name": "constant.character.escape.kotlin" } ] }, { "begin": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.kotlin" } }, "end": "\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.kotlin" } }, "name": "string.quoted.double.kotlin", "patterns": [ { "match": "(\\$\\w+|\\$\\{[^\\}]+\\})", "name": "variable.parameter.template.kotlin" }, { "match": "\\\\.", "name": "constant.character.escape.kotlin" } ] }, { "begin": "'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.kotlin" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.kotlin" } }, "name": "string.quoted.single.kotlin", "patterns": [ { "match": "\\\\.", "name": "constant.character.escape.kotlin" } ] }, { "begin": "`", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.kotlin" } }, "end": "`", "endCaptures": { "0": { "name": "punctuation.definition.string.end.kotlin" } }, "name": "string.quoted.single.kotlin" } ] }, "typedefs": { "begin": "(?=\\s*(?:type))", "end": "(?=$)", "patterns": [ { "match": "\\b(type)\\b", "name": "keyword.other.kotlin" }, { "begin": "<", "end": ">", "patterns": [ { "include": "#generics" } ] }, { "include": "#expressions" } ] }, "types": { "patterns": [ { "match": "\\b(Any|Unit|String|Int|Boolean|Char|Long|Double|Float|Short|Byte)\\b", "name": "storage.type.buildin.kotlin" }, { "match": "\\b(IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray)\\b", "name": "storage.type.buildin.array.kotlin" }, { "begin": "\\b(Array|List|Map)<\\b", "beginCaptures": { "1": { "name": "storage.type.buildin.collection.kotlin" } }, "end": ">", "patterns": [ { "include": "#types" }, { "include": "#keywords" } ] }, { "begin": "\\w+<", "end": ">", "patterns": [ { "include": "#types" }, { "include": "#keywords" } ] }, { "begin": "(#)\\(", "beginCaptures": { "1": { "name": "keyword.operator.tuple.kotlin" } }, "end": "\\)", "patterns": [ { "include": "#expressions" } ] }, { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#statements" } ] }, { "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#types" } ] }, { "match": "(->)", "name": "keyword.operator.declaration.kotlin" } ] }, "variables": { "begin": "(?=\\s*(?:var|val))", "end": "(?=:|=|$)", "patterns": [ { "begin": "\\b(var|val)\\b", "beginCaptures": { "1": { "name": "keyword.other.kotlin" } }, "end": "(?=:|=|$)", "patterns": [ { "begin": "<", "end": ">", "patterns": [ { "include": "#generics" } ] }, { "captures": { "2": { "name": "entity.name.variable.kotlin" } }, "match": "([\\.<\\?>\\w]+\\.)?(\\w+)" } ] }, { "begin": "(:)", "beginCaptures": { "1": { "name": "keyword.operator.declaration.kotlin" } }, "end": "(?==|$)", "patterns": [ { "include": "#types" }, { "include": "#getters-and-setters" } ] }, { "begin": "(=)", "beginCaptures": { "1": { "name": "keyword.operator.assignment.kotlin" } }, "end": "(?=$)", "patterns": [ { "include": "#expressions" }, { "include": "#getters-and-setters" } ] } ] } }, "scopeName": "source.Kotlin", "uuid": "d508c059-a938-4779-b2bc-ff43a5078907" }