在sublime3中配置kotlin
本文两部分:
1.准备工具
用来编译运行kotlin代码,只看代码,可跳过此步。
1.1 下载JetBrains kotlin编译器
https://github.com/JetBrains/kotlin/releases
找到最新版本下载 :这里用的1.6.10
1.2 设置环境变量
1 export KOTLINC=~/android/kotlin/kotlinc
2 export KOTLIN_NATIVE=~/android/kotlin/kotlin-native-linux-x86_64-1.6.10
3 export PATH=$ANDROID:$PATH:$KOTLINC/bin:$KOTLIN_NATIVE/bin:.
source ~./profile
2.使用现成插件包
2.1 工具官网
https://github.com/vkostyukov/kotlin-sublime-package
2.2 安装过程
第1步 菜单选项
Preferences --> Paceage Control --> Install Package
第2步 搜索Kotlin 包
第3步 安装Kotlin包
选中Kotlin包,双击左键或者回车 安装:安装过程见左下状态栏:
2.3 编译和运行kotlin代码
a.配置编译系统
Tools --> Build System --> Kotlin(或者Automatic)
b.设置编译工具 (Ctrl + Shift + B )
b.编译运行 (Ctrl + B)
2.4 卸载Kotlin包
Preferences --> Paceage Control --> Remove Pacakge
选中Kotlin包,双击左键或者回车卸载。
3.手动配置
3.1 设置SublimeText3的系统构建工具
第1步 菜单选项
打开sublime text 3 : Tools --> Build System --> New Build System...
第2步 设置配置文件
{
"path" : "/usr/local/bin:$PATH",
"selector" : "source.Kotlin",
"file_regex": "^(.*):([0-9]+):([0-9]+): (?:error|warning):(.*)",
"cmd" : "kotlinc \"${file}\" -include-runtime -d ${file_base_name}.jar",
"variants": [{
"cmd": "kotlinc \"${file}\" -include-runtime -d ${file_base_name}.jar",
"name": "Compile"
},{
"cmd": "kotlinc \"${file}\" -include-runtime -d ${file_base_name}.jar || exit 1; java -jar ${file_base_name}.jar",
"name": "Compile + run"
},{
"name": "Run",
"cmd": "java -jar ${file_base_name}.jar"
}],
"shell" : "true",
"windows" : {
"path" : "$PATH"
}
}
第3步 保存为 Kotlin1.6.10.sublime-build
默认保存在 ~/.config/sublime-text/Packages/User/ 目录下。
第4步 添加编译的菜单选项
如果第3步未成功,那么打开 ~/.config/sublime-text/Local/Session.sublime_session 文件
3.2 配置语法高亮样式
第1步 添加Kotlin语法文件
在 ~/.config/sublime-text/Packages/User/ 目录下新建 Kotlin1.6.10.tmLanguage 文件,内容如下:
查看代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>kt</string>
<string>kts</string>
</array>
<key>name</key>
<string>Kotlin1.6.10</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.package.kotlin</string>
</dict>
</dict>
<key>match</key>
<string>^\s*(package)\b(?:\s*([^ ;$]+)\s*)?</string>
</dict>
<dict>
<key>include</key>
<string>#imports</string>
</dict>
<dict>
<key>include</key>
<string>#statements</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>classes</key>
<dict>
<key>begin</key>
<string>(?<!::)(?=\b(?:companion|class|object|interface)\b)</string>
<key>end</key>
<string>(?=$|\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>begin</key>
<string>\b(companion\s*)?(class|object|interface)\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.modifier.kotlin</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.modifier.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=<|\{|\(|:|$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>match</key>
<string>\w+</string>
<key>name</key>
<string>entity.name.type.class.kotlin</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string><</string>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#generics</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#parameters</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?={|$)</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\w+</string>
<key>name</key>
<string>entity.other.inherited-class.kotlin</string>
</dict>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#statements</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>comments</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>/\*</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>\*/</string>
<key>name</key>
<string>comment.block.kotlin</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.line.double-slash.kotlin</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.kotlin</string>
</dict>
</dict>
<key>match</key>
<string>\s*((//).*$\n?)</string>
</dict>
</array>
</dict>
<key>constants</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b(true|false|null|this|super)\b</string>
<key>name</key>
<string>constant.language.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)([LlFf])?\b</string>
<key>name</key>
<string>constant.numeric.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b([A-Z][A-Z0-9_]+)\b</string>
<key>name</key>
<string>constant.other.kotlin</string>
</dict>
</array>
</dict>
<key>expressions</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#types</string>
</dict>
<dict>
<key>include</key>
<string>#strings</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
</array>
</dict>
<key>functions</key>
<dict>
<key>begin</key>
<string>(?=\s*\b(?:fun)\b)</string>
<key>end</key>
<string>(?=$|\})</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\b(fun)\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=\()</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string><</string>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#generics</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.function.kotlin</string>
</dict>
</dict>
<key>match</key>
<string>([\.<\?>\w]+\.)?(\w+)</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#parameters</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?={|=|$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>(?=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#statements</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>generics</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=,|>)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
<dict>
<key>match</key>
<string>\w+</string>
<key>name</key>
<string>storage.type.generic.kotlin</string>
</dict>
</array>
</dict>
<key>getters-and-setters</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\b(get)\b\s*\(\s*\)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>\}|(?=\bset\b)|$</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=$|\bset\b)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\b(set)\b\s*(?=\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>\}|(?=\bget\b)|$</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#parameters</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=$|\bset\b)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
</array>
</dict>
</array>
</dict>
<key>imports</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
</dict>
<key>match</key>
<string>^\s*(import)\s+[^ $]+\s+(as)?</string>
</dict>
</array>
</dict>
<key>keywords</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\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</string>
<key>name</key>
<string>storage.modifier.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b(try|catch|finally|throw)\b</string>
<key>name</key>
<string>keyword.control.catch-exception.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b(if|else|while|for|do|return|when|where|break|continue)\b</string>
<key>name</key>
<string>keyword.control.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b(in|is|!in|!is|as|as\?|assert)\b</string>
<key>name</key>
<string>keyword.operator.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(==|!=|===|!==|<=|>=|<|>)</string>
<key>name</key>
<string>keyword.operator.comparison.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(=)</string>
<key>name</key>
<string>keyword.operator.assignment.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(::)</string>
<key>name</key>
<string>keyword.operator.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(:)</string>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b(by)\b</string>
<key>name</key>
<string>keyword.other.by.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\?\.)</string>
<key>name</key>
<string>keyword.operator.safenav.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\.)</string>
<key>name</key>
<string>keyword.operator.dot.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\?:)</string>
<key>name</key>
<string>keyword.operator.elvis.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\-\-|\+\+)</string>
<key>name</key>
<string>keyword.operator.increment-decrement.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\+=|\-=|\*=|\/=)</string>
<key>name</key>
<string>keyword.operator.arithmetic.assign.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\.\.)</string>
<key>name</key>
<string>keyword.operator.range.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(\-|\+|\*|\/|%)</string>
<key>name</key>
<string>keyword.operator.arithmetic.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(!|&&|\|\|)</string>
<key>name</key>
<string>keyword.operator.logical.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>(;)</string>
<key>name</key>
<string>punctuation.terminator.kotlin</string>
</dict>
</array>
</dict>
<key>namespaces</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b(namespace)\b</string>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#statements</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>parameters</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=,|\)|=)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=,|\))</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
<dict>
<key>match</key>
<string>\w+</string>
<key>name</key>
<string>variable.parameter.function.kotlin</string>
</dict>
</array>
</dict>
<key>statements</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#namespaces</string>
</dict>
<dict>
<key>include</key>
<string>#typedefs</string>
</dict>
<dict>
<key>include</key>
<string>#classes</string>
</dict>
<dict>
<key>include</key>
<string>#functions</string>
</dict>
<dict>
<key>include</key>
<string>#variables</string>
</dict>
<dict>
<key>include</key>
<string>#getters-and-setters</string>
</dict>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<key>strings</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>"""</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>"""</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.kotlin</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.third.kotlin</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(\$\w+|\$\{[^\}]+\})</string>
<key>name</key>
<string>variable.parameter.template.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\\.</string>
<key>name</key>
<string>constant.character.escape.kotlin</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>"</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>"</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.kotlin</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.double.kotlin</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(\$\w+|\$\{[^\}]+\})</string>
<key>name</key>
<string>variable.parameter.template.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\\.</string>
<key>name</key>
<string>constant.character.escape.kotlin</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>'</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>'</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.kotlin</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.single.kotlin</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\.</string>
<key>name</key>
<string>constant.character.escape.kotlin</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>`</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>`</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.kotlin</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.single.kotlin</string>
</dict>
</array>
</dict>
<key>typedefs</key>
<dict>
<key>begin</key>
<string>(?=\s*(?:type))</string>
<key>end</key>
<string>(?=$)</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b(type)\b</string>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
<dict>
<key>begin</key>
<string><</string>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#generics</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<key>types</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b(Nothing|Any|Unit|String|CharSequence|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic)\b</string>
<key>name</key>
<string>storage.type.buildin.kotlin</string>
</dict>
<dict>
<key>match</key>
<string>\b(IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray)\b</string>
<key>name</key>
<string>storage.type.buildin.array.kotlin</string>
</dict>
<dict>
<key>begin</key>
<string>\b(Array|Collection|List|Map|Set|MutableList|MutableMap|MutableSet|Sequence)<\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.buildin.collection.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\w+<</string>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#statements</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>\)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>(->)</string>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</array>
</dict>
<key>variables</key>
<dict>
<key>begin</key>
<string>(?=\s*\b(?:var|val)\b)</string>
<key>end</key>
<string>(?=:|=|(\b(by)\b)|$)</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>\b(var|val)\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=:|=|(\b(by)\b)|$)</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string><</string>
<key>end</key>
<string>></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#generics</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.variable.kotlin</string>
</dict>
</dict>
<key>match</key>
<string>([\.<\?>\w]+\.)?(\w+)</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(:)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.declaration.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?==|$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#types</string>
</dict>
<dict>
<key>include</key>
<string>#getters-and-setters</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>\b(by)\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(=)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.kotlin</string>
</dict>
</dict>
<key>end</key>
<string>(?=$)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#expressions</string>
</dict>
<dict>
<key>include</key>
<string>#getters-and-setters</string>
</dict>
</array>
</dict>
</array>
</dict>
</dict>
<key>scopeName</key>
<string>source.Kotlin</string>
<key>uuid</key>
<string>d508c059-a938-4779-b2bc-ff43a5078907</string>
</dict>
</plist>
第2步 选择Kotlin语法
右下脚 --> 左键 --> 选择喜欢的高亮样式
3.3 编译运行kotlin代码
和 [ 2.3 编译和运行kotlin代码 ] 一样。