mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 17:30:08 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -1,12 +1,10 @@
|
|||
[
|
||||
(imports)
|
||||
|
||||
(function_declaration)
|
||||
(enum_type)
|
||||
(struct_type)
|
||||
(tuple_type)
|
||||
(union_type)
|
||||
|
||||
(block)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
|
|
@ -14,7 +12,6 @@
|
|||
(switch_expression)
|
||||
(match_expression)
|
||||
(case)
|
||||
|
||||
(array_literal)
|
||||
(struct_literal)
|
||||
(tuple_literal)
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Types
|
||||
|
||||
(type) @type
|
||||
|
||||
(scoped_type_identifier
|
||||
(identifier) . (identifier) @type)
|
||||
(identifier)
|
||||
.
|
||||
(identifier) @type)
|
||||
|
||||
(struct_literal
|
||||
. (identifier) @type)
|
||||
.
|
||||
(identifier) @type)
|
||||
|
||||
(builtin_type) @type.builtin
|
||||
|
||||
; Constants
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z_]+$"))
|
||||
|
||||
; Includes
|
||||
|
||||
[
|
||||
"use"
|
||||
] @keyword.import
|
||||
"use" @keyword.import
|
||||
|
||||
(use_statement
|
||||
(scoped_type_identifier
|
||||
(identifier) @module))
|
||||
|
||||
(use_statement
|
||||
(identifier) @module "{")
|
||||
(identifier) @module
|
||||
"{")
|
||||
|
||||
(use_statement
|
||||
. (identifier) @module .)
|
||||
.
|
||||
(identifier) @module .)
|
||||
|
||||
((scoped_type_identifier
|
||||
path: (_) @module)
|
||||
(#set! "priority" 105))
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"def"
|
||||
"enum"
|
||||
|
|
@ -49,9 +49,7 @@
|
|||
"union"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"fn"
|
||||
] @keyword.function
|
||||
"fn" @keyword.function
|
||||
|
||||
[
|
||||
"defer"
|
||||
|
|
@ -65,12 +63,13 @@
|
|||
] @keyword.operator
|
||||
|
||||
; Typedefs
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @type.definition . "=")
|
||||
"type"
|
||||
(identifier) @type.definition
|
||||
.
|
||||
"=")
|
||||
|
||||
; Qualifiers
|
||||
|
||||
[
|
||||
"const"
|
||||
"static"
|
||||
|
|
@ -78,7 +77,6 @@
|
|||
] @type.qualifier
|
||||
|
||||
; Attributes
|
||||
|
||||
[
|
||||
"@fini"
|
||||
"@init"
|
||||
|
|
@ -89,62 +87,72 @@
|
|||
] @attribute
|
||||
|
||||
; Labels
|
||||
|
||||
((label) @label
|
||||
(#set! "priority" 105))
|
||||
|
||||
; Functions
|
||||
|
||||
(function_declaration
|
||||
"fn" . (identifier) @function)
|
||||
"fn"
|
||||
.
|
||||
(identifier) @function)
|
||||
|
||||
(call_expression
|
||||
. (identifier) @function.call)
|
||||
.
|
||||
(identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
. (scoped_type_identifier
|
||||
. (identifier) . "::" . (identifier) @function.method.call))
|
||||
.
|
||||
(scoped_type_identifier
|
||||
.
|
||||
(identifier)
|
||||
.
|
||||
"::"
|
||||
.
|
||||
(identifier) @function.method.call))
|
||||
|
||||
((call_expression
|
||||
. (identifier) @function.builtin)
|
||||
.
|
||||
(identifier) @function.builtin)
|
||||
(#any-of? @function.builtin "align" "assert" "free" "len" "offset" "size"))
|
||||
|
||||
(size_expression
|
||||
"size" @function.builtin)
|
||||
|
||||
((function_declaration
|
||||
"fn" . (identifier) @constructor)
|
||||
"fn"
|
||||
.
|
||||
(identifier) @constructor)
|
||||
(#eq? @constructor "init"))
|
||||
|
||||
((call_expression
|
||||
. (identifier) @constructor)
|
||||
.
|
||||
(identifier) @constructor)
|
||||
(#eq? @constructor "init"))
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter
|
||||
(_) @variable.parameter . ":")
|
||||
(_) @variable.parameter
|
||||
.
|
||||
":")
|
||||
|
||||
; Fields
|
||||
|
||||
((member_expression
|
||||
"." (_) @variable.member)
|
||||
"."
|
||||
(_) @variable.member)
|
||||
(#set! "priority" 105))
|
||||
|
||||
(field
|
||||
. (identifier) @variable.member)
|
||||
.
|
||||
(identifier) @variable.member)
|
||||
|
||||
(field_assignment
|
||||
. (identifier) @variable.member)
|
||||
.
|
||||
(identifier) @variable.member)
|
||||
|
||||
; Repeats
|
||||
|
||||
[
|
||||
"for"
|
||||
] @keyword.repeat
|
||||
"for" @keyword.repeat
|
||||
|
||||
; Conditionals
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
|
|
@ -155,7 +163,6 @@
|
|||
] @keyword.conditional
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
|
|
@ -196,12 +203,20 @@
|
|||
] @operator
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[ "{" "}" ] @punctuation.bracket
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[ "[" "]" ] @punctuation.bracket
|
||||
|
||||
[ "(" ")" ] @punctuation.bracket
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
".."
|
||||
|
|
@ -209,11 +224,14 @@
|
|||
"_"
|
||||
] @punctuation.special
|
||||
|
||||
(pointer_type "*" @punctuation.special)
|
||||
(pointer_type
|
||||
"*" @punctuation.special)
|
||||
|
||||
(slice_type "*" @punctuation.special)
|
||||
(slice_type
|
||||
"*" @punctuation.special)
|
||||
|
||||
(error_type "!" @punctuation.special)
|
||||
(error_type
|
||||
"!" @punctuation.special)
|
||||
|
||||
[
|
||||
","
|
||||
|
|
@ -225,7 +243,6 @@
|
|||
] @punctuation.delimiter
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(string)
|
||||
(raw_string)
|
||||
|
|
@ -247,5 +264,4 @@
|
|||
] @constant.builtin
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
|
|
|||
|
|
@ -3,19 +3,18 @@
|
|||
(struct_type)
|
||||
(tuple_type)
|
||||
(union_type)
|
||||
|
||||
(block)
|
||||
(for_statement)
|
||||
(call_expression)
|
||||
(case)
|
||||
|
||||
(array_literal)
|
||||
(struct_literal)
|
||||
(tuple_literal)
|
||||
] @indent.begin
|
||||
|
||||
(if_statement
|
||||
("(" condition: (_) ")") @indent.begin)
|
||||
("("
|
||||
condition: (_)")") @indent.begin)
|
||||
|
||||
[
|
||||
"}"
|
||||
|
|
@ -23,11 +22,20 @@
|
|||
")"
|
||||
] @indent.end
|
||||
|
||||
[ "{" "}" ] @indent.branch
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @indent.branch
|
||||
|
||||
[ "[" "]" ] @indent.branch
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @indent.branch
|
||||
|
||||
[ "(" ")" ] @indent.branch
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @indent.branch
|
||||
|
||||
[
|
||||
(ERROR)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((call_expression
|
||||
. (_) @_fnname
|
||||
. "("
|
||||
. (_ [(string_content) (raw_string_content)] @injection.content)
|
||||
. ")")
|
||||
.
|
||||
(_) @_fnname
|
||||
.
|
||||
"("
|
||||
.
|
||||
(_
|
||||
[
|
||||
(string_content)
|
||||
(raw_string_content)
|
||||
] @injection.content)
|
||||
.
|
||||
")")
|
||||
(#any-of? @_fnname "compile" "regex::compile")
|
||||
(#set! injection.language "regex"))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
; Scopes
|
||||
|
||||
[
|
||||
(module)
|
||||
(function_declaration)
|
||||
|
|
@ -10,38 +9,57 @@
|
|||
] @local.scope
|
||||
|
||||
; References
|
||||
|
||||
[
|
||||
(identifier)
|
||||
(scoped_type_identifier)
|
||||
] @local.reference
|
||||
|
||||
; Definitions
|
||||
|
||||
(global_binding
|
||||
(identifier) @local.definition.constant . ":" (_))
|
||||
(identifier) @local.definition.constant
|
||||
.
|
||||
":"
|
||||
(_))
|
||||
|
||||
(const_declaration
|
||||
"const" (identifier) @local.definition.constant . "=")
|
||||
"const"
|
||||
(identifier) @local.definition.constant
|
||||
.
|
||||
"=")
|
||||
|
||||
(field
|
||||
. (identifier) @local.definition.field)
|
||||
.
|
||||
(identifier) @local.definition.field)
|
||||
|
||||
(field_assignment
|
||||
. (identifier) @local.definition.field)
|
||||
.
|
||||
(identifier) @local.definition.field)
|
||||
|
||||
(function_declaration
|
||||
"fn" . (identifier) @local.definition.function)
|
||||
"fn"
|
||||
.
|
||||
(identifier) @local.definition.function)
|
||||
|
||||
(parameter
|
||||
(_) @local.definition.parameter . ":")
|
||||
(_) @local.definition.parameter
|
||||
.
|
||||
":")
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @local.definition.type . "=")
|
||||
"type"
|
||||
(identifier) @local.definition.type
|
||||
.
|
||||
"=")
|
||||
|
||||
(type_declaration
|
||||
"type" (identifier) @local.definition.enum . "=" (enum_type))
|
||||
"type"
|
||||
(identifier) @local.definition.enum
|
||||
.
|
||||
"="
|
||||
(enum_type))
|
||||
|
||||
(let_declaration
|
||||
"let" . (identifier) @local.definition.variable ","?)
|
||||
|
||||
"let"
|
||||
.
|
||||
(identifier) @local.definition.variable
|
||||
","?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue