mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 19:30:02 -04:00
Refactor (new syntax)
This commit is contained in:
parent
7372837300
commit
40cc924bf4
1 changed files with 67 additions and 42 deletions
|
|
@ -2,22 +2,34 @@
|
|||
|
||||
; Methods
|
||||
|
||||
(method_declaration
|
||||
name: (identifier) @method)
|
||||
(method_declaration
|
||||
parameters: (formal_parameter) @parameter)
|
||||
(method_invocation
|
||||
name: (identifier) @method)
|
||||
[
|
||||
(method_declaration
|
||||
name: (identifier))
|
||||
|
||||
(method_invocation
|
||||
name: (identifier))
|
||||
] @method
|
||||
|
||||
[
|
||||
(method_declaration
|
||||
parameters: (formal_parameter))
|
||||
(method_declaration
|
||||
parameters: (formal_parameter))
|
||||
] @parameter
|
||||
|
||||
(super) @function.builtin
|
||||
|
||||
; Annotations
|
||||
|
||||
(annotation
|
||||
name: (identifier) @attribute)
|
||||
(marker_annotation
|
||||
name: (identifier) @attribute)
|
||||
[
|
||||
(annotation
|
||||
name: (identifier))
|
||||
(marker_annotation
|
||||
name: (identifier))
|
||||
] @attribute
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"@"
|
||||
"+"
|
||||
|
|
@ -47,12 +59,18 @@
|
|||
|
||||
; Types
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @type)
|
||||
(class_declaration
|
||||
name: (identifier) @type)
|
||||
(enum_declaration
|
||||
name: (identifier) @type)
|
||||
[
|
||||
(interface_declaration
|
||||
name: (identifier))
|
||||
(class_declaration
|
||||
name: (identifier))
|
||||
(enum_declaration
|
||||
name: (identifier)
|
||||
(constructor_declaration
|
||||
name: (identifier))
|
||||
(type_identifier)
|
||||
] @type
|
||||
|
||||
|
||||
((field_access
|
||||
object: (identifier) @type)
|
||||
|
|
@ -61,15 +79,13 @@
|
|||
scope: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(constructor_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
(type_identifier) @type
|
||||
(boolean_type) @type.builtin
|
||||
(integral_type) @type.builtin
|
||||
(floating_point_type) @type.builtin
|
||||
(floating_point_type) @type.builtin
|
||||
(void_type) @type.builtin
|
||||
[
|
||||
(boolean_type)
|
||||
(integral_type)
|
||||
(floating_point_type)
|
||||
(floating_point_type)
|
||||
(void_type)
|
||||
] @type.builtin
|
||||
|
||||
; Variables
|
||||
|
||||
|
|
@ -77,16 +93,21 @@
|
|||
(#match? @constant "^_*[A-Z][A-Z\d_]+"))
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(this) @variable.builtin
|
||||
|
||||
; Literals
|
||||
|
||||
(hex_integer_literal) @number
|
||||
(decimal_integer_literal) @number
|
||||
(octal_integer_literal) @number
|
||||
(decimal_floating_point_literal) @float
|
||||
(hex_floating_point_literal) @float
|
||||
[
|
||||
(hex_integer_literal)
|
||||
(decimal_integer_literal)
|
||||
(octal_integer_literal)
|
||||
] @number
|
||||
|
||||
[
|
||||
(decimal_floating_point_literal)
|
||||
(hex_floating_point_literal)
|
||||
] @float
|
||||
|
||||
(character_literal) @character
|
||||
(string_literal) @string
|
||||
(null_literal) @constant.builtin
|
||||
|
|
@ -152,25 +173,29 @@
|
|||
"case"
|
||||
] @conditional
|
||||
|
||||
;
|
||||
;
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
] @repeat
|
||||
|
||||
;
|
||||
; Includes
|
||||
|
||||
"import" @include
|
||||
|
||||
; Punctuation
|
||||
|
||||
";" @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"] @punctuation.bracket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue