Skip to content

Commit

Permalink
Improved variable and constant declaration based on how local var is …
Browse files Browse the repository at this point in the history
…defined in java grammar
  • Loading branch information
per-steinar committed Jan 16, 2024
1 parent 51cead3 commit eb7c3a3
Showing 1 changed file with 56 additions and 20 deletions.
76 changes: 56 additions & 20 deletions syntaxes/kotlin.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,34 +427,70 @@
}
},
"variable-declaration": {
"match": "\\b(var)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?",
"captures": {
"1": {
"name": "storage.type.variable.kotlin"
"begin": "(?=\\b(var)\\b\\s+[A-Za-z_$][\\w$]*\\s*(=|:|$))",
"end": "(?=\\=|:|$)",
"name": "meta.definition.variable.kotlin",
"patterns": [
{
"match": "\\b(var)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?",
"captures": {
"1": {
"name": "storage.type.variable.kotlin"
},
"2": {
"patterns": [
{
"include": "#type-parameter"
}
]
}
}
},
"2": {
"patterns": [
{
"include": "#type-parameter"
{
"match": "([A-Za-z$_][\\w$]*)(?=\\s*(\\[\\])*\\s*(=|:|$))",
"captures": {
"1": {
"name": "variable.other.definition.kotlin"
}
]
}
},
{
"include": "#code"
}
}
]
},
"constant-declaration": {
"match": "\\b(val)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?",
"captures": {
"1": {
"name": "storage.type.variable.readonly.kotlin"
"begin": "(?=\\b(val)\\b\\s+[A-Za-z_$][\\w$]*\\s*(=|:|$))",
"end": "(?=\\=|:|$)",
"name": "meta.definition.variable.readonly.kotlin",
"patterns": [
{
"match": "\\b(val)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?",
"captures": {
"1": {
"name": "storage.type.variable.kotlin"
},
"2": {
"patterns": [
{
"include": "#type-parameter"
}
]
}
}
},
"2": {
"patterns": [
{
"include": "#type-parameter"
{
"match": "([A-Za-z$_][\\w$]*)(?=\\s*(\\[\\])*\\s*(=|:|$))",
"captures": {
"1": {
"name": "variable.other.definition.kotlin"
}
]
}
},
{
"include": "#code"
}
}
]
},
"object": {
"match": "\\b(\\w+)(?=\\.)",
Expand Down

0 comments on commit eb7c3a3

Please sign in to comment.