aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakker <joaquinandresleon108@gmail.com>2021-08-16 22:00:07 -0400
committerStephan Seitz <stephan.seitz@fau.de>2021-09-15 12:47:03 +0200
commit16a4da493c947d67a6559160a93f9f63887f1e24 (patch)
treec109e3a5d85887f768c978b844a5b25f237c8b43
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar.gz
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar.bz2
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar.lz
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar.xz
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.tar.zst
nvim-treesitter-16a4da493c947d67a6559160a93f9f63887f1e24.zip
New kotlin parser
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua4
-rw-r--r--queries/kotlin/highlights.scm313
3 files changed, 159 insertions, 160 deletions
diff --git a/lockfile.json b/lockfile.json
index d7a52002f..3ccd631b1 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -117,7 +117,7 @@
"revision": "12ea597262125fc22fd2e91aa953ac69b19c26ca"
},
"kotlin": {
- "revision": "48bfb38abd93f8d617877d7bb7f92a6bb1166285"
+ "revision": "0369bdc8a7ed42830ff718af1173129d2028769a"
},
"latex": {
"revision": "2c0d03a36ee979bc697f6a9dd119174cf0ef15e0"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index e0e80c115..eab78b134 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -205,10 +205,10 @@ list.java = {
list.kotlin = {
install_info = {
- url = "https://github.com/tormodatt/tree-sitter-kotlin",
+ url = "https://github.com/Joakker/tree-sitter-kotlin",
files = { "src/parser.c" },
},
- maintainers = { "@tormodatt" },
+ maintainers = { "@Joakker" },
}
list.html = {
diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm
index b31fc791d..285b1fb9a 100644
--- a/queries/kotlin/highlights.scm
+++ b/queries/kotlin/highlights.scm
@@ -1,191 +1,190 @@
-;;; Kotlin
-
-(simple_identifier) @variable
-; Reset some
-(navigation_suffix (simple_identifier) @none)
-(import_header (identifier (simple_identifier) @none))
-(package_header (identifier (simple_identifier) @none))
-
-
-;; Strings
-(line_string_literal) @string
-(multi_line_string_literal) @string
-; Interpolated
-(interpolated_identifier) @variable
-(interpolated_expression) @none
-
-
-;; Suffixes
-(navigation_expression (navigation_suffix (simple_identifier) @property ))
-; Reset some
-(assignment (navigation_expression (navigation_suffix (simple_identifier) @none )))
-(call_expression (navigation_expression (navigation_suffix (simple_identifier) @none )))
-(navigation_expression (navigation_expression (navigation_suffix (simple_identifier) @none )))
-
-
-
-;; Variables/fields
-; attribute in data classes etc.
-(class_parameter (simple_identifier) @field)
-; 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) @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) @variable)
-
-
-;; Constants
-; Assume all-caps names are constants
-((simple_identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]+$"))
-((interpolated_identifier) @constant
- (#vim-match? @constant "^[A-Z][A-Z_0-9]+$"))
-
-
-(lambda_parameters) @parameter
-
-
-;; Builtin functions
-((simple_identifier) @function.macro
- (#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)$"))
-
-(call_expression
- (simple_identifier) @function)
-
-((simple_identifier) @function.builtin
- (#vim-match? @function.builtin "^(print|println|buildMap|emptyMap|hashMapOf|linkedMapOf|mapOf|mutableMapOf|buildSet|emptySet|hashSetOf|linkedSetOf|mutableSetOf|setOf|setOfNotNull|TODO|repeat|run|with)$"))
+[
+ (comment)
+ (shebang)
+] @comment
+[
+ ":"
+ ","
+ "."
+] @punctuation.delimiter
-;; Numbers
-(integer_literal) @number
+[
+ "("
+ ")"
+ "{"
+ "}"
+] @punctuation.bracket
-;; Booleans
-(boolean_literal) @boolean
+[
+ "class"
+ "object"
+ "fun"
+ "var"
+ "val"
+ "try"
+ "catch"
+ "finally"
+] @keyword
-;; Types
-(type_identifier) @type
+"import" @include
-;; Annotations
-(annotation (single_annotation) @attribute)
-(single_annotation (user_type (type_identifier) @attribute))
-(single_annotation (constructor_invocation (user_type (type_identifier) @attribute)))
+"return" @keyword.return
+(return_expr
+ "return@" @keyword.return
+ label: (identifier) @label)
+(break_expr
+ "break@" @keyword
+ label: (identifier) @label)
-;; it
-(indexing_expression (simple_identifier) @variable.builtin
- (#vim-match? @variable.builtin "^it$"))
+(label
+ name: (identifier) @label) @constant
+[
+ "for"
+ "do"
+ "while"
+] @repeat
-;; Operators
[
-"="
-"-"
-"->"
-"+"
-"++"
-"--"
-"*"
+ "||"
+ "&&"
+ "!="
+ "!=="
+ "=="
+ "==="
+ "<"
+ ">"
+ "<="
+ ">="
+ ".."
+ "+"
+ "-"
+ "%"
+ "*"
+ "/"
] @operator
-;; Keyword operators
[
-"in"
+ "as"
+ "as?"
+ "in"
] @keyword.operator
-((simple_identifier) @keyword.operator
- (#vim-match? @keyword.operator "^to$"))
-
+(class_decl
+ name: (identifier) @type)
+(class_decl
+ super: (_) @type)
+(object_decl
+ name: (identifier) @type)
-;; Keywords
-[
- "this"
- "override"
- "enum"
- "as"
- "class"
- "object"
- "data"
- "val"
- "init"
- "private"
- "var"
- "break"
- "by"
- "companion"
- "constructor"
- "throw"
-] @keyword
+(class_param
+ name: (identifier) @parameter
+ type: (_) @type)
-"fun" @keyword.function
-"return" @keyword.return
+(type_constraints
+ "where" @keyword
+ (type_constraint
+ type: (identifier) @type
+ super: (_) @type))
-(null_literal) @keyword
+(property
+ name: (identifier) @property)
+(property
+ type: (_) @type)
-; const etc.
-(property_modifier) @keyword
+(enum_entry
+ name: (identifier) @constant)
+(func_decl
+ name: (identifier) @function)
+(func_decl
+ return: (_) @type)
-;; Conditionals
-[
-"if"
-"is"
-"else"
-"when"
-] @conditional
+(param_decl
+ name: (identifier) @parameter
+ type: (_) @type)
+(type_param
+ name: (identifier) @type)
-;; Loops
-[
-"for"
-"while"
-] @repeat
+(call
+ function: (identifier) @function)
+(call
+ function: (selector
+ field: (identifier) @function))
+(getter
+ "get" @function.builtin)
+(setter
+ "set" @function.builtin)
-;; Includes
+((identifier) @function.builtin
+ (#any-of? @function.builtin
+ "arrayOf"
+ "arrayOfNulls"
+ "assert"
+ "booleanArrayOf"
+ "byteArrayOf"
+ "Char"
+ "charArrayOf"
+ "check"
+ "checkNotNull"
+ "doubleArrayOf"
+ "emptyArray"
+ "enumValueOf"
+ "enumValues"
+ "error"
+ "floatArrayOf"
+ "intArrayOf"
+ "lazy"
+ "lazyOf"
+ "longArrayOf"
+ "repeat"
+ "require"
+ "requireNotNull"
+ "run"
+ "runCatching"
+ "shortArrayOf"
+ "suspend"
+ "synchronized"
+ "TODO"
+ "ubyteArrayOf"
+ "UintArray"
+ "uintArrayOf"
+ "ULongArray"
+ "ulongArrayOf"
+ "UShortArray"
+ "ushortArrayOf"
+ "with"
+ "print"
+ "println"
+ "readLine"))
+((identifier) @constant.builtin
+ (#eq? @constant.builtin "it"))
-"import" @include
-"package" @include
+(lambda
+ args: (var_decl
+ name: (identifier) @parameter))
+(lambda
+ args: (var_decl
+ type: (_) @type ))
+(binary_expr
+ operator: (identifier) @keyword.operator)
-;; Punctuation
+(ERROR) @error
-[
-"::"
-";"
-"."
-","
-] @punctuation.delimiter
+(integer) @number
+(float) @float
-[
-"$"
-"${"
-"}"
-] @none
+(string) @string
-[
-"["
-"]"
-"{"
-"}"
-"("
-")"
-] @punctuation.bracket
+"null" @constant
[
-"$"
-] @punctuation.special
-
-;; Comments
-(comment) @comment
-
-; Functions
-(function_declaration (simple_identifier) @function)
-
-
-(ERROR) @error
+ "true"
+ "false"
+] @boolean
-; TODO parameter