mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 10:50:06 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -1,13 +1,13 @@
|
|||
[
|
||||
(do_statement)
|
||||
(numeric_for_statement)
|
||||
(generic_for_statement)
|
||||
(while_statement)
|
||||
(repeat_statement)
|
||||
(if_statement)
|
||||
(function_statement)
|
||||
(record_declaration)
|
||||
(enum_declaration)
|
||||
(anon_function)
|
||||
(table_constructor)
|
||||
(do_statement)
|
||||
(numeric_for_statement)
|
||||
(generic_for_statement)
|
||||
(while_statement)
|
||||
(repeat_statement)
|
||||
(if_statement)
|
||||
(function_statement)
|
||||
(record_declaration)
|
||||
(enum_declaration)
|
||||
(anon_function)
|
||||
(table_constructor)
|
||||
] @fold
|
||||
|
|
|
|||
|
|
@ -1,91 +1,192 @@
|
|||
|
||||
;; Primitives
|
||||
; Primitives
|
||||
(boolean) @boolean
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-][-]"))
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
||||
|
||||
(shebang_comment) @keyword.directive
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "self"))
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
(number) @number
|
||||
|
||||
(string) @string
|
||||
(table_constructor ["{" "}"] @constructor)
|
||||
(varargs "..." @constant.builtin)
|
||||
[ "," "." ":" ";" ] @punctuation.delimiter
|
||||
|
||||
(table_constructor
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @constructor)
|
||||
|
||||
(varargs
|
||||
"..." @constant.builtin)
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(format_specifier) @string.escape
|
||||
|
||||
;; Basic statements/Keywords
|
||||
[ "if" "then" "elseif" "else" ] @keyword.conditional
|
||||
[ "for" "while" "repeat" "until" ] @keyword.repeat
|
||||
; Basic statements/Keywords
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"elseif"
|
||||
"else"
|
||||
] @keyword.conditional
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
"repeat"
|
||||
"until"
|
||||
] @keyword.repeat
|
||||
|
||||
"return" @keyword.return
|
||||
[ "in" "local" (break) (goto) "do" "end" ] @keyword
|
||||
|
||||
[
|
||||
"in"
|
||||
"local"
|
||||
(break)
|
||||
(goto)
|
||||
"do"
|
||||
"end"
|
||||
] @keyword
|
||||
|
||||
(label) @label
|
||||
|
||||
;; Global isn't a real keyword, but it gets special treatment in these places
|
||||
(var_declaration "global" @keyword)
|
||||
(type_declaration "global" @keyword)
|
||||
(function_statement "global" @keyword)
|
||||
(record_declaration "global" @keyword)
|
||||
(enum_declaration "global" @keyword)
|
||||
; Global isn't a real keyword, but it gets special treatment in these places
|
||||
(var_declaration
|
||||
"global" @keyword)
|
||||
|
||||
;; Ops
|
||||
(bin_op (op) @operator)
|
||||
(unary_op (op) @operator)
|
||||
[ "=" "as" ] @operator
|
||||
(type_declaration
|
||||
"global" @keyword)
|
||||
|
||||
;; Functions
|
||||
(function_statement
|
||||
"global" @keyword)
|
||||
|
||||
(record_declaration
|
||||
"global" @keyword)
|
||||
|
||||
(enum_declaration
|
||||
"global" @keyword)
|
||||
|
||||
; Ops
|
||||
(bin_op
|
||||
(op) @operator)
|
||||
|
||||
(unary_op
|
||||
(op) @operator)
|
||||
|
||||
[
|
||||
"="
|
||||
"as"
|
||||
] @operator
|
||||
|
||||
; Functions
|
||||
(function_statement
|
||||
"function" @keyword.function
|
||||
. name: (_) @function)
|
||||
.
|
||||
name: (_) @function)
|
||||
|
||||
(anon_function
|
||||
"function" @keyword.function)
|
||||
(function_body "end" @keyword.function)
|
||||
|
||||
(arg name: (identifier) @variable.parameter)
|
||||
(function_body
|
||||
"end" @keyword.function)
|
||||
|
||||
(arg
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
(function_signature
|
||||
(arguments
|
||||
. (arg name: (identifier) @variable.builtin))
|
||||
.
|
||||
(arg
|
||||
name: (identifier) @variable.builtin))
|
||||
(#eq? @variable.builtin "self"))
|
||||
|
||||
(typeargs
|
||||
"<" @punctuation.bracket
|
||||
. (_) @variable.parameter
|
||||
. ("," . (_) @variable.parameter)*
|
||||
. ">" @punctuation.bracket)
|
||||
.
|
||||
(_) @variable.parameter
|
||||
.
|
||||
(","
|
||||
.
|
||||
(_) @variable.parameter)*
|
||||
.
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(function_call
|
||||
(identifier) @function . (arguments))
|
||||
(function_call
|
||||
(index (_) key: (identifier) @function) . (arguments))
|
||||
(function_call
|
||||
(method_index (_) key: (identifier) @function) . (arguments))
|
||||
(identifier) @function
|
||||
.
|
||||
(arguments))
|
||||
|
||||
;; Types
|
||||
(function_call
|
||||
(index
|
||||
(_)
|
||||
key: (identifier) @function)
|
||||
.
|
||||
(arguments))
|
||||
|
||||
(function_call
|
||||
(method_index
|
||||
(_)
|
||||
key: (identifier) @function)
|
||||
.
|
||||
(arguments))
|
||||
|
||||
; Types
|
||||
(record_declaration
|
||||
. "record" @keyword
|
||||
.
|
||||
"record" @keyword
|
||||
name: (identifier) @type)
|
||||
(anon_record . "record" @keyword)
|
||||
|
||||
(anon_record
|
||||
.
|
||||
"record" @keyword)
|
||||
|
||||
(record_body
|
||||
(record_declaration
|
||||
. [ "record" ] @keyword
|
||||
. name: (identifier) @type))
|
||||
.
|
||||
"record" @keyword
|
||||
.
|
||||
name: (identifier) @type))
|
||||
|
||||
(record_body
|
||||
(enum_declaration
|
||||
. [ "enum" ] @keyword
|
||||
. name: (identifier) @type))
|
||||
.
|
||||
"enum" @keyword
|
||||
.
|
||||
name: (identifier) @type))
|
||||
|
||||
(record_body
|
||||
(typedef
|
||||
. "type" @keyword
|
||||
. name: (identifier) @type . "="))
|
||||
.
|
||||
"type" @keyword
|
||||
.
|
||||
name: (identifier) @type
|
||||
.
|
||||
"="))
|
||||
|
||||
(record_body
|
||||
(metamethod "metamethod" @keyword))
|
||||
(metamethod
|
||||
"metamethod" @keyword))
|
||||
|
||||
(record_body
|
||||
(userdata) @keyword)
|
||||
|
||||
|
|
@ -93,27 +194,52 @@
|
|||
"enum" @keyword
|
||||
name: (identifier) @type)
|
||||
|
||||
(type_declaration "type" @keyword)
|
||||
(type_declaration (identifier) @type)
|
||||
(simple_type name: (identifier) @type)
|
||||
(type_index (identifier) @type)
|
||||
(type_union "|" @operator)
|
||||
(function_type "function" @type)
|
||||
(type_declaration
|
||||
"type" @keyword)
|
||||
|
||||
;; The rest of it
|
||||
(var_declaration
|
||||
declarators: (var_declarators
|
||||
(var name: (identifier) @variable)))
|
||||
(var_declaration
|
||||
declarators: (var_declarators
|
||||
(var
|
||||
"<" @punctuation.bracket
|
||||
. attribute: (attribute) @attribute
|
||||
. ">" @punctuation.bracket)))
|
||||
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
|
||||
(type_declaration
|
||||
(identifier) @type)
|
||||
|
||||
;; Only highlight format specifiers in calls to string.format
|
||||
;; string.format('...')
|
||||
(simple_type
|
||||
name: (identifier) @type)
|
||||
|
||||
(type_index
|
||||
(identifier) @type)
|
||||
|
||||
(type_union
|
||||
"|" @operator)
|
||||
|
||||
(function_type
|
||||
"function" @type)
|
||||
|
||||
; The rest of it
|
||||
(var_declaration
|
||||
declarators:
|
||||
(var_declarators
|
||||
(var
|
||||
name: (identifier) @variable)))
|
||||
|
||||
(var_declaration
|
||||
declarators:
|
||||
(var_declarators
|
||||
(var
|
||||
"<" @punctuation.bracket
|
||||
.
|
||||
attribute: (attribute) @attribute
|
||||
.
|
||||
">" @punctuation.bracket)))
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Only highlight format specifiers in calls to string.format
|
||||
; string.format('...')
|
||||
;(function_call
|
||||
; called_object: (index
|
||||
; (identifier) @base
|
||||
|
|
@ -123,8 +249,7 @@
|
|||
;
|
||||
; (#eq? @base "string")
|
||||
; (#eq? @entry "format"))
|
||||
|
||||
;; ('...'):format()
|
||||
; ('...'):format()
|
||||
;(function_call
|
||||
; called_object: (method_index
|
||||
; (string (format_specifier) @string.escape)
|
||||
|
|
|
|||
|
|
@ -1,47 +1,42 @@
|
|||
(
|
||||
(function_call
|
||||
(index
|
||||
(identifier) @_cdef_identifier)
|
||||
(arguments
|
||||
(string) @injection.content)
|
||||
)
|
||||
|
||||
((function_call
|
||||
(index
|
||||
(identifier) @_cdef_identifier)
|
||||
(arguments
|
||||
(string) @injection.content))
|
||||
(#eq? @_cdef_identifier "cdef")
|
||||
(#lua-match? @injection.content "^[\"']")
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "c")
|
||||
)
|
||||
|
||||
(
|
||||
(function_call
|
||||
(index
|
||||
(identifier) @_cdef_identifier)
|
||||
(arguments
|
||||
(string) @injection.content)
|
||||
)
|
||||
(#set! injection.language "c"))
|
||||
|
||||
((function_call
|
||||
(index
|
||||
(identifier) @_cdef_identifier)
|
||||
(arguments
|
||||
(string) @injection.content))
|
||||
(#eq? @_cdef_identifier "cdef")
|
||||
(#lua-match? @injection.content "^%[%[")
|
||||
(#offset! @injection.content 0 2 0 -2)
|
||||
(#set! injection.language "c")
|
||||
)
|
||||
(#set! injection.language "c"))
|
||||
|
||||
; string.format('...')
|
||||
((function_call
|
||||
(index
|
||||
(identifier) @_base
|
||||
key: (identifier) @_entry)
|
||||
(arguments . (string) @injection.content))
|
||||
(#eq? @_base "string")
|
||||
(#eq? @_entry "format")
|
||||
(#set! injection.language "printf"))
|
||||
(arguments
|
||||
.
|
||||
(string) @injection.content))
|
||||
(#eq? @_base "string")
|
||||
(#eq? @_entry "format")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
; ('...'):format()
|
||||
((function_call
|
||||
(method_index (string) @printf
|
||||
(method_index
|
||||
(string) @printf
|
||||
key: (identifier) @_func))
|
||||
(#eq? @_func "format")
|
||||
(#set! injection.language "printf"))
|
||||
(#eq? @_func "format")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
(#set! injection.language "comment"))
|
||||
|
|
|
|||
|
|
@ -1,23 +1,38 @@
|
|||
(var_declaration
|
||||
declarators: (var_declarators
|
||||
(var (identifier)) @local.definition.var))
|
||||
declarators:
|
||||
(var_declarators
|
||||
(var
|
||||
(identifier)) @local.definition.var))
|
||||
|
||||
(var_assignment
|
||||
variables: (assignment_variables
|
||||
(var (identifier) @local.definition.var) @local.definition.associated))
|
||||
variables:
|
||||
(assignment_variables
|
||||
(var
|
||||
(identifier) @local.definition.var) @local.definition.associated))
|
||||
|
||||
(arg name: (identifier) @local.definition.parameter)
|
||||
(arg
|
||||
name: (identifier) @local.definition.parameter)
|
||||
|
||||
(anon_function) @local.scope
|
||||
|
||||
((function_statement
|
||||
(function_name) @local.definition.function) @local.scope)
|
||||
|
||||
(program) @local.scope
|
||||
|
||||
(if_statement) @local.scope
|
||||
(generic_for_statement (for_body) @local.scope)
|
||||
(numeric_for_statement (for_body) @local.scope)
|
||||
|
||||
(generic_for_statement
|
||||
(for_body) @local.scope)
|
||||
|
||||
(numeric_for_statement
|
||||
(for_body) @local.scope)
|
||||
|
||||
(repeat_statement) @local.scope
|
||||
(while_statement (while_body) @local.scope)
|
||||
|
||||
(while_statement
|
||||
(while_body) @local.scope)
|
||||
|
||||
(do_statement) @local.scope
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue