| { "name": "Kotlin", |
| "scopeName": "source.Kotlin", |
| "fileTypes": ["kt", "kts"], |
| "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": { |
| "statements": { |
| "patterns": [ |
| { |
| "include": "#namespaces" |
| }, |
| { |
| "include": "#typedefs" |
| }, |
| { |
| "include": "#classes" |
| }, |
| { |
| "include": "#functions" |
| }, |
| { |
| "include": "#variables" |
| }, |
| { |
| "include": "#getters-and-setters" |
| }, |
| { |
| "include": "#expressions" |
| } |
| ] |
| }, |
| "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?)" |
| } |
| ] |
| }, |
| "imports": { |
| "patterns": [ |
| { |
| "captures": { |
| "1": { |
| "name": "keyword.other.kotlin" |
| }, |
| "2": { |
| "name": "keyword.other.kotlin" |
| } |
| }, |
| "match": "^\\s*(import)\\s+[^ $]+\\s+(as)?" |
| } |
| ] |
| }, |
| "namespaces": { |
| "patterns": [ |
| { |
| "match": "\\b(namespace)\\b", |
| "name": "keyword.other.kotlin" |
| }, |
| { |
| "begin": "\\{", |
| "end": "\\}", |
| "patterns": [ |
| { |
| "include": "#statements" |
| } |
| ] |
| } |
| ] |
| }, |
| "types": { |
| "patterns": [ |
| { |
| "match": "\\b(Nothing|Any|Unit|String|CharSequence|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic)\\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|Collection|List|Map|Set|MutableList|MutableMap|MutableSet|Sequence)<\\b", |
| "beginCaptures": { |
| "1": { |
| "name": "storage.type.buildin.collection.kotlin" |
| } |
| }, |
| "end": ">", |
| "patterns": [ |
| { |
| "include": "#types" |
| }, |
| { |
| "include": "#keywords" |
| } |
| ] |
| }, |
| { |
| "begin": "\\w+<", |
| "end": ">", |
| "patterns": [ |
| { |
| "include": "#types" |
| }, |
| { |
| "include": "#keywords" |
| } |
| ] |
| }, |
| { |
| "begin": "\\{", |
| "end": "\\}", |
| "patterns": [ |
| { |
| "include": "#statements" |
| } |
| ] |
| }, |
| { |
| "begin": "\\(", |
| "end": "\\)", |
| "patterns": [ |
| { |
| "include": "#types" |
| } |
| ] |
| }, |
| { |
| "match": "(->)", |
| "name": "keyword.operator.declaration.kotlin" |
| } |
| ] |
| }, |
| "generics": { |
| "patterns": [ |
| { |
| "begin": "(:)", |
| "beginCaptures": { |
| "1": { |
| "name": "keyword.operator.declaration.kotlin" |
| } |
| }, |
| "end": "(?=,|>)", |
| "patterns": [ |
| { |
| "include": "#types" |
| } |
| ] |
| }, |
| { |
| "include": "#keywords" |
| }, |
| { |
| "match": "\\w+", |
| "name": "storage.type.generic.kotlin" |
| } |
| ] |
| }, |
| "typedefs": { |
| "begin": "(?=\\s*(?:type))", |
| "end": "(?=$)", |
| "patterns": [ |
| { |
| "match": "\\b(type)\\b", |
| "name": "keyword.other.kotlin" |
| }, |
| { |
| "begin": "<", |
| "end": ">", |
| "patterns": [ |
| { |
| "include": "#generics" |
| } |
| ] |
| }, |
| { |
| "include": "#expressions" |
| } |
| ] |
| }, |
| "classes": { |
| "begin": "(?<!::)(?=\\b(?:companion|class|object|interface)\\b)", |
| "end": "(?=$|\\})", |
| "patterns": [ |
| { |
| "include" : "#comments" |
| }, |
| { |
| "begin": "\\b(companion\\s*)?(class|object|interface)\\b", |
| "beginCaptures": { |
| "1": { |
| "name": "storage.modifier.kotlin" |
| }, |
| "2": { |
| "name": "storage.modifier.kotlin" |
| } |
| }, |
| "end": "(?=<|\\{|\\(|:|$)", |
| "patterns": [ |
| { |
| "include" : "#comments" |
| }, |
| { |
| "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" |
| } |
| ] |
| } |
| ] |
| }, |
| "variables": { |
| "begin": "(?=\\s*\\b(?:var|val)\\b)", |
| "end": "(?=:|=|(\\b(by)\\b)|$)", |
| "patterns": [ |
| { |
| "begin": "\\b(var|val)\\b", |
| "beginCaptures": { |
| "1": { |
| "name": "keyword.other.kotlin" |
| } |
| }, |
| "end": "(?=:|=|(\\b(by)\\b)|$)", |
| "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": "\\b(by)\\b", |
| "beginCaptures": { |
| "1": { |
| "name": "keyword.other.kotlin" |
| } |
| }, |
| "end": "(?=$)", |
| "patterns": [ |
| { |
| "include": "#expressions" |
| } |
| ] |
| }, |
| { |
| "begin": "(=)", |
| "beginCaptures": { |
| "1": { |
| "name": "keyword.operator.assignment.kotlin" |
| } |
| }, |
| "end": "(?=$)", |
| "patterns": [ |
| { |
| "include": "#expressions" |
| }, |
| { |
| "include": "#getters-and-setters" |
| } |
| ] |
| } |
| ] |
| }, |
| "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" |
| } |
| ] |
| } |
| ] |
| } |
| ] |
| }, |
| "functions": { |
| "begin": "(?=\\s*\\b(?:fun)\\b)", |
| "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" |
| } |
| ] |
| } |
| ] |
| }, |
| "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" |
| } |
| ] |
| }, |
| "expressions": { |
| "patterns": [ |
| { |
| "begin": "\\(", |
| "end": "\\)", |
| "patterns": [ |
| { |
| "include": "#expressions" |
| } |
| ] |
| }, |
| { |
| "include": "#types" |
| }, |
| { |
| "include": "#strings" |
| }, |
| { |
| "include": "#constants" |
| }, |
| { |
| "include": "#comments" |
| }, |
| { |
| "include": "#keywords" |
| } |
| ] |
| }, |
| "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" |
| } |
| ] |
| }, |
| "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]+)?)([LlFf])?\\b", |
| "name": "constant.numeric.kotlin" |
| }, |
| { |
| "match": "\\b([A-Z][A-Z0-9_]+)\\b", |
| "name": "constant.other.kotlin" |
| } |
| ] |
| }, |
| "keywords": { |
| "patterns": [ |
| { |
| "match": "\\b(var|val|public|private|protected|abstract|final|sealed|enum|open|attribute|annotation|override|inline|vararg|in|out|internal|data|tailrec|operator|infix|const|yield|typealias|typeof|reified|suspend)\\b", |
| "name": "storage.modifier.kotlin" |
| }, |
| { |
| "match": "\\b(try|catch|finally|throw)\\b", |
| "name": "keyword.control.catch-exception.kotlin" |
| }, |
| { |
| "match": "\\b(if|else|while|for|do|return|when|where|break|continue)\\b", |
| "name": "keyword.control.kotlin" |
| }, |
| { |
| "match": "\\b(in|is|!in|!is|as|as\\?|assert)\\b", |
| "name": "keyword.operator.kotlin" |
| }, |
| { |
| "match": "(==|!=|===|!==|<=|>=|<|>)", |
| "name": "keyword.operator.comparison.kotlin" |
| }, |
| { |
| "match": "(=)", |
| "name": "keyword.operator.assignment.kotlin" |
| }, |
| { |
| "match": "(::)", |
| "name": "keyword.operator.kotlin" |
| }, |
| { |
| "match": "(:)", |
| "name": "keyword.operator.declaration.kotlin" |
| }, |
| { |
| "match": "\\b(by)\\b", |
| "name": "keyword.other.by.kotlin" |
| }, |
| { |
| "match": "(\\?\\.)", |
| "name": "keyword.operator.safenav.kotlin" |
| }, |
| { |
| "match": "(\\.)", |
| "name": "keyword.operator.dot.kotlin" |
| }, |
| { |
| "match": "(\\?:)", |
| "name": "keyword.operator.elvis.kotlin" |
| }, |
| { |
| "match": "(\\-\\-|\\+\\+)", |
| "name": "keyword.operator.increment-decrement.kotlin" |
| }, |
| { |
| "match": "(\\+=|\\-=|\\*=|\\/=)", |
| "name": "keyword.operator.arithmetic.assign.kotlin" |
| }, |
| { |
| "match": "(\\.\\.)", |
| "name": "keyword.operator.range.kotlin" |
| }, |
| { |
| "match": "(\\-|\\+|\\*|\\/|%)", |
| "name": "keyword.operator.arithmetic.kotlin" |
| }, |
| { |
| "match": "(!|&&|\\|\\|)", |
| "name": "keyword.operator.logical.kotlin" |
| }, |
| { |
| "match": "(;)", |
| "name": "punctuation.terminator.kotlin" |
| } |
| ] |
| } |
| }, |
| "uuid": "d508c059-a938-4779-b2bc-ff43a5078907" |
| } |