Expand Gotlin language and tooling

This commit is contained in:
pavel 2026-08-27 01:46:57 +02:00
commit de1262b4cf
41 changed files with 6059 additions and 379 deletions

View file

@ -3,39 +3,21 @@
"name": "Gotlin",
"scopeName": "source.gotlin",
"patterns": [
{
"include": "#comments"
},
{
"include": "#imports"
},
{
"include": "#package"
},
{
"include": "#functions"
},
{
"include": "#typesDecl"
},
{
"include": "#literals"
},
{
"include": "#keywords"
},
{
"include": "#types"
},
{
"include": "#strings"
},
{
"include": "#numbers"
},
{
"include": "#operators"
}
{ "include": "#comments" },
{ "include": "#imports" },
{ "include": "#package" },
{ "include": "#annotations" },
{ "include": "#declarations" },
{ "include": "#functions" },
{ "include": "#strings" },
{ "include": "#sql" },
{ "include": "#generics" },
{ "include": "#literals" },
{ "include": "#keywords" },
{ "include": "#types" },
{ "include": "#numbers" },
{ "include": "#typeOperators" },
{ "include": "#operators" }
],
"repository": {
"comments": {
@ -49,18 +31,29 @@
"imports": {
"patterns": [
{
"name": "meta.import.gotlin",
"match": "\\b(import)\\b\\s+((?:[A-Za-z_][\\w-]*\\.)*[A-Za-z_][\\w-]*)(?:\\s+((?:[A-Za-z_][\\w-]*\\.)*[A-Za-z_][\\w-]*))?",
"name": "meta.import.go.quoted.gotlin",
"match": "^(\\s*)(import)\\s+([A-Za-z_][A-Za-z0-9_]*)\\s+(\"(?:\\\\.|[^\"\\\\])*\")\\s*;?",
"captures": {
"1": {
"name": "keyword.control.import.gotlin"
},
"2": {
"name": "meta.path.gotlin"
},
"3": {
"name": "meta.path.gotlin"
}
"2": { "name": "keyword.control.import.gotlin" },
"3": { "name": "entity.name.namespace.alias.gotlin" },
"4": { "name": "string.quoted.double.import-path.gotlin" }
}
},
{
"name": "meta.import.go.quoted.gotlin",
"match": "^(\\s*)(import)\\s+(\"(?:\\\\.|[^\"\\\\])*\")\\s*;?",
"captures": {
"2": { "name": "keyword.control.import.gotlin" },
"3": { "name": "string.quoted.double.import-path.gotlin" }
}
},
{
"name": "meta.import.go.bare.gotlin",
"match": "^(\\s*)(import)\\s+(?:([A-Za-z_][A-Za-z0-9_]*)\\s+)?([A-Za-z_][A-Za-z0-9_]*(?:[.-][A-Za-z_][A-Za-z0-9_]*)*)\\s*;?\\s*(?://.*)?$",
"captures": {
"2": { "name": "keyword.control.import.gotlin" },
"3": { "name": "entity.name.namespace.alias.gotlin" },
"4": { "name": "entity.name.namespace.import-path.gotlin" }
}
}
]
@ -69,14 +62,108 @@
"patterns": [
{
"name": "meta.package.gotlin",
"match": "\\b(package)\\b\\s+((?:[A-Za-z_][\\w-]*\\.)*[A-Za-z_][\\w-]*)",
"match": "^(\\s*)(package)\\s+([A-Za-z_][A-Za-z0-9_]*(?:[.-][A-Za-z_][A-Za-z0-9_]*)*)\\s*;?",
"captures": {
"1": {
"name": "keyword.control.package.gotlin"
},
"2": {
"name": "meta.path.gotlin"
}
"2": { "name": "keyword.control.package.gotlin" },
"3": { "name": "entity.name.namespace.gotlin" }
}
}
]
},
"annotations": {
"patterns": [
{
"match": "(@)(jsonNaming)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.json-naming.gotlin" }
}
},
{
"match": "(@)(embed)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.embed.gotlin" }
}
},
{
"match": "(@)(table)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.table.gotlin" }
}
},
{
"match": "(@)(column)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.column.gotlin" }
}
},
{
"match": "(@)(id)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.id.gotlin" }
}
},
{
"match": "(@)(generated)\\b",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.generated.gotlin" }
}
},
{
"match": "(@)([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "punctuation.definition.annotation.gotlin" },
"2": { "name": "entity.other.attribute-name.annotation.gotlin" }
}
}
]
},
"declarations": {
"patterns": [
{
"name": "meta.class.data.gotlin",
"match": "\\b(data)\\s+(class)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.modifier.data.gotlin" },
"2": { "name": "storage.type.class.gotlin" },
"3": { "name": "entity.name.type.class.gotlin" }
}
},
{
"name": "meta.interface.gotlin",
"match": "\\b(interface)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.type.interface.gotlin" },
"2": { "name": "entity.name.type.interface.gotlin" }
}
},
{
"name": "meta.worker.gotlin",
"match": "\\b(worker)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.type.worker.gotlin" },
"2": { "name": "entity.name.type.worker.gotlin" }
}
},
{
"name": "meta.enum.gotlin",
"match": "\\b(enum)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.type.enum.gotlin" },
"2": { "name": "entity.name.type.enum.gotlin" }
}
},
{
"name": "meta.class.gotlin",
"match": "\\b(class)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.type.class.gotlin" },
"2": { "name": "entity.name.type.class.gotlin" }
}
}
]
@ -85,46 +172,73 @@
"patterns": [
{
"name": "meta.function.gotlin",
"match": "\\b(?:(override)\\s+)?(fun)\\b\\s+([A-Za-z_][A-Za-z0-9_]*)",
"match": "\\b(?:(override)\\s+)?(fun)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "storage.modifier.gotlin"
},
"2": {
"name": "keyword.control.function.gotlin"
},
"3": {
"name": "entity.name.function.gotlin"
}
"1": { "name": "storage.modifier.override.gotlin" },
"2": { "name": "storage.type.function.gotlin" },
"3": { "name": "entity.name.function.gotlin" }
}
}
]
},
"typesDecl": {
"strings": {
"patterns": [
{
"name": "meta.interface.gotlin",
"match": "\\b(interface)\\b\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "storage.type.interface.gotlin"
},
"2": {
"name": "entity.name.type.interface.gotlin"
"name": "string.quoted.double.gotlin",
"begin": "\"",
"beginCaptures": {
"0": { "name": "punctuation.definition.string.begin.gotlin" }
},
"end": "\"",
"endCaptures": {
"0": { "name": "punctuation.definition.string.end.gotlin" }
},
"patterns": [
{
"name": "constant.character.escape.gotlin",
"match": "\\\\."
}
}
]
}
]
},
"sql": {
"patterns": [
{
"name": "support.type.namespace.sql.gotlin",
"match": "\\bsql\\b(?=\\s*\\.)"
},
{
"name": "meta.class.gotlin",
"match": "\\b(class)\\b\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": {
"name": "storage.type.class.gotlin"
},
"2": {
"name": "entity.name.type.class.gotlin"
}
}
"name": "support.function.sql.query.gotlin",
"match": "(?<=\\.)\\b(from|where|select|orderBy|orderByDescending|limit|forUpdate|skipLocked)\\b"
},
{
"name": "support.function.sql.mutation.gotlin",
"match": "(?<=\\.)\\b(insert|update|delete|onConflict|doNothing|doUpdate|returning)\\b"
},
{
"name": "support.function.sql.execution.gotlin",
"match": "(?<=\\.)\\b(build|fetch|single|iterator)\\b"
},
{
"name": "support.function.sql.helper.gotlin",
"match": "\\b(set|now)\\b(?=\\s*\\()"
},
{
"name": "support.function.mapping.gotlin",
"match": "(?<=\\.)\\bmapTo\\b"
}
]
},
"generics": {
"patterns": [
{
"name": "punctuation.definition.generic.begin.gotlin",
"match": "(?<=\\w)<(?=\\s*[*A-Za-z_])"
},
{
"name": "punctuation.definition.generic.end.gotlin",
"match": ">(?=\\??\\s*(?:[>,.()\\[\\]{}:=]|$))"
}
]
},
@ -140,26 +254,54 @@
},
{
"name": "variable.language.this.gotlin",
"match": "\\bthis\\b"
"match": "\\b(this|it)\\b"
}
]
},
"keywords": {
"patterns": [
{
"name": "keyword.control.gotlin",
"match": "\\b(fun|val|var|override|if|else|while|return|try|catch|throw)\\b"
"name": "keyword.control.declaration.gotlin",
"match": "\\b(package|import|data|class|interface|worker|enum|fun)\\b"
},
{
"name": "storage.modifier.gotlin",
"match": "\\b(private|override)\\b"
},
{
"name": "storage.type.variable.gotlin",
"match": "\\b(val|var)\\b"
},
{
"name": "keyword.control.conditional.gotlin",
"match": "\\b(if|else|match)\\b"
},
{
"name": "keyword.control.loop.gotlin",
"match": "\\b(while|for|in)\\b"
},
{
"name": "keyword.control.concurrency.gotlin",
"match": "\\b(select|go|defer)\\b"
},
{
"name": "keyword.control.exception.gotlin",
"match": "\\b(try|catch|throw)\\b"
},
{
"name": "keyword.control.return.gotlin",
"match": "\\breturn\\b"
}
]
},
"types": {
"patterns": [
{
"name": "storage.type.gotlin",
"match": "\\b(Int|String|Boolean|Unit)\\b"
"name": "support.type.builtin.gotlin",
"match": "\\b(Int|String|Boolean|Unit|Double|Float|Any|ByteSlice|List|MutableList|Map|MutableMap|Channel|GotlinSQLQuery|GotlinSQLIterator)\\b"
},
{
"name": "support.type.gotlin",
"name": "support.type.qualified.gotlin",
"match": "\\b[A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)+\\b"
},
{
@ -168,34 +310,67 @@
}
]
},
"strings": {
"patterns": [
{
"name": "string.quoted.double.gotlin",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.gotlin",
"match": "\\\\."
}
]
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.gotlin",
"match": "\\b\\d+\\b"
"name": "constant.numeric.float.gotlin",
"match": "\\b[0-9]+\\.[0-9]+\\b"
},
{
"name": "constant.numeric.integer.gotlin",
"match": "\\b[0-9]+\\b"
}
]
},
"typeOperators": {
"patterns": [
{
"name": "keyword.operator.type.nullable.gotlin",
"match": "(?<=[A-Za-z0-9_>])\\?"
},
{
"name": "keyword.operator.address.gotlin",
"match": "&(?=\\s*[A-Za-z_(])"
},
{
"name": "keyword.operator.pointer.dereference.spread.gotlin",
"match": "\\*(?=\\s*[A-Za-z_(])"
}
]
},
"operators": {
"patterns": [
{
"name": "keyword.operator.gotlin",
"match": "->|==|!=|<=|>=|&&|\\|\\||[=+\\-*/%<>!:.,]"
"name": "keyword.operator.assignment.gotlin",
"match": "\\+=|="
},
{
"name": "keyword.operator.comparison.gotlin",
"match": "==|!=|<=|>="
},
{
"name": "keyword.operator.logical.gotlin",
"match": "&&|\\|\\||!"
},
{
"name": "keyword.operator.arrow.gotlin",
"match": "->"
},
{
"name": "punctuation.accessor.enum.gotlin",
"match": "::"
},
{
"name": "keyword.operator.arithmetic.gotlin",
"match": "[+\\-*/%<>]"
},
{
"name": "punctuation.accessor.dot.gotlin",
"match": "\\."
},
{
"name": "punctuation.separator.gotlin",
"match": "[,;:]"
}
]
}