aboutsummaryrefslogtreecommitdiffstats
path: root/queries
diff options
context:
space:
mode:
authorTormod Alf Try Tufteland <tormodat.tufteland@eika.no>2020-12-02 21:27:25 +0100
committerStephan Seitz <stephan.lauf@yahoo.de>2020-12-06 15:08:51 +0100
commit18fadcfd4b88bd084ff227734ce8fe2a0b14d240 (patch)
tree8f1c0a84aa49bafc6d063b8c0e0c82d5f7583018 /queries
parentmove divide to punctiation.special (diff)
downloadnvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar.gz
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar.bz2
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar.lz
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar.xz
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.tar.zst
nvim-treesitter-18fadcfd4b88bd084ff227734ce8fe2a0b14d240.zip
add readme and more correct highlight captures
Diffstat (limited to 'queries')
-rw-r--r--queries/kotlin/highlights.scm108
1 files changed, 71 insertions, 37 deletions
diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm
index 60ab279ac..e896b74a3 100644
--- a/queries/kotlin/highlights.scm
+++ b/queries/kotlin/highlights.scm
@@ -1,18 +1,19 @@
-;;; 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)`
-(function_modifier) @type
-
-;; String
+;; Strings
(line_string_literal) @string
(multi_line_string_literal) @string
-(line_string_literal (interpolated_identifier)) @string
-(line_string_literal (interpolated_expression (line_string_literal))) @string
+; Interpolated
+(interpolated_identifier) @none
+(interpolated_expression) @none
+
;; Constants
; Assume all-caps names are constants
@@ -20,17 +21,24 @@
(#vim-match? @constant "^[A-Z][A-Z_]+"))
-;; Variables
-(class_parameter (simple_identifier) @variable.builtin)
+;; Variables/fields
+; field in data classes etc.
+(class_parameter (simple_identifier) @field)
+; field in normal classes
+(property_declaration (variable_declaration (simple_identifier) @field))
+; accessed field in blocks. `logger` in `logger.info("")`
+(statements (call_expression (navigation_expression (simple_identifier) @field)))
-; Class level
-(property_declaration (variable_declaration (simple_identifier) @variable.builtin))
+(statements (navigation_expression (simple_identifier) @field))
-(statements (call_expression (navigation_expression (simple_identifier) @variable.builtin)))
+(call_expression (navigation_expression (simple_identifier) @field))
-(directly_assignable_expression (navigation_expression (simple_identifier) @variable.builtin))
+; TODO check if this is needed
+(directly_assignable_expression (navigation_expression (simple_identifier) @string))
+; `variable` in `variable = car.doors`
+(directly_assignable_expression (simple_identifier) @field)
-(directly_assignable_expression (simple_identifier) @variable.builtin)
+(lambda_parameters) @field
; TODO not supported yet
@@ -41,44 +49,55 @@
;; Property access syntax
-; TODO
-; a = get().value etc
-(assignment (navigation_expression (navigation_suffix) @type ))
-; val a = A.get().value etc
-(property_declaration (navigation_expression (navigation_suffix) @type ))
-; value in `mapOf(A.value to B.value)` etc.
-(infix_expression (navigation_expression (navigation_suffix) @type ))
+; `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) @type ))
-
-
-;; Interpolated
-
-(interpolated_identifier) @type
-(interpolated_expression) @type
+(value_argument (navigation_expression (navigation_suffix) @method ))
;; Builtin functions
-((simple_identifier) @function.builtin
- (#vim-match? @function.builtin "(^let$|^listOf$|^mapOf$|^map$)"))
-
+;; TODO add more functions
+((simple_identifier) @function.macro
+ (#vim-match? @function.macro "(^let$|^listOf$|^mapOf$|^map$|^downto$)"))
+;; TODO add more functions
((simple_identifier) @function.builtin
- (#vim-match? @function.builtin "^to$"))
+ (#vim-match? @function.builtin "(^print$|^println$)"))
-(modifiers (annotation (user_type (type_identifier)))) @attribute
+((simple_identifier) @keyword.operator
+ (#vim-match? @keyword.operator "^to$"))
-(annotation) @attribute
+;; Numbers
(integer_literal) @number
+;; Booleans
(boolean_literal) @boolean
+;; Annotations
+(annotation (single_annotation) @annotation)
+
+;; Types
+; TODO more type definitions
+(variable_declaration (user_type (type_identifier) @type))
+(callable_reference (type_identifier) @type)
+
;; it
-(indexing_expression (simple_identifier) @type
- (#vim-match? @type "^it$"))
+(indexing_expression (simple_identifier) @variable.builtin
+ (#vim-match? @variable.builtin "^it$"))
+
+
+;; Keyword operators
+
+[
+"in"
+] @keyword.operator
;; Keywords
@@ -99,6 +118,7 @@
"companion"
"return"
"constructor"
+ "throw"
] @keyword
; const does not work
@@ -112,6 +132,13 @@
] @conditional
+;; Loops
+[
+"for"
+"while"
+] @repeat
+
+
;; Includes
"import" @include
@@ -121,12 +148,19 @@
;; Punctuation
[
+"::"
";"
"."
","
] @punctuation.delimiter
[
+"$"
+"${"
+"}"
+] @none
+
+[
"["
"]"
"{"
@@ -137,8 +171,6 @@
[
"$"
-"${"
-"}"
] @punctuation.special
;; Comments
@@ -159,4 +191,6 @@
"*"
] @operator
+; TODO parameter
+
(ERROR) @error