|
1 | 1 | { |
2 | 2 | "information_for_contributors": [ |
3 | | - "This file has been copied from https://github.com/eclipse/buildship/blob/b848d9a08283b68860671a73ceec3c99bdab27c2/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json" |
4 | | - ], |
| 3 | + "This file has been copied from https://github.com/eclipse/buildship/blob/b848d9a08283b68860671a73ceec3c99bdab27c2/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json" |
| 4 | + ], |
5 | 5 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", |
6 | 6 | "name": "Kotlin", |
7 | 7 | "scopeName": "source.kotlin", |
|
21 | 21 | ], |
22 | 22 | "repository": { |
23 | 23 | "import": { |
24 | | - "begin": "\\b(import)\\b\\s*", |
| 24 | + "begin": "\\b(import)\\b\\s?([\\w+.]*\\w+)?\\s*", |
25 | 25 | "beginCaptures": { |
26 | 26 | "1": { |
27 | 27 | "name": "storage.type.import.kotlin" |
| 28 | + }, |
| 29 | + "2": { |
| 30 | + "name": "storage.modifier.import.kotlin" |
28 | 31 | } |
29 | 32 | }, |
30 | 33 | "end": ";|$", |
|
91 | 94 | { |
92 | 95 | "include": "#variable-declaration" |
93 | 96 | }, |
| 97 | + { |
| 98 | + "include": "#constant-declaration" |
| 99 | + }, |
| 100 | + { |
| 101 | + "include": "#variable" |
| 102 | + }, |
| 103 | + { |
| 104 | + "include": "#object" |
| 105 | + }, |
94 | 106 | { |
95 | 107 | "include": "#type-constraint" |
96 | 108 | }, |
|
100 | 112 | { |
101 | 113 | "include": "#function-call" |
102 | 114 | }, |
| 115 | + { |
| 116 | + "include": "#property.reference" |
| 117 | + }, |
103 | 118 | { |
104 | 119 | "include": "#method-reference" |
105 | 120 | }, |
|
141 | 156 | }, |
142 | 157 | { |
143 | 158 | "include": "#null-literal" |
| 159 | + }, |
| 160 | + { |
| 161 | + "match": ",", |
| 162 | + "name": "punctuation.separator.delimiter.kotlin" |
| 163 | + }, |
| 164 | + { |
| 165 | + "match": "\\.", |
| 166 | + "name": "punctuation.separator.period.kotlin" |
| 167 | + }, |
| 168 | + { |
| 169 | + "match": "\\?\\.", |
| 170 | + "name": "punctuation.accessor.optional.kotlin" |
144 | 171 | } |
145 | 172 | ] |
146 | 173 | }, |
|
234 | 261 | }, |
235 | 262 | { |
236 | 263 | "include": "#control-keywords" |
| 264 | + }, |
| 265 | + { |
| 266 | + "include": "#map-keywords" |
237 | 267 | } |
238 | 268 | ] |
239 | 269 | }, |
|
257 | 287 | "match": "\\b(if|else|while|do|when|try|throw|break|continue|return|for)\\b", |
258 | 288 | "name": "keyword.control.kotlin" |
259 | 289 | }, |
| 290 | + "map-keywords": { |
| 291 | + "match": "\\b(to)\\b", |
| 292 | + "name": "keyword.map.kotlin" |
| 293 | + }, |
260 | 294 | "annotation-simple": { |
261 | 295 | "match": "(?<!\\w)@[\\w\\.]+\\b(?!:)", |
262 | 296 | "name": "entity.name.type.annotation.kotlin" |
|
341 | 375 | } |
342 | 376 | }, |
343 | 377 | "function-declaration": { |
344 | | - "match": "\\b(fun)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?\\s*(?:(\\w+)\\.)?(\\b\\w+\\b|`[^`]+`)", |
345 | | - "captures": { |
| 378 | + "begin": "\\b(fun)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?\\s*(?:(\\w+)\\.)?(\\b\\w+\\b|`[^`]+`)\\(", |
| 379 | + "beginCaptures": { |
346 | 380 | "1": { |
347 | 381 | "name": "storage.type.function.kotlin" |
348 | 382 | }, |
|
359 | 393 | "5": { |
360 | 394 | "name": "entity.name.function.declaration.kotlin" |
361 | 395 | } |
| 396 | + }, |
| 397 | + "end": "\\)", |
| 398 | + "endCaptures": { |
| 399 | + "1": { |
| 400 | + "name": "keyword.operator.assignment.type.kotlin" |
| 401 | + } |
| 402 | + }, |
| 403 | + "patterns": [ |
| 404 | + { |
| 405 | + "include": "#parameter-declaration" |
| 406 | + } |
| 407 | + ] |
| 408 | + }, |
| 409 | + "parameter-declaration": { |
| 410 | + "match": "\\b(\\w+)\\s*(:)\\s*(\\w+)(\\?)?(,)?", |
| 411 | + "captures": { |
| 412 | + "1": { |
| 413 | + "name": "variable.parameter.kotlin" |
| 414 | + }, |
| 415 | + "2": { |
| 416 | + "name": "keyword.operator.assignment.type.kotlin" |
| 417 | + }, |
| 418 | + "3": { |
| 419 | + "name": "entity.name.type.kotlin" |
| 420 | + }, |
| 421 | + "4": { |
| 422 | + "name": "keyword.operator.optional" |
| 423 | + }, |
| 424 | + "5": { |
| 425 | + "name": "punctuation.separator.delimiter.kotlin" |
| 426 | + } |
362 | 427 | } |
363 | 428 | }, |
364 | 429 | "variable-declaration": { |
365 | | - "match": "\\b(val|var)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?", |
| 430 | + "match": "\\b(var)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?", |
366 | 431 | "captures": { |
367 | 432 | "1": { |
368 | 433 | "name": "storage.type.variable.kotlin" |
|
376 | 441 | } |
377 | 442 | } |
378 | 443 | }, |
| 444 | + "constant-declaration": { |
| 445 | + "match": "\\b(val)\\b\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?", |
| 446 | + "captures": { |
| 447 | + "1": { |
| 448 | + "name": "storage.type.variable.readonly.kotlin" |
| 449 | + }, |
| 450 | + "2": { |
| 451 | + "patterns": [ |
| 452 | + { |
| 453 | + "include": "#type-parameter" |
| 454 | + } |
| 455 | + ] |
| 456 | + } |
| 457 | + } |
| 458 | + }, |
| 459 | + "variable" : { |
| 460 | + "match": "\\b(\\w+)(?=\\s*[:=])", |
| 461 | + "captures": { |
| 462 | + "1": { |
| 463 | + "name": "variable.other.definition.kotlin" |
| 464 | + } |
| 465 | + } |
| 466 | + }, |
| 467 | + "object" : { |
| 468 | + "match": "\\b(\\w+)(?=\\.)", |
| 469 | + "captures": { |
| 470 | + "1": { |
| 471 | + "name": "variable.other.object.kotlin" |
| 472 | + } |
| 473 | + } |
| 474 | + }, |
379 | 475 | "type-parameter": { |
380 | 476 | "patterns": [ |
381 | 477 | { |
382 | | - "match": "\\b\\w+\\b", |
383 | | - "name": "entity.name.type.kotlin" |
| 478 | + "match": "(:)?\\s*(\\b\\w+\\b)(\\?)?", |
| 479 | + "captures": { |
| 480 | + "1": { |
| 481 | + "name": "keyword.operator.assignment.kotlin" |
| 482 | + }, |
| 483 | + "2": { |
| 484 | + "name": "entity.name.type.kotlin" |
| 485 | + }, |
| 486 | + "3": { |
| 487 | + "name": "keyword.operator.optional" |
| 488 | + } |
| 489 | + } |
384 | 490 | }, |
385 | 491 | { |
386 | 492 | "match": "\\b(in|out)\\b", |
|
401 | 507 | } |
402 | 508 | }, |
403 | 509 | "function-call": { |
404 | | - "match": "\\??\\.?(\\b\\w+\\b|`[^`]+`)\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?\\s*(?=[({])", |
| 510 | + "match": "(?:(\\?\\.)|(\\.))?(\\b\\w+\\b|`[^`]+`)\\s*(?<GROUP><([^<>]|\\g<GROUP>)+>)?\\s*(?=[({])", |
405 | 511 | "captures": { |
406 | 512 | "1": { |
407 | | - "name": "entity.name.function.call.kotlin" |
| 513 | + "name": "punctuation.accessor.optional.kotlin" |
408 | 514 | }, |
409 | 515 | "2": { |
| 516 | + "name": "punctuation.separator.period.kotlin" |
| 517 | + }, |
| 518 | + "3": { |
| 519 | + "name": "entity.name.function.call.kotlin" |
| 520 | + }, |
| 521 | + "4": { |
410 | 522 | "patterns": [ |
411 | 523 | { |
412 | 524 | "include": "#type-parameter" |
|
415 | 527 | } |
416 | 528 | } |
417 | 529 | }, |
| 530 | + "property.reference": { |
| 531 | + "match": "(?:(\\?\\.)|(\\.))(\\w+)\\b", |
| 532 | + "captures": { |
| 533 | + "1": { |
| 534 | + "name": "punctuation.accessor.optional.kotlin" |
| 535 | + }, |
| 536 | + "2": { |
| 537 | + "name": "punctuation.separator.period.kotlin" |
| 538 | + }, |
| 539 | + "3": { |
| 540 | + "name": "variable.other.property.kotlin" |
| 541 | + } |
| 542 | + } |
| 543 | + }, |
418 | 544 | "method-reference": { |
419 | 545 | "match": "\\??::(\\b\\w+\\b|`[^`]+`)", |
420 | 546 | "captures": { |
|
537 | 663 | "match": "(===?|\\!==?|<=|>=|<|>)", |
538 | 664 | "name": "keyword.operator.comparison.kotlin" |
539 | 665 | }, |
| 666 | + { |
| 667 | + "match": "(\\?:)", |
| 668 | + "name": "keyword.operator.elvis.kotlin" |
| 669 | + }, |
540 | 670 | { |
541 | 671 | "match": "([+*/%-]=)", |
542 | 672 | "name": "keyword.operator.assignment.arithmetic.kotlin" |
|
0 commit comments