diff options
| author | Tormod Alf Try Tufteland <tormodat.tufteland@eika.no> | 2020-11-30 22:58:52 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-12-06 15:08:51 +0100 |
| commit | d90a4621a3c7371a7e96d9b01458be7596ed258b (patch) | |
| tree | 2d91e4a4a7f42f362299773a2b467b3c028b682f | |
| parent | Add some ruby exception keywords (diff) | |
| download | nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar.gz nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar.bz2 nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar.lz nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar.xz nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.tar.zst nvim-treesitter-d90a4621a3c7371a7e96d9b01458be7596ed258b.zip | |
add kotlin parser and highligh-queries
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 7 | ||||
| -rw-r--r-- | queries/kotlin/highlights.scm | 158 |
2 files changed, 165 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index afc2e4cb7..602b9b740 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -111,6 +111,13 @@ list.java = { maintainers = {"@p00f"}, } +list.kotlin = { + install_info = { + url = "https://github.com/QthCN/tree-sitter-kotlin", + files = { "src/parser.c" }, + }, +} + list.html = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-html", diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm new file mode 100644 index 000000000..6d84f0f4a --- /dev/null +++ b/queries/kotlin/highlights.scm @@ -0,0 +1,158 @@ +;;; 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) + + +(function_modifier) @type + +;; String + +(line_string_literal) @string +(multi_line_string_literal) @string +(line_string_literal (interpolated_identifier)) @string +(line_string_literal (interpolated_expression (line_string_literal))) @string + +;; Constants +; Assume all-caps names are constants +((simple_identifier) @constant + (#vim-match? @constant "^[A-Z][A-Z_]+")) + + +;; Variables +(class_parameter (simple_identifier) @variable.builtin) + +; Class level +(property_declaration (variable_declaration (simple_identifier) @variable.builtin)) + +(statements (call_expression (navigation_expression (simple_identifier) @variable.builtin))) + +(directly_assignable_expression (navigation_expression (simple_identifier) @variable.builtin)) + +(directly_assignable_expression (simple_identifier) @variable.builtin) + + +; TODO not supported yet +; (navigation_expression (simple_identifier) @type +; (#is-not? local)) +; (directly_assignable_expression (simple_identifier) @type +; (#is-not? local)) + + +;; 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 )) +; java in `Car::class.java` +(value_argument (navigation_expression (navigation_suffix) @type )) + + +;; Interpolated + +(interpolated_identifier) @type +(interpolated_expression) @type + + +;; Builtin functions +((simple_identifier) @function.builtin + (#vim-match? @function.builtin "(^let$|^listOf$|^mapOf$|^map$)")) + + +((simple_identifier) @function.builtin + (#vim-match? @function.builtin "^to$")) + + +(modifiers (annotation (user_type (type_identifier)))) @attribute + +(annotation) @attribute + +(integer_literal) @number + +(boolean_literal) @boolean + + +;; it +(indexing_expression (simple_identifier) @type + (#vim-match? @type "^it$")) + + +;; Keywords + +[ + "enum" + "as" + "class" + "object" + "data" + "val" + "init" + "private" + "var" + "break" + "by" + "fun" + "companion" + "return" + "constructor" +] @keyword +; const does not work + + +;; Conditionals +[ +"if" +"is" +"else" +"when" +] @conditional + + +;; Includes + +"import" @include +"package" @include + + +;; Punctuation + +[ +";" +"." +"," +] @punctuation.delimiter + +[ +"[" +"]" +"$" +"${" +"{" +"}" +"(" +")" +] @punctuation.bracket + +;; Comments +(comment) @comment + +; Methods + +(function_declaration (simple_identifier) @function) + + +[ +"=" +"-" +"->" +"+" +"++" +"--" +"*" +] @operator + +(ERROR) @error |
