mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 02:40:09 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -1,10 +1,25 @@
|
|||
[ "." ";" ":" "," ] @punctuation.delimiter
|
||||
[
|
||||
"."
|
||||
";"
|
||||
":"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
; TODO: "\\(" ")" in interpolations should be @punctuation.special
|
||||
[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
[
|
||||
"\\("
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Identifiers
|
||||
(attribute) @variable
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
(self_expression) @variable.builtin
|
||||
|
||||
; Declarations
|
||||
|
|
@ -20,16 +35,35 @@
|
|||
(mutation_modifier)
|
||||
] @type.qualifier
|
||||
|
||||
(function_declaration (simple_identifier) @function.method)
|
||||
(function_declaration ["init" @constructor])
|
||||
(function_declaration
|
||||
(simple_identifier) @function.method)
|
||||
|
||||
(function_declaration
|
||||
"init" @constructor)
|
||||
|
||||
(throws) @keyword
|
||||
|
||||
(where_keyword) @keyword
|
||||
(parameter external_name: (simple_identifier) @variable.parameter)
|
||||
(parameter name: (simple_identifier) @variable.parameter)
|
||||
(type_parameter (type_identifier) @variable.parameter)
|
||||
(inheritance_constraint (identifier (simple_identifier) @variable.parameter))
|
||||
(equality_constraint (identifier (simple_identifier) @variable.parameter))
|
||||
(pattern bound_identifier: (simple_identifier)) @variable
|
||||
|
||||
(parameter
|
||||
external_name: (simple_identifier) @variable.parameter)
|
||||
|
||||
(parameter
|
||||
name: (simple_identifier) @variable.parameter)
|
||||
|
||||
(type_parameter
|
||||
(type_identifier) @variable.parameter)
|
||||
|
||||
(inheritance_constraint
|
||||
(identifier
|
||||
(simple_identifier) @variable.parameter))
|
||||
|
||||
(equality_constraint
|
||||
(identifier
|
||||
(simple_identifier) @variable.parameter))
|
||||
|
||||
(pattern
|
||||
bound_identifier: (simple_identifier)) @variable
|
||||
|
||||
[
|
||||
"typealias"
|
||||
|
|
@ -58,60 +92,114 @@
|
|||
(modify_specifier)
|
||||
] @keyword
|
||||
|
||||
(class_body (property_declaration (pattern (simple_identifier) @property)))
|
||||
(protocol_property_declaration (pattern (simple_identifier) @property))
|
||||
(class_body
|
||||
(property_declaration
|
||||
(pattern
|
||||
(simple_identifier) @property)))
|
||||
|
||||
(protocol_property_declaration
|
||||
(pattern
|
||||
(simple_identifier) @property))
|
||||
|
||||
(navigation_expression
|
||||
(navigation_suffix (simple_identifier) @property))
|
||||
(navigation_suffix
|
||||
(simple_identifier) @property))
|
||||
|
||||
(value_argument
|
||||
name: (value_argument_label) @property)
|
||||
|
||||
(import_declaration ["import" @keyword.import])
|
||||
(import_declaration
|
||||
"import" @keyword.import)
|
||||
|
||||
(enum_entry ["case" @keyword])
|
||||
(enum_entry
|
||||
"case" @keyword)
|
||||
|
||||
; Function calls
|
||||
(call_expression (simple_identifier) @function.call) ; foo()
|
||||
(call_expression ; foo.bar.baz(): highlight the baz()
|
||||
(navigation_expression
|
||||
(navigation_suffix (simple_identifier) @function.call)))
|
||||
(call_expression
|
||||
(prefix_expression (simple_identifier) @function.call)) ; .foo()
|
||||
(simple_identifier) @function.call) ; foo()
|
||||
|
||||
(call_expression
|
||||
; foo.bar.baz(): highlight the baz()
|
||||
(navigation_expression
|
||||
(navigation_suffix
|
||||
(simple_identifier) @function.call)))
|
||||
|
||||
(call_expression
|
||||
(prefix_expression
|
||||
(simple_identifier) @function.call)) ; .foo()
|
||||
|
||||
((navigation_expression
|
||||
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(directive) @function.macro
|
||||
|
||||
(diagnostic) @function.macro
|
||||
|
||||
; Statements
|
||||
(for_statement ["for" @keyword.repeat])
|
||||
(for_statement ["in" @keyword.repeat])
|
||||
(for_statement (pattern) @variable)
|
||||
(for_statement
|
||||
"for" @keyword.repeat)
|
||||
|
||||
(for_statement
|
||||
"in" @keyword.repeat)
|
||||
|
||||
(for_statement
|
||||
(pattern) @variable)
|
||||
|
||||
(else) @keyword
|
||||
|
||||
(as_operator) @keyword
|
||||
|
||||
["while" "repeat" "continue" "break"] @keyword.repeat
|
||||
[
|
||||
"while"
|
||||
"repeat"
|
||||
"continue"
|
||||
"break"
|
||||
] @keyword.repeat
|
||||
|
||||
["let" "var"] @keyword
|
||||
[
|
||||
"let"
|
||||
"var"
|
||||
] @keyword
|
||||
|
||||
(guard_statement
|
||||
"guard" @keyword.conditional)
|
||||
|
||||
(if_statement
|
||||
"if" @keyword.conditional)
|
||||
|
||||
(switch_statement
|
||||
"switch" @keyword.conditional)
|
||||
|
||||
(switch_entry
|
||||
"case" @keyword)
|
||||
|
||||
(switch_entry
|
||||
"fallthrough" @keyword)
|
||||
|
||||
(switch_entry
|
||||
(default_keyword) @keyword)
|
||||
|
||||
(guard_statement ["guard" @keyword.conditional])
|
||||
(if_statement ["if" @keyword.conditional])
|
||||
(switch_statement ["switch" @keyword.conditional])
|
||||
(switch_entry ["case" @keyword])
|
||||
(switch_entry ["fallthrough" @keyword])
|
||||
(switch_entry (default_keyword) @keyword)
|
||||
"return" @keyword.return
|
||||
(ternary_expression
|
||||
["?" ":"] @keyword.conditional)
|
||||
|
||||
["do" (throw_keyword) (catch_keyword)] @keyword
|
||||
(ternary_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional)
|
||||
|
||||
[
|
||||
"do"
|
||||
(throw_keyword)
|
||||
(catch_keyword)
|
||||
] @keyword
|
||||
|
||||
(statement_label) @label
|
||||
|
||||
; Comments
|
||||
[
|
||||
(comment)
|
||||
(multiline_comment)
|
||||
(comment)
|
||||
(multiline_comment)
|
||||
] @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
|
|
@ -125,25 +213,38 @@
|
|||
|
||||
; String literals
|
||||
(line_str_text) @string
|
||||
|
||||
(str_escaped_char) @string
|
||||
|
||||
(multi_line_str_text) @string
|
||||
|
||||
(raw_str_part) @string
|
||||
|
||||
(raw_str_end_part) @string
|
||||
|
||||
(raw_str_interpolation_start) @punctuation.special
|
||||
["\"" "\"\"\""] @string
|
||||
|
||||
[
|
||||
"\""
|
||||
"\"\"\""
|
||||
] @string
|
||||
|
||||
; Lambda literals
|
||||
(lambda_literal ["in" @keyword.operator])
|
||||
(lambda_literal
|
||||
"in" @keyword.operator)
|
||||
|
||||
; Basic literals
|
||||
[
|
||||
(integer_literal)
|
||||
(hex_literal)
|
||||
(oct_literal)
|
||||
(bin_literal)
|
||||
(integer_literal)
|
||||
(hex_literal)
|
||||
(oct_literal)
|
||||
(bin_literal)
|
||||
] @number
|
||||
|
||||
(real_literal) @number.float
|
||||
|
||||
(boolean_literal) @boolean
|
||||
|
||||
"nil" @constant.builtin
|
||||
|
||||
; Regex literals
|
||||
|
|
@ -151,39 +252,37 @@
|
|||
|
||||
; Operators
|
||||
(custom_operator) @operator
|
||||
|
||||
[
|
||||
"try"
|
||||
"try?"
|
||||
"try!"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"<"
|
||||
">"
|
||||
"<="
|
||||
">="
|
||||
"++"
|
||||
"--"
|
||||
"&"
|
||||
"~"
|
||||
"%="
|
||||
"!="
|
||||
"!=="
|
||||
"=="
|
||||
"==="
|
||||
"??"
|
||||
|
||||
"->"
|
||||
|
||||
"..<"
|
||||
"..."
|
||||
"try"
|
||||
"try?"
|
||||
"try!"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"<"
|
||||
">"
|
||||
"<="
|
||||
">="
|
||||
"++"
|
||||
"--"
|
||||
"&"
|
||||
"~"
|
||||
"%="
|
||||
"!="
|
||||
"!=="
|
||||
"=="
|
||||
"==="
|
||||
"??"
|
||||
"->"
|
||||
"..<"
|
||||
"..."
|
||||
(bang)
|
||||
] @operator
|
||||
|
||||
|
|
|
|||
|
|
@ -47,16 +47,13 @@
|
|||
_ @indent.branch
|
||||
(#not-has-type? @indent.branch type_parameters parameter))
|
||||
|
||||
|
||||
(ERROR
|
||||
[
|
||||
"<"
|
||||
"{"
|
||||
"("
|
||||
"<"
|
||||
"{"
|
||||
"("
|
||||
"["
|
||||
]
|
||||
) @indent.begin
|
||||
|
||||
]) @indent.begin
|
||||
|
||||
; if-elseif
|
||||
(if_statement
|
||||
|
|
@ -65,23 +62,34 @@
|
|||
; case Foo:
|
||||
; default Foo:
|
||||
; @attribute default Foo:
|
||||
(switch_entry . _ @indent.branch)
|
||||
(switch_entry
|
||||
.
|
||||
_ @indent.branch)
|
||||
|
||||
(function_declaration ")" @indent.branch)
|
||||
(function_declaration
|
||||
")" @indent.branch)
|
||||
|
||||
(type_parameters
|
||||
">" @indent.branch @indent.end .)
|
||||
|
||||
(tuple_expression
|
||||
")" @indent.branch @indent.end)
|
||||
|
||||
(value_arguments
|
||||
")" @indent.branch @indent.end)
|
||||
|
||||
(tuple_type
|
||||
")" @indent.branch @indent.end)
|
||||
|
||||
(type_parameters ">" @indent.branch @indent.end .)
|
||||
(tuple_expression ")" @indent.branch @indent.end)
|
||||
(value_arguments ")" @indent.branch @indent.end)
|
||||
(tuple_type ")" @indent.branch @indent.end)
|
||||
(modifiers
|
||||
(attribute ")" @indent.branch @indent.end))
|
||||
(attribute
|
||||
")" @indent.branch @indent.end))
|
||||
|
||||
[
|
||||
"}"
|
||||
"]"
|
||||
] @indent.branch @indent.end
|
||||
|
||||
|
||||
[
|
||||
; (ERROR)
|
||||
(comment)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
(import_declaration (identifier) @local.definition.import)
|
||||
(function_declaration name: (simple_identifier) @local.definition.function)
|
||||
(import_declaration
|
||||
(identifier) @local.definition.import)
|
||||
|
||||
(function_declaration
|
||||
name: (simple_identifier) @local.definition.function)
|
||||
|
||||
; Scopes
|
||||
[
|
||||
(statements)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(repeat_while_statement)
|
||||
(do_statement)
|
||||
(if_statement)
|
||||
(guard_statement)
|
||||
(switch_statement)
|
||||
(property_declaration)
|
||||
(function_declaration)
|
||||
(class_declaration)
|
||||
(protocol_declaration)
|
||||
(statements)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(repeat_while_statement)
|
||||
(do_statement)
|
||||
(if_statement)
|
||||
(guard_statement)
|
||||
(switch_statement)
|
||||
(property_declaration)
|
||||
(function_declaration)
|
||||
(class_declaration)
|
||||
(protocol_declaration)
|
||||
] @local.scope
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue