mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
add readme and more correct highlight captures
This commit is contained in:
parent
558d938c2e
commit
18fadcfd4b
3 changed files with 74 additions and 38 deletions
|
|
@ -150,6 +150,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka)
|
||||
- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka)
|
||||
- [ ] [julia](https://github.com/tree-sitter/tree-sitter-julia)
|
||||
- [x] [kotlin](https://github.com/QthCN/tree-sitter-kotlin) (maintained by @tormodatt)
|
||||
- [x] [lua](https://github.com/nvim-treesitter/tree-sitter-lua) (maintained by @vigoux)
|
||||
- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
|
||||
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ list.kotlin = {
|
|||
url = "https://github.com/QthCN/tree-sitter-kotlin",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = {"@tormodatt"},
|
||||
}
|
||||
|
||||
list.html = {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
;; 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 "(^let$|^listOf$|^mapOf$|^map$)"))
|
||||
(#vim-match? @function.builtin "(^print$|^println$)"))
|
||||
|
||||
|
||||
((simple_identifier) @function.builtin
|
||||
(#vim-match? @function.builtin "^to$"))
|
||||
((simple_identifier) @keyword.operator
|
||||
(#vim-match? @keyword.operator "^to$"))
|
||||
|
||||
|
||||
(modifiers (annotation (user_type (type_identifier)))) @attribute
|
||||
|
||||
(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,11 +148,18 @@
|
|||
;; Punctuation
|
||||
|
||||
[
|
||||
"::"
|
||||
";"
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"$"
|
||||
"${"
|
||||
"}"
|
||||
] @none
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
|
|
@ -137,8 +171,6 @@
|
|||
|
||||
[
|
||||
"$"
|
||||
"${"
|
||||
"}"
|
||||
] @punctuation.special
|
||||
|
||||
;; Comments
|
||||
|
|
@ -159,4 +191,6 @@
|
|||
"*"
|
||||
] @operator
|
||||
|
||||
; TODO parameter
|
||||
|
||||
(ERROR) @error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue