diff options
| author | Tormod Alf Try Tufteland <tormodat.tufteland@eika.no> | 2020-12-05 21:20:56 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-12-06 15:08:51 +0100 |
| commit | c071454a1839994bfef60dbea1debd5e87420d93 (patch) | |
| tree | 74aa951e1f15080b627367522974faa19109c815 | |
| parent | add readme and more correct highlight captures (diff) | |
| download | nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar.gz nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar.bz2 nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar.lz nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar.xz nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.tar.zst nvim-treesitter-c071454a1839994bfef60dbea1debd5e87420d93.zip | |
add more builtin functions
| -rw-r--r-- | queries/kotlin/highlights.scm | 98 |
1 files changed, 36 insertions, 62 deletions
diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm index e896b74a3..86a1e5a3a 100644 --- a/queries/kotlin/highlights.scm +++ b/queries/kotlin/highlights.scm @@ -1,13 +1,6 @@ ;;; Kotlin -;; Issues - -; mapOf with type definition AND multiple entries are not highligted correctly. Issue in parser. Eg. -; a = mapOf<String, String>(AA.value to AA.value, AA.value to AA.value) - -;; parser does not recognice `in` and `downto` in `for (i in 5..1) print(i)` ;; Strings - (line_string_literal) @string (multi_line_string_literal) @string ; Interpolated @@ -15,6 +8,15 @@ (interpolated_expression) @none +;; Suffixes +;; Issues: +;; - `doors` in `c = car.doors` not reconized +(navigation_expression (navigation_suffix) @property ) ; TODO to method and resetable italics +(assignment (navigation_expression (navigation_suffix) @none )) +(call_expression (navigation_expression (navigation_suffix) @none )) +(navigation_expression (navigation_expression (navigation_suffix) @none )) +(parenthesized_expression (navigation_expression (navigation_suffix) @property)) + ;; Constants ; Assume all-caps names are constants ((simple_identifier) @constant @@ -22,55 +24,27 @@ ;; Variables/fields -; field in data classes etc. -(class_parameter (simple_identifier) @field) -; field in normal classes -(property_declaration (variable_declaration (simple_identifier) @field)) +; attribute in data classes etc. +(class_parameter (simple_identifier) @attribute) +; variable in normal classes +(property_declaration (variable_declaration (simple_identifier) @variable)) ; accessed field in blocks. `logger` in `logger.info("")` -(statements (call_expression (navigation_expression (simple_identifier) @field))) - -(statements (navigation_expression (simple_identifier) @field)) - -(call_expression (navigation_expression (simple_identifier) @field)) - -; TODO check if this is needed -(directly_assignable_expression (navigation_expression (simple_identifier) @string)) +(statements (call_expression (navigation_expression (simple_identifier) @variable))) +(indexing_expression (call_expression (navigation_expression (simple_identifier) @variable))) +; `classProp` in `classProp.lastIndex` +(statements (navigation_expression (simple_identifier) @variable)) ; `variable` in `variable = car.doors` -(directly_assignable_expression (simple_identifier) @field) - -(lambda_parameters) @field - - -; TODO not supported yet -; (navigation_expression (simple_identifier) @type -; (#is-not? local)) -; (directly_assignable_expression (simple_identifier) @type -; (#is-not? local)) - +(directly_assignable_expression (simple_identifier) @variable) -;; Property access syntax -; `value` in `a = get().value` -(assignment (navigation_expression (navigation_suffix) @property )) -; `value` in `val a = A.get().value` -(property_declaration (navigation_expression (navigation_suffix) @property )) -; `value` in `mapOf(A.value to B.value)` -(infix_expression (navigation_expression (navigation_suffix) @property )) -; java in `Car::class.java` -(value_argument (navigation_expression (navigation_suffix) @method )) +(lambda_parameters) @parameter ;; Builtin functions -;; TODO add more functions ((simple_identifier) @function.macro - (#vim-match? @function.macro "(^let$|^listOf$|^mapOf$|^map$|^downto$)")) + (#vim-match? @function.macro "(^commonPrefixWith$|^commonSuffixWith$|^endsWith$|^findAnyOf$|^findLastAnyOf$|^hasSurrogatePairAt$|^ifBlank$|^ifEmpty$|^indexOf$|^indexOfAny$|^isEmpty$|^isNotBlank$|^isNotEmpty$|^isNullOrBlank$|^isNullOrEmpty$|^lastIndexOf$|^lastIndexOfAny$|^lineSequence$|^lines$|^orEmpty$|^padEnd$|^padStart$|^removePrefix$|^removeRange$|^removeSuffix$|^removeSurrounding$|^replace$|^replaceAfter$|^replaceAfterLast$|^replaceBefore$|^replaceBeforeLast$|^replaceFirst$|^replaceRange$|^split$|^splitToSequence$|^startsWith$|^subSequence$|^substring$|^substringAfter$|^substringAfterLast$|^substringBefore$|^substringBeforeLast$|^trim$|^trimEnd$|^trimStart$|^containsKey$|^containsValue$|^filter$|^filterKeys$|^filterNot$|^filterNotTo$|^filterTo$|^filterValues$|^getOrElse$|^getOrPut$|^getValue$|^ifEmpty$|^isNotEmpty$|^isNullOrEmpty$|^mapKeys$|^mapKeysTo$|^mapValues$|^mapValuesTo$|^orEmpty$|^putAll$|^remove$|^toMap$|^toMutableMap$|^toPair$|^also$|^apply$|^let$|^run$|^takeIf$|^takeUnless$|^prependIndent$|^replaceIndent$|^replaceIndentByMargin$|^trimIndent$|^trimMargin$|^all$|^any$|^asIterable$|^asSequence$|^associate$|^associateBy$|^associateByTo$|^associateTo$|^associateWith$|^associateWithTo$|^chunked$|^chunkedSequence$|^count$|^drop$|^dropLast$|^dropLastWhile$|^dropWhile$|^elementAtOrElse$|^elementAtOrNull$|^filter$|^filterIndexed$|^filterIndexedTo$|^filterNot$|^filterNotTo$|^filterTo$|^find$|^findLast$|^first$|^firstOrNull$|^flatMap$|^flatMapIndexed$|^flatMapIndexedTo$|^flatMapTo$|^fold$|^foldIndexed$|^foldRight$|^foldRightIndexed$|^forEach$|^forEachIndexed$|^getOrElse$|^getOrNull$|^groupBy$|^groupByTo$|^groupingBy$|^indexOfFirst$|^indexOfLast$|^last$|^lastOrNull$|^map$|^mapIndexed$|^mapIndexedNotNull$|^mapIndexedNotNullTo$|^mapIndexedTo$|^mapNotNull$|^mapNotNullTo$|^mapTo$|^max$|^maxBy$|^maxByOrNull$|^maxOf$|^maxOfOrNull$|^maxOfWith$|^maxOfWithOrNull$|^maxOrNull$|^maxWith$|^maxWithOrNull$|^min$|^minBy$|^minByOrNull$|^minOf$|^minOfOrNull$|^minOfWith$|^minOfWithOrNull$|^minOrNull$|^minWith$|^minWithOrNull$|^none$|^onEach$|^onEachIndexed$|^partition$|^random$|^randomOrNull$|^reduce$|^reduceIndexed$|^reduceIndexedOrNull$|^reduceOrNull$|^reduceRight$|^reduceRightIndexed$|^reduceRightIndexedOrNull$|^reduceRightOrNull$|^reversed$|^runningFold$|^runningFoldIndexed$|^runningReduce$|^runningReduceIndexed$|^scan$|^scanIndexed$|^scanReduce$|^scanReduceIndexed$|^single$|^singleOrNull$|^slice$|^sumBy$|^sumByDouble$|^sumOf$|^take$|^takeLast$|^takeLastWhile$|^takeWhile$|^toCollection$|^toHashSet$|^toList$|^toMutableList$|^toSet$|^windowed$|^windowedSequence$|^withIndex$|^zip$|^zipWithNext$)")) -;; TODO add more functions ((simple_identifier) @function.builtin - (#vim-match? @function.builtin "(^print$|^println$)")) - - -((simple_identifier) @keyword.operator - (#vim-match? @keyword.operator "^to$")) + (#vim-match? @function.builtin "(^print$|^println$|^buildMap$|^emptyMap$|^hashMapOf$|^linkedMapOf$|^mapOf$|^mutableMapOf$|^buildSet$|^emptySet$|^hashSetOf$|^linkedSetOf$|^mutableSetOf$|^setOf$|^setOfNotNull$|^TODO$|^repeat$|^run$|^with$)")) ;; Numbers @@ -93,15 +67,27 @@ (#vim-match? @variable.builtin "^it$")) -;; Keyword operators +;; Operators +[ +"=" +"-" +"->" +"+" +"++" +"--" +"*" +] @operator +;; Keyword operators [ "in" ] @keyword.operator +((simple_identifier) @keyword.operator + (#vim-match? @keyword.operator "^to$")) -;; Keywords +;; Keywords [ "enum" "as" @@ -176,21 +162,9 @@ ;; Comments (comment) @comment -; Methods - +; Functions (function_declaration (simple_identifier) @function) - -[ -"=" -"-" -"->" -"+" -"++" -"--" -"*" -] @operator - ; TODO parameter (ERROR) @error |
