mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
chore(queries): use inherited queries for ts/js
This commit is contained in:
@@ -1,192 +1,4 @@
|
||||
; Types
|
||||
|
||||
; Javascript
|
||||
; Special identifiers
|
||||
;--------------------
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
|
||||
|
||||
((shorthand_property_identifier) @constant
|
||||
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
|
||||
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(arguments|module|console|window|document)$"))
|
||||
|
||||
((identifier) @function.builtin
|
||||
(#eq? @function.builtin "require"))
|
||||
|
||||
; Function and method definitions
|
||||
;--------------------------------
|
||||
|
||||
(function
|
||||
name: (identifier) @function)
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
(method_definition
|
||||
name: (property_identifier) @function.method)
|
||||
|
||||
(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)
|
||||
right: (arrow_function))
|
||||
(assignment_expression
|
||||
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))
|
||||
|
||||
(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_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @function.method))
|
||||
|
||||
; Variables
|
||||
;----------
|
||||
|
||||
(formal_parameters (identifier) @variable.parameter)
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Properties
|
||||
;-----------
|
||||
|
||||
(property_identifier) @property
|
||||
|
||||
; Literals
|
||||
;---------
|
||||
|
||||
(this) @variable.builtin
|
||||
(super) @variable.builtin
|
||||
|
||||
(true) @constant.builtin
|
||||
(false) @constant.builtin
|
||||
(null) @constant.builtin
|
||||
(comment) @comment
|
||||
(string) @string
|
||||
(regex) @string.special
|
||||
(template_string) @string
|
||||
(number) @number
|
||||
|
||||
; Punctuation
|
||||
;------------
|
||||
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
";" @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
|
||||
"--" @operator
|
||||
"-" @operator
|
||||
"-=" @operator
|
||||
"&&" @operator
|
||||
"+" @operator
|
||||
"++" @operator
|
||||
"+=" @operator
|
||||
"<" @operator
|
||||
"<<" @operator
|
||||
"=" @operator
|
||||
"==" @operator
|
||||
"===" @operator
|
||||
"=>" @operator
|
||||
">" @operator
|
||||
">>" @operator
|
||||
"||" @operator
|
||||
"??" @operator
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
|
||||
; Keywords
|
||||
;----------
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"import"
|
||||
"from"
|
||||
"as"
|
||||
] @include
|
||||
|
||||
[
|
||||
"for"
|
||||
"of"
|
||||
"do"
|
||||
"while"
|
||||
"continue"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
"async"
|
||||
"await"
|
||||
"break"
|
||||
"catch"
|
||||
"class"
|
||||
"const"
|
||||
"debugger"
|
||||
"delete"
|
||||
"export"
|
||||
"extends"
|
||||
"finally"
|
||||
"function"
|
||||
"get"
|
||||
"in"
|
||||
"instanceof"
|
||||
"let"
|
||||
"new"
|
||||
"return"
|
||||
"set"
|
||||
"static"
|
||||
"switch"
|
||||
"target"
|
||||
"throw"
|
||||
"try"
|
||||
"typeof"
|
||||
"var"
|
||||
"void"
|
||||
"with"
|
||||
"yield"
|
||||
"abstract"
|
||||
"declare"
|
||||
"enum"
|
||||
|
||||
@@ -1,37 +1,2 @@
|
||||
; Scopes
|
||||
;-------
|
||||
|
||||
(statement_block) @scope
|
||||
(function) @scope
|
||||
(arrow_function) @scope
|
||||
(function_declaration) @scope
|
||||
(method_definition) @scope
|
||||
|
||||
; Definitions
|
||||
;------------
|
||||
|
||||
(formal_parameters
|
||||
(identifier) @definition)
|
||||
|
||||
(formal_parameters
|
||||
(object_pattern
|
||||
(identifier) @definition))
|
||||
|
||||
(formal_parameters
|
||||
(object_pattern
|
||||
(shorthand_property_identifier) @definition))
|
||||
|
||||
(formal_parameters
|
||||
(array_pattern
|
||||
(identifier) @definition))
|
||||
|
||||
(variable_declarator
|
||||
name: (identifier) @definition)
|
||||
|
||||
; References
|
||||
;------------
|
||||
|
||||
(identifier) @reference
|
||||
|
||||
(required_parameter (identifier) @definition)
|
||||
(optional_parameter (identifier) @definition)
|
||||
|
||||
Reference in New Issue
Block a user