chore: query formatting

This commit is contained in:
Pham Huy Hoang 2024-01-06 15:05:50 +09:00 committed by Christian Clason
parent 79975d6557
commit 57a8acf0c4
674 changed files with 18466 additions and 12648 deletions

View file

@ -1,92 +1,60 @@
; Types
; Javascript
; Variables
;-----------
(identifier) @variable
; Properties
;-----------
(property_identifier) @property
(shorthand_property_identifier) @property
(private_property_identifier) @property
(variable_declarator
name: (object_pattern
(shorthand_property_identifier_pattern))) @variable
name:
(object_pattern
(shorthand_property_identifier_pattern))) @variable
; Special identifiers
;--------------------
((identifier) @type
(#lua-match? @type "^[A-Z]"))
(#lua-match? @type "^[A-Z]"))
((identifier) @constant
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
((shorthand_property_identifier) @constant
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
((identifier) @variable.builtin
(#any-of? @variable.builtin
"arguments"
"module"
"console"
"window"
"document"))
(#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
((identifier) @type.builtin
(#any-of? @type.builtin
"Object"
"Function"
"Boolean"
"Symbol"
"Number"
"Math"
"Date"
"String"
"RegExp"
"Map"
"Set"
"WeakMap"
"WeakSet"
"Promise"
"Array"
"Int8Array"
"Uint8Array"
"Uint8ClampedArray"
"Int16Array"
"Uint16Array"
"Int32Array"
"Uint32Array"
"Float32Array"
"Float64Array"
"ArrayBuffer"
"DataView"
"Error"
"EvalError"
"InternalError"
"RangeError"
"ReferenceError"
"SyntaxError"
"TypeError"
"URIError"))
(#any-of? @type.builtin "Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set" "WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array" "Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView" "Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError" "URIError"))
; Function and method definitions
;--------------------------------
(function
name: (identifier) @function)
(function_declaration
name: (identifier) @function)
(generator_function
name: (identifier) @function)
(generator_function_declaration
name: (identifier) @function)
(method_definition
name: [(property_identifier) (private_property_identifier)] @function.method)
name:
[
(property_identifier)
(private_property_identifier)
] @function.method)
(method_definition
name: (property_identifier) @constructor
(#eq? @constructor "constructor"))
@ -94,22 +62,27 @@
(pair
key: (property_identifier) @function.method
value: (function))
(pair
key: (property_identifier) @function.method
value: (arrow_function))
(assignment_expression
left: (member_expression
property: (property_identifier) @function.method)
left:
(member_expression
property: (property_identifier) @function.method)
right: (arrow_function))
(assignment_expression
left: (member_expression
property: (property_identifier) @function.method)
left:
(member_expression
property: (property_identifier) @function.method)
right: (function))
(variable_declarator
name: (identifier) @function
value: (arrow_function))
(variable_declarator
name: (identifier) @function
value: (function))
@ -117,42 +90,35 @@
(assignment_expression
left: (identifier) @function
right: (arrow_function))
(assignment_expression
left: (identifier) @function
right: (function))
; Function and method calls
;--------------------------
(call_expression
function: (identifier) @function.call)
(call_expression
function: (member_expression
property: [(property_identifier) (private_property_identifier)] @function.method.call))
function:
(member_expression
property:
[
(property_identifier)
(private_property_identifier)
] @function.method.call))
; Builtins
;---------
((identifier) @module.builtin
(#eq? @module.builtin "Intl"))
(#eq? @module.builtin "Intl"))
((identifier) @function.builtin
(#any-of? @function.builtin
"eval"
"isFinite"
"isNaN"
"parseFloat"
"parseInt"
"decodeURI"
"decodeURIComponent"
"encodeURI"
"encodeURIComponent"
"require"))
(#any-of? @function.builtin "eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI" "encodeURIComponent" "require"))
; Constructor
;------------
(new_expression
constructor: (identifier) @constructor)
@ -163,19 +129,24 @@
; Decorators
;----------
(decorator "@" @attribute (identifier) @attribute)
(decorator "@" @attribute (call_expression (identifier) @attribute))
(decorator
"@" @attribute
(identifier) @attribute)
(decorator
"@" @attribute
(call_expression
(identifier) @attribute))
; Literals
;---------
[
(this)
(super)
] @variable.builtin
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
(#eq? @variable.builtin "self"))
[
(true)
@ -195,30 +166,45 @@
(hash_bang_line) @keyword.directive
((string_fragment) @keyword.directive
(#eq? @keyword.directive "use strict"))
(#eq? @keyword.directive "use strict"))
(string) @string
(template_string) @string
(escape_sequence) @string.escape
(regex_pattern) @string.regexp
(regex_flags) @character.special
(regex "/" @punctuation.bracket) ; Regex delimiters
(regex
"/" @punctuation.bracket) ; Regex delimiters
(number) @number
((identifier) @number
(#any-of? @number "NaN" "Infinity"))
; Punctuation
;------------
";" @punctuation.delimiter
"." @punctuation.delimiter
"," @punctuation.delimiter
(pair ":" @punctuation.delimiter)
(pair_pattern ":" @punctuation.delimiter)
(switch_case ":" @punctuation.delimiter)
(switch_default ":" @punctuation.delimiter)
(pair
":" @punctuation.delimiter)
(pair_pattern
":" @punctuation.delimiter)
(switch_case
":" @punctuation.delimiter)
(switch_default
":" @punctuation.delimiter)
[
"--"
@ -265,10 +251,28 @@
"..."
] @operator
(binary_expression "/" @operator)
(ternary_expression ["?" ":"] @keyword.conditional.ternary)
(unary_expression ["!" "~" "-" "+"] @operator)
(unary_expression ["delete" "void"] @keyword.operator)
(binary_expression
"/" @operator)
(ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(unary_expression
[
"!"
"~"
"-"
"+"
] @operator)
(unary_expression
[
"delete"
"void"
] @keyword.operator)
[
"("
@ -279,11 +283,14 @@
"}"
] @punctuation.bracket
((template_substitution ["${" "}"] @punctuation.special) @none)
((template_substitution
[
"${"
"}"
] @punctuation.special) @none)
; Keywords
;----------
[
"if"
"else"
@ -296,10 +303,17 @@
"from"
] @keyword.import
(export_specifier "as" @keyword.import)
(import_specifier "as" @keyword.import)
(namespace_export "as" @keyword.import)
(namespace_import "as" @keyword.import)
(export_specifier
"as" @keyword.import)
(import_specifier
"as" @keyword.import)
(namespace_export
"as" @keyword.import)
(namespace_import
"as" @keyword.import)
[
"for"
@ -335,9 +349,7 @@
"yield"
] @keyword.return
[
"function"
] @keyword.function
"function" @keyword.function
[
"new"
@ -356,5 +368,6 @@
(export_statement
"default" @keyword)
(switch_default
"default" @keyword.conditional)