mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 01:40: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] [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)
|
- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka)
|
||||||
- [ ] [julia](https://github.com/tree-sitter/tree-sitter-julia)
|
- [ ] [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] [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] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
|
||||||
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
|
- [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",
|
url = "https://github.com/QthCN/tree-sitter-kotlin",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
|
maintainers = {"@tormodatt"},
|
||||||
}
|
}
|
||||||
|
|
||||||
list.html = {
|
list.html = {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
;;; Kotlin
|
;;; Kotlin
|
||||||
;; Issues
|
;; Issues
|
||||||
|
|
||||||
; mapOf with type definition AND multiple entries are not highligted correctly. Issue in parser. Eg.
|
; 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)
|
; 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
|
;; Strings
|
||||||
|
|
||||||
;; String
|
|
||||||
|
|
||||||
(line_string_literal) @string
|
(line_string_literal) @string
|
||||||
(multi_line_string_literal) @string
|
(multi_line_string_literal) @string
|
||||||
(line_string_literal (interpolated_identifier)) @string
|
; Interpolated
|
||||||
(line_string_literal (interpolated_expression (line_string_literal))) @string
|
(interpolated_identifier) @none
|
||||||
|
(interpolated_expression) @none
|
||||||
|
|
||||||
|
|
||||||
;; Constants
|
;; Constants
|
||||||
; Assume all-caps names are constants
|
; Assume all-caps names are constants
|
||||||
|
|
@ -20,17 +21,24 @@
|
||||||
(#vim-match? @constant "^[A-Z][A-Z_]+"))
|
(#vim-match? @constant "^[A-Z][A-Z_]+"))
|
||||||
|
|
||||||
|
|
||||||
;; Variables
|
;; Variables/fields
|
||||||
(class_parameter (simple_identifier) @variable.builtin)
|
; 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
|
(statements (navigation_expression (simple_identifier) @field))
|
||||||
(property_declaration (variable_declaration (simple_identifier) @variable.builtin))
|
|
||||||
|
|
||||||
(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
|
; TODO not supported yet
|
||||||
|
|
@ -41,44 +49,55 @@
|
||||||
|
|
||||||
|
|
||||||
;; Property access syntax
|
;; Property access syntax
|
||||||
; TODO
|
; `value` in `a = get().value`
|
||||||
; a = get().value etc
|
(assignment (navigation_expression (navigation_suffix) @property ))
|
||||||
(assignment (navigation_expression (navigation_suffix) @type ))
|
; `value` in `val a = A.get().value`
|
||||||
; val a = A.get().value etc
|
(property_declaration (navigation_expression (navigation_suffix) @property ))
|
||||||
(property_declaration (navigation_expression (navigation_suffix) @type ))
|
; `value` in `mapOf(A.value to B.value)`
|
||||||
; value in `mapOf(A.value to B.value)` etc.
|
(infix_expression (navigation_expression (navigation_suffix) @property ))
|
||||||
(infix_expression (navigation_expression (navigation_suffix) @type ))
|
|
||||||
; java in `Car::class.java`
|
; java in `Car::class.java`
|
||||||
(value_argument (navigation_expression (navigation_suffix) @type ))
|
(value_argument (navigation_expression (navigation_suffix) @method ))
|
||||||
|
|
||||||
|
|
||||||
;; Interpolated
|
|
||||||
|
|
||||||
(interpolated_identifier) @type
|
|
||||||
(interpolated_expression) @type
|
|
||||||
|
|
||||||
|
|
||||||
;; Builtin functions
|
;; 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
|
((simple_identifier) @function.builtin
|
||||||
(#vim-match? @function.builtin "(^let$|^listOf$|^mapOf$|^map$)"))
|
(#vim-match? @function.builtin "(^print$|^println$)"))
|
||||||
|
|
||||||
|
|
||||||
((simple_identifier) @function.builtin
|
((simple_identifier) @keyword.operator
|
||||||
(#vim-match? @function.builtin "^to$"))
|
(#vim-match? @keyword.operator "^to$"))
|
||||||
|
|
||||||
|
|
||||||
(modifiers (annotation (user_type (type_identifier)))) @attribute
|
;; Numbers
|
||||||
|
|
||||||
(annotation) @attribute
|
|
||||||
|
|
||||||
(integer_literal) @number
|
(integer_literal) @number
|
||||||
|
|
||||||
|
;; Booleans
|
||||||
(boolean_literal) @boolean
|
(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
|
;; it
|
||||||
(indexing_expression (simple_identifier) @type
|
(indexing_expression (simple_identifier) @variable.builtin
|
||||||
(#vim-match? @type "^it$"))
|
(#vim-match? @variable.builtin "^it$"))
|
||||||
|
|
||||||
|
|
||||||
|
;; Keyword operators
|
||||||
|
|
||||||
|
[
|
||||||
|
"in"
|
||||||
|
] @keyword.operator
|
||||||
|
|
||||||
|
|
||||||
;; Keywords
|
;; Keywords
|
||||||
|
|
@ -99,6 +118,7 @@
|
||||||
"companion"
|
"companion"
|
||||||
"return"
|
"return"
|
||||||
"constructor"
|
"constructor"
|
||||||
|
"throw"
|
||||||
] @keyword
|
] @keyword
|
||||||
; const does not work
|
; const does not work
|
||||||
|
|
||||||
|
|
@ -112,6 +132,13 @@
|
||||||
] @conditional
|
] @conditional
|
||||||
|
|
||||||
|
|
||||||
|
;; Loops
|
||||||
|
[
|
||||||
|
"for"
|
||||||
|
"while"
|
||||||
|
] @repeat
|
||||||
|
|
||||||
|
|
||||||
;; Includes
|
;; Includes
|
||||||
|
|
||||||
"import" @include
|
"import" @include
|
||||||
|
|
@ -121,11 +148,18 @@
|
||||||
;; Punctuation
|
;; Punctuation
|
||||||
|
|
||||||
[
|
[
|
||||||
|
"::"
|
||||||
";"
|
";"
|
||||||
"."
|
"."
|
||||||
","
|
","
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
[
|
||||||
|
"$"
|
||||||
|
"${"
|
||||||
|
"}"
|
||||||
|
] @none
|
||||||
|
|
||||||
[
|
[
|
||||||
"["
|
"["
|
||||||
"]"
|
"]"
|
||||||
|
|
@ -137,8 +171,6 @@
|
||||||
|
|
||||||
[
|
[
|
||||||
"$"
|
"$"
|
||||||
"${"
|
|
||||||
"}"
|
|
||||||
] @punctuation.special
|
] @punctuation.special
|
||||||
|
|
||||||
;; Comments
|
;; Comments
|
||||||
|
|
@ -159,4 +191,6 @@
|
||||||
"*"
|
"*"
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
|
; TODO parameter
|
||||||
|
|
||||||
(ERROR) @error
|
(ERROR) @error
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue