mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 02:10:15 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -5,20 +5,16 @@
|
|||
(enum_item)
|
||||
(impl_item)
|
||||
(type_item)
|
||||
|
||||
(use_declaration)
|
||||
(let_declaration)
|
||||
(namespace_definition)
|
||||
|
||||
(arguments)
|
||||
(implicit_arguments)
|
||||
(tuple_type)
|
||||
|
||||
(import_statement)
|
||||
(attribute_statement)
|
||||
(with_statement)
|
||||
(if_statement)
|
||||
|
||||
(function_definition)
|
||||
(struct_definition)
|
||||
(loop_expression)
|
||||
|
|
@ -26,6 +22,5 @@
|
|||
(match_expression)
|
||||
(call_expression)
|
||||
(tuple_expression)
|
||||
|
||||
(attribute_item)
|
||||
] @fold
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
; Preproc
|
||||
|
||||
[
|
||||
"%builtins"
|
||||
"%lang"
|
||||
] @keyword.directive
|
||||
|
||||
; Includes
|
||||
|
||||
(import_statement [ "from" "import" ] @keyword.import module_name: (dotted_name (identifier) @module . ))
|
||||
(import_statement
|
||||
[
|
||||
"from"
|
||||
"import"
|
||||
] @keyword.import
|
||||
module_name:
|
||||
(dotted_name
|
||||
(identifier) @module .))
|
||||
|
||||
[
|
||||
"as"
|
||||
|
|
@ -16,41 +21,42 @@
|
|||
] @keyword.import
|
||||
|
||||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Namespaces
|
||||
|
||||
(namespace_definition (identifier) @module)
|
||||
(namespace_definition
|
||||
(identifier) @module)
|
||||
|
||||
(mod_item
|
||||
name: (identifier) @module)
|
||||
|
||||
(use_list (self) @module)
|
||||
(use_list
|
||||
(self) @module)
|
||||
|
||||
(scoped_use_list (self) @module)
|
||||
(scoped_use_list
|
||||
(self) @module)
|
||||
|
||||
(scoped_identifier
|
||||
path: (identifier) @module)
|
||||
|
||||
(scoped_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @module))
|
||||
(scoped_identifier
|
||||
name: (identifier) @module))
|
||||
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @module)
|
||||
|
||||
((scoped_identifier
|
||||
path: (identifier) @type)
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
((scoped_identifier
|
||||
name: (identifier) @type)
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
name: (identifier) @type)
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
((scoped_identifier
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||
|
||||
((scoped_identifier
|
||||
path: (identifier) @type
|
||||
|
|
@ -68,17 +74,25 @@
|
|||
path: (identifier) @module)
|
||||
|
||||
(scoped_use_list
|
||||
path: (scoped_identifier
|
||||
(identifier) @module))
|
||||
path:
|
||||
(scoped_identifier
|
||||
(identifier) @module))
|
||||
|
||||
(use_list (scoped_identifier (identifier) @module . (_)))
|
||||
(use_list
|
||||
(scoped_identifier
|
||||
(identifier) @module
|
||||
.
|
||||
(_)))
|
||||
|
||||
(use_list (identifier) @type (#lua-match? @type "^[A-Z]"))
|
||||
(use_list
|
||||
(identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(use_as_clause alias: (identifier) @type (#lua-match? @type "^[A-Z]"))
|
||||
(use_as_clause
|
||||
alias: (identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
; 0.x
|
||||
"using"
|
||||
|
|
@ -96,7 +110,6 @@
|
|||
"with"
|
||||
"call"
|
||||
"nondet"
|
||||
|
||||
; 1.0
|
||||
"type"
|
||||
"impl"
|
||||
|
|
@ -133,9 +146,7 @@
|
|||
"match"
|
||||
] @keyword.conditional
|
||||
|
||||
[
|
||||
"loop"
|
||||
] @keyword.repeat
|
||||
"loop" @keyword.repeat
|
||||
|
||||
[
|
||||
"assert"
|
||||
|
|
@ -144,33 +155,52 @@
|
|||
] @keyword.exception
|
||||
|
||||
; Fields
|
||||
(implicit_arguments
|
||||
(typed_identifier
|
||||
(identifier) @variable.member))
|
||||
|
||||
(implicit_arguments (typed_identifier (identifier) @variable.member))
|
||||
(member_expression
|
||||
"."
|
||||
(identifier) @variable.member)
|
||||
|
||||
(member_expression "." (identifier) @variable.member)
|
||||
(call_expression
|
||||
(assignment_expression
|
||||
left: (identifier) @variable.member))
|
||||
|
||||
(call_expression (assignment_expression left: (identifier) @variable.member))
|
||||
|
||||
(tuple_expression (assignment_expression left: (identifier) @variable.member))
|
||||
(tuple_expression
|
||||
(assignment_expression
|
||||
left: (identifier) @variable.member))
|
||||
|
||||
(field_identifier) @variable.member
|
||||
|
||||
(shorthand_field_initializer (identifier) @variable.member)
|
||||
(shorthand_field_initializer
|
||||
(identifier) @variable.member)
|
||||
|
||||
; Parameters
|
||||
(arguments
|
||||
(typed_identifier
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
(arguments (typed_identifier (identifier) @variable.parameter))
|
||||
(call_expression
|
||||
(tuple_expression
|
||||
(assignment_expression
|
||||
left: (identifier) @variable.parameter)))
|
||||
|
||||
(call_expression (tuple_expression (assignment_expression left: (identifier) @variable.parameter)))
|
||||
(return_type
|
||||
(tuple_type
|
||||
(named_type
|
||||
.
|
||||
(identifier) @variable.parameter)))
|
||||
|
||||
(return_type (tuple_type (named_type . (identifier) @variable.parameter)))
|
||||
|
||||
(parameter (identifier) @variable.parameter)
|
||||
(parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
; Builtins
|
||||
(builtin_directive
|
||||
(identifier) @variable.builtin)
|
||||
|
||||
(builtin_directive (identifier) @variable.builtin)
|
||||
(lang_directive (identifier) @variable.builtin)
|
||||
(lang_directive
|
||||
(identifier) @variable.builtin)
|
||||
|
||||
[
|
||||
"ap"
|
||||
|
|
@ -179,32 +209,45 @@
|
|||
] @variable.builtin
|
||||
|
||||
; Functions
|
||||
(function_definition
|
||||
"func"
|
||||
(identifier) @function)
|
||||
|
||||
(function_definition "func" (identifier) @function)
|
||||
(function_definition "fn" (identifier) @function)
|
||||
(function_signature "fn" (identifier) @function)
|
||||
(extern_function_statement (identifier) @function)
|
||||
(function_definition
|
||||
"fn"
|
||||
(identifier) @function)
|
||||
|
||||
(function_signature
|
||||
"fn"
|
||||
(identifier) @function)
|
||||
|
||||
(extern_function_statement
|
||||
(identifier) @function)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
(identifier) @function.call .))
|
||||
function:
|
||||
(scoped_identifier
|
||||
(identifier) @function.call .))
|
||||
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call))
|
||||
function:
|
||||
(field_expression
|
||||
field: (field_identifier) @function.call))
|
||||
|
||||
[
|
||||
"jmp"
|
||||
] @function.builtin
|
||||
"jmp" @function.builtin
|
||||
|
||||
; Types
|
||||
(struct_definition
|
||||
.
|
||||
(identifier) @type
|
||||
(typed_identifier
|
||||
(identifier) @variable.member)?)
|
||||
|
||||
(struct_definition . (identifier) @type (typed_identifier (identifier) @variable.member)?)
|
||||
|
||||
(named_type (identifier) @type .)
|
||||
(named_type
|
||||
(identifier) @type .)
|
||||
|
||||
[
|
||||
(builtin_type)
|
||||
|
|
@ -217,7 +260,6 @@
|
|||
(type_identifier) @type
|
||||
|
||||
; Constants
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z_][A-Z0-9_]*$"))
|
||||
|
||||
|
|
@ -225,49 +267,68 @@
|
|||
name: (identifier) @constant)
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
"::"
|
||||
name: (identifier) @constant)
|
||||
function:
|
||||
(scoped_identifier
|
||||
"::"
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((match_arm
|
||||
pattern: (match_pattern (identifier) @constant))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
pattern:
|
||||
(match_pattern
|
||||
(identifier) @constant))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(scoped_identifier
|
||||
name: (identifier) @constant)))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
pattern:
|
||||
(match_pattern
|
||||
(scoped_identifier
|
||||
name: (identifier) @constant)))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
|
||||
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
|
||||
|
||||
; Constructors
|
||||
(unary_expression
|
||||
"new"
|
||||
(call_expression
|
||||
.
|
||||
(identifier) @constructor))
|
||||
|
||||
(unary_expression "new" (call_expression . (identifier) @constructor))
|
||||
|
||||
((call_expression . (identifier) @constructor)
|
||||
((call_expression
|
||||
.
|
||||
(identifier) @constructor)
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
; Attributes
|
||||
(decorator
|
||||
"@" @attribute
|
||||
(identifier) @attribute)
|
||||
|
||||
(decorator "@" @attribute (identifier) @attribute)
|
||||
(attribute_item
|
||||
(identifier) @function.macro)
|
||||
|
||||
(attribute_item (identifier) @function.macro)
|
||||
|
||||
(attribute_item (scoped_identifier (identifier) @function.macro .))
|
||||
(attribute_item
|
||||
(scoped_identifier
|
||||
(identifier) @function.macro .))
|
||||
|
||||
; Labels
|
||||
(label
|
||||
.
|
||||
(identifier) @label)
|
||||
|
||||
(label . (identifier) @label)
|
||||
(inst_jmp_to_label
|
||||
"jmp"
|
||||
.
|
||||
(identifier) @label)
|
||||
|
||||
(inst_jmp_to_label "jmp" . (identifier) @label)
|
||||
|
||||
(inst_jnz_to_label "jmp" . (identifier) @label)
|
||||
(inst_jnz_to_label
|
||||
"jmp"
|
||||
.
|
||||
(identifier) @label)
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
|
|
@ -307,7 +368,6 @@
|
|||
] @operator
|
||||
|
||||
; Literals
|
||||
|
||||
(number) @number
|
||||
|
||||
(boolean) @boolean
|
||||
|
|
@ -318,17 +378,41 @@
|
|||
] @string
|
||||
|
||||
; Punctuation
|
||||
(attribute_item
|
||||
"#" @punctuation.special)
|
||||
|
||||
(attribute_item "#" @punctuation.special)
|
||||
[
|
||||
"."
|
||||
","
|
||||
":"
|
||||
";"
|
||||
"->"
|
||||
"=>"
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[ "." "," ":" ";" "->" "=>" "::" ] @punctuation.delimiter
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"%{"
|
||||
"%}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[ "{" "}" "(" ")" "[" "]" "%{" "%}" ] @punctuation.bracket
|
||||
(type_parameters
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(type_parameters [ "<" ">" ] @punctuation.bracket)
|
||||
|
||||
(type_arguments [ "<" ">" ] @punctuation.bracket)
|
||||
(type_arguments
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
; Comment
|
||||
|
||||
(comment) @comment @spell
|
||||
|
|
|
|||
|
|
@ -18,19 +18,36 @@
|
|||
(tuple_pattern)
|
||||
] @indent.begin
|
||||
|
||||
(import_statement "(") @indent.begin
|
||||
(import_statement
|
||||
"(") @indent.begin
|
||||
|
||||
(block
|
||||
"}" @indent.end)
|
||||
|
||||
(block "}" @indent.end)
|
||||
(enum_item
|
||||
body: (enum_variant_list "}" @indent.end))
|
||||
body:
|
||||
(enum_variant_list
|
||||
"}" @indent.end))
|
||||
|
||||
(match_expression
|
||||
body: (match_block "}" @indent.end))
|
||||
body:
|
||||
(match_block
|
||||
"}" @indent.end))
|
||||
|
||||
(mod_item
|
||||
body: (declaration_list "}" @indent.end))
|
||||
body:
|
||||
(declaration_list
|
||||
"}" @indent.end))
|
||||
|
||||
(struct_item
|
||||
body: (field_declaration_list "}" @indent.end))
|
||||
body:
|
||||
(field_declaration_list
|
||||
"}" @indent.end))
|
||||
|
||||
(trait_item
|
||||
body: (declaration_list "}" @indent.end))
|
||||
body:
|
||||
(declaration_list
|
||||
"}" @indent.end))
|
||||
|
||||
[
|
||||
")"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
(python_code) @python
|
||||
((python_code) @injection.content
|
||||
(#set! injection.language "python"))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
; References
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
((type_identifier) @local.reference
|
||||
(#set! reference.kind "type"))
|
||||
|
||||
((field_identifier) @local.reference
|
||||
(#set! reference.kind "field"))
|
||||
|
||||
; Scopes
|
||||
|
||||
[
|
||||
(program)
|
||||
(block)
|
||||
|
|
@ -16,53 +16,52 @@
|
|||
(if_expression)
|
||||
(match_expression)
|
||||
(match_arm)
|
||||
|
||||
(struct_item)
|
||||
(enum_item)
|
||||
(impl_item)
|
||||
] @local.scope
|
||||
|
||||
(use_declaration
|
||||
argument: (scoped_identifier
|
||||
name: (identifier) @local.definition.import))
|
||||
(use_declaration
|
||||
argument:
|
||||
(scoped_identifier
|
||||
name: (identifier) @local.definition.import))
|
||||
|
||||
(use_as_clause
|
||||
(use_as_clause
|
||||
alias: (identifier) @local.definition.import)
|
||||
|
||||
(use_list
|
||||
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
|
||||
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
|
||||
|
||||
; Functions
|
||||
|
||||
(function_definition
|
||||
(identifier) @local.definition.function)
|
||||
(identifier) @local.definition.function)
|
||||
|
||||
(function_definition
|
||||
(identifier) @local.definition.method
|
||||
(parameter (self)))
|
||||
(parameter
|
||||
(self)))
|
||||
|
||||
; Function with parameters, defines parameters
|
||||
|
||||
(parameter
|
||||
[ (identifier) (self) ] @local.definition.parameter)
|
||||
[
|
||||
(identifier)
|
||||
(self)
|
||||
] @local.definition.parameter)
|
||||
|
||||
; Types
|
||||
|
||||
(struct_item
|
||||
name: (type_identifier) @local.definition.type)
|
||||
|
||||
(constrained_type_parameter
|
||||
(constrained_type_parameter
|
||||
left: (type_identifier) @local.definition.type) ; the P in remove_file<P: AsRef<Path>>(path: P)
|
||||
|
||||
(enum_item
|
||||
name: (type_identifier) @local.definition.type)
|
||||
|
||||
; Module
|
||||
|
||||
(mod_item
|
||||
(mod_item
|
||||
name: (identifier) @local.definition.namespace)
|
||||
|
||||
; Variables
|
||||
|
||||
(assignment_expression
|
||||
left: (identifier) @local.definition.var)
|
||||
left: (identifier) @local.definition.var)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue