mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 19:00:02 -04:00
add more builtin functions
This commit is contained in:
parent
18fadcfd4b
commit
c071454a18
1 changed files with 36 additions and 62 deletions
|
|
@ -1,13 +1,6 @@
|
||||||
;;; Kotlin
|
;;; 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
|
;; Strings
|
||||||
|
|
||||||
(line_string_literal) @string
|
(line_string_literal) @string
|
||||||
(multi_line_string_literal) @string
|
(multi_line_string_literal) @string
|
||||||
; Interpolated
|
; Interpolated
|
||||||
|
|
@ -15,6 +8,15 @@
|
||||||
(interpolated_expression) @none
|
(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
|
;; Constants
|
||||||
; Assume all-caps names are constants
|
; Assume all-caps names are constants
|
||||||
((simple_identifier) @constant
|
((simple_identifier) @constant
|
||||||
|
|
@ -22,55 +24,27 @@
|
||||||
|
|
||||||
|
|
||||||
;; Variables/fields
|
;; Variables/fields
|
||||||
; field in data classes etc.
|
; attribute in data classes etc.
|
||||||
(class_parameter (simple_identifier) @field)
|
(class_parameter (simple_identifier) @attribute)
|
||||||
; field in normal classes
|
; variable in normal classes
|
||||||
(property_declaration (variable_declaration (simple_identifier) @field))
|
(property_declaration (variable_declaration (simple_identifier) @variable))
|
||||||
; accessed field in blocks. `logger` in `logger.info("")`
|
; accessed field in blocks. `logger` in `logger.info("")`
|
||||||
(statements (call_expression (navigation_expression (simple_identifier) @field)))
|
(statements (call_expression (navigation_expression (simple_identifier) @variable)))
|
||||||
|
(indexing_expression (call_expression (navigation_expression (simple_identifier) @variable)))
|
||||||
(statements (navigation_expression (simple_identifier) @field))
|
; `classProp` in `classProp.lastIndex`
|
||||||
|
(statements (navigation_expression (simple_identifier) @variable))
|
||||||
(call_expression (navigation_expression (simple_identifier) @field))
|
|
||||||
|
|
||||||
; TODO check if this is needed
|
|
||||||
(directly_assignable_expression (navigation_expression (simple_identifier) @string))
|
|
||||||
; `variable` in `variable = car.doors`
|
; `variable` in `variable = car.doors`
|
||||||
(directly_assignable_expression (simple_identifier) @field)
|
(directly_assignable_expression (simple_identifier) @variable)
|
||||||
|
|
||||||
(lambda_parameters) @field
|
(lambda_parameters) @parameter
|
||||||
|
|
||||||
|
|
||||||
; TODO not supported yet
|
|
||||||
; (navigation_expression (simple_identifier) @type
|
|
||||||
; (#is-not? local))
|
|
||||||
; (directly_assignable_expression (simple_identifier) @type
|
|
||||||
; (#is-not? local))
|
|
||||||
|
|
||||||
|
|
||||||
;; 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 ))
|
|
||||||
|
|
||||||
|
|
||||||
;; Builtin functions
|
;; Builtin functions
|
||||||
;; TODO add more functions
|
|
||||||
((simple_identifier) @function.macro
|
((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
|
((simple_identifier) @function.builtin
|
||||||
(#vim-match? @function.builtin "(^print$|^println$)"))
|
(#vim-match? @function.builtin "(^print$|^println$|^buildMap$|^emptyMap$|^hashMapOf$|^linkedMapOf$|^mapOf$|^mutableMapOf$|^buildSet$|^emptySet$|^hashSetOf$|^linkedSetOf$|^mutableSetOf$|^setOf$|^setOfNotNull$|^TODO$|^repeat$|^run$|^with$)"))
|
||||||
|
|
||||||
|
|
||||||
((simple_identifier) @keyword.operator
|
|
||||||
(#vim-match? @keyword.operator "^to$"))
|
|
||||||
|
|
||||||
|
|
||||||
;; Numbers
|
;; Numbers
|
||||||
|
|
@ -93,15 +67,27 @@
|
||||||
(#vim-match? @variable.builtin "^it$"))
|
(#vim-match? @variable.builtin "^it$"))
|
||||||
|
|
||||||
|
|
||||||
;; Keyword operators
|
;; Operators
|
||||||
|
[
|
||||||
|
"="
|
||||||
|
"-"
|
||||||
|
"->"
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"--"
|
||||||
|
"*"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
;; Keyword operators
|
||||||
[
|
[
|
||||||
"in"
|
"in"
|
||||||
] @keyword.operator
|
] @keyword.operator
|
||||||
|
|
||||||
|
((simple_identifier) @keyword.operator
|
||||||
|
(#vim-match? @keyword.operator "^to$"))
|
||||||
|
|
||||||
|
|
||||||
;; Keywords
|
;; Keywords
|
||||||
|
|
||||||
[
|
[
|
||||||
"enum"
|
"enum"
|
||||||
"as"
|
"as"
|
||||||
|
|
@ -176,21 +162,9 @@
|
||||||
;; Comments
|
;; Comments
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
; Methods
|
; Functions
|
||||||
|
|
||||||
(function_declaration (simple_identifier) @function)
|
(function_declaration (simple_identifier) @function)
|
||||||
|
|
||||||
|
|
||||||
[
|
|
||||||
"="
|
|
||||||
"-"
|
|
||||||
"->"
|
|
||||||
"+"
|
|
||||||
"++"
|
|
||||||
"--"
|
|
||||||
"*"
|
|
||||||
] @operator
|
|
||||||
|
|
||||||
; TODO parameter
|
; TODO parameter
|
||||||
|
|
||||||
(ERROR) @error
|
(ERROR) @error
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue