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
|
|
@ -4,11 +4,9 @@
|
|||
(let_section)
|
||||
(type_section)
|
||||
(using_section)
|
||||
|
||||
(object_declaration)
|
||||
(tuple_type)
|
||||
(enum_declaration)
|
||||
|
||||
(case)
|
||||
(if)
|
||||
(when)
|
||||
|
|
@ -17,22 +15,18 @@
|
|||
(of_branch)
|
||||
(elif_branch)
|
||||
(else_branch)
|
||||
|
||||
(for)
|
||||
(while)
|
||||
(block)
|
||||
(static_statement)
|
||||
(pragma_statement)
|
||||
|
||||
(try)
|
||||
(except_branch)
|
||||
(finally_branch)
|
||||
|
||||
(do_block)
|
||||
(call
|
||||
(argument_list
|
||||
(statement_list)))
|
||||
|
||||
(proc_declaration)
|
||||
(func_declaration)
|
||||
(method_declaration)
|
||||
|
|
@ -40,10 +34,8 @@
|
|||
(converter_declaration)
|
||||
(template_declaration)
|
||||
(macro_declaration)
|
||||
|
||||
(proc_expression)
|
||||
(func_expression)
|
||||
(iterator_expression)
|
||||
|
||||
(concept_declaration)
|
||||
] @fold
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,24 +1,27 @@
|
|||
; =============================================================================
|
||||
; generalized_strings
|
||||
|
||||
; regex in generalized_strings
|
||||
(generalized_string
|
||||
function: (identifier) @_string_prefix .
|
||||
function: (identifier) @_string_prefix
|
||||
.
|
||||
(string_content) @injection.content
|
||||
(#set! injection.language "regex")
|
||||
(#any-of? @_string_prefix "re" "rex"))
|
||||
|
||||
; format string in generalized_strings
|
||||
(generalized_string
|
||||
function: (identifier) @_string_prefix .
|
||||
function: (identifier) @_string_prefix
|
||||
.
|
||||
(string_content) @injection.content
|
||||
(#set! injection.language "nim_format_string")
|
||||
(#eq? @_string_prefix "fmt"))
|
||||
|
||||
; format string in normal strings with & prefix
|
||||
(prefix_expression
|
||||
operator: (operator) @_string_prefix .
|
||||
(_ (string_content) @injection.content)
|
||||
operator: (operator) @_string_prefix
|
||||
.
|
||||
(_
|
||||
(string_content) @injection.content)
|
||||
(#set! injection.language "nim_format_string")
|
||||
(#eq? @_string_prefix "&"))
|
||||
|
||||
|
|
@ -31,45 +34,47 @@
|
|||
|
||||
; =============================================================================
|
||||
; emit pragma
|
||||
|
||||
; C / CPP / OBJC / JAVASCRIPT
|
||||
; a `#<no whitespace><language name>`
|
||||
; has to directly precede the {.emit: "<language code>".} pragma
|
||||
|
||||
; eg.:
|
||||
; #objc
|
||||
; {.emit: "<objc code>".}
|
||||
; OR
|
||||
; #javascript
|
||||
; {.emit: "<javascript code>".}
|
||||
|
||||
; normal strings
|
||||
((comment (comment_content) @injection.language)
|
||||
((comment
|
||||
(comment_content) @injection.language)
|
||||
.
|
||||
(pragma_statement
|
||||
(pragma_list
|
||||
(colon_expression
|
||||
left: (identifier) @_emit_keyword (#eq? @_emit_keyword "emit")
|
||||
right: (_ (string_content) @injection.content)))))
|
||||
|
||||
left: (identifier) @_emit_keyword
|
||||
(#eq? @_emit_keyword "emit")
|
||||
right:
|
||||
(_
|
||||
(string_content) @injection.content)))))
|
||||
|
||||
; =============================================================================
|
||||
; asm statement
|
||||
|
||||
; works same as emit pragma, needs preceding comment with language name
|
||||
((comment (comment_content) @injection.language)
|
||||
((comment
|
||||
(comment_content) @injection.language)
|
||||
.
|
||||
(assembly_statement (_ (string_content) @injection.content)))
|
||||
(assembly_statement
|
||||
(_
|
||||
(string_content) @injection.content)))
|
||||
|
||||
; =============================================================================
|
||||
; comments
|
||||
|
||||
; NOTE: ts "comment" parser heavily impacts performance
|
||||
|
||||
; markdown parser in documentation_comment
|
||||
(documentation_comment (comment_content) @injection.content
|
||||
(documentation_comment
|
||||
(comment_content) @injection.content
|
||||
(#set! injection.language "markdown_inline"))
|
||||
|
||||
; markdown parser in block_documentation_comment
|
||||
(block_documentation_comment (comment_content) @injection.content
|
||||
(block_documentation_comment
|
||||
(comment_content) @injection.content
|
||||
(#set! injection.language "markdown"))
|
||||
|
|
|
|||
|
|
@ -1,198 +1,243 @@
|
|||
|
||||
; ==============================================================================
|
||||
; @local.definition ; various definitions
|
||||
|
||||
(block
|
||||
label: [
|
||||
(identifier) @local.definition
|
||||
(accent_quoted) @local.definition
|
||||
])
|
||||
label:
|
||||
[
|
||||
(identifier) @local.definition
|
||||
(accent_quoted) @local.definition
|
||||
])
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.constant ; constants
|
||||
|
||||
(const_section
|
||||
(variable_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.constant
|
||||
(accent_quoted) @local.definition.constant
|
||||
(exported_symbol (identifier) @local.definition.constant)
|
||||
(exported_symbol (accent_quoted) @local.definition.constant)
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.constant
|
||||
(accent_quoted) @local.definition.constant
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.constant)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.constant)
|
||||
]))
|
||||
type: (type_expression)? @local.definition.associated))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.function ; functions
|
||||
|
||||
(proc_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol (identifier) @local.definition.function)
|
||||
(exported_symbol (accent_quoted) @local.definition.function)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.function)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.function)
|
||||
]
|
||||
(#set! "definition.function.scope" "parent"))
|
||||
|
||||
(func_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol (identifier) @local.definition.function)
|
||||
(exported_symbol (accent_quoted) @local.definition.function)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.function)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.function)
|
||||
]
|
||||
(#set! "definition.function.scope" "parent"))
|
||||
|
||||
(iterator_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol (identifier) @local.definition.function)
|
||||
(exported_symbol (accent_quoted) @local.definition.function)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.function)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.function)
|
||||
]
|
||||
(#set! "definition.function.scope" "parent"))
|
||||
|
||||
(converter_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol (identifier) @local.definition.function)
|
||||
(exported_symbol (accent_quoted) @local.definition.function)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.function
|
||||
(accent_quoted) @local.definition.function
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.function)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.function)
|
||||
]
|
||||
(#set! "definition.function.scope" "parent"))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.method ; methods
|
||||
|
||||
(method_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.method
|
||||
(accent_quoted) @local.definition.method
|
||||
(exported_symbol (identifier) @local.definition.method)
|
||||
(exported_symbol (accent_quoted) @local.definition.method)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.method
|
||||
(accent_quoted) @local.definition.method
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.method)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.method)
|
||||
]
|
||||
(#set! "definition.method.scope" "parent"))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.var ; variables
|
||||
|
||||
(var_section
|
||||
(variable_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
(exported_symbol (identifier) @local.definition.var)
|
||||
(exported_symbol (accent_quoted) @local.definition.var)
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.var)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.var)
|
||||
]))
|
||||
type: (type_expression)? @local.definition.associated))
|
||||
|
||||
(let_section
|
||||
(variable_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
(exported_symbol (identifier) @local.definition.var)
|
||||
(exported_symbol (accent_quoted) @local.definition.var)
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.var)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.var)
|
||||
]))
|
||||
type: (type_expression)? @local.definition.associated))
|
||||
|
||||
(for
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
])))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
])))
|
||||
|
||||
(try
|
||||
(except_branch
|
||||
values: (expression_list
|
||||
(infix_expression
|
||||
right: [
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
]))))
|
||||
values:
|
||||
(expression_list
|
||||
(infix_expression
|
||||
right:
|
||||
[
|
||||
(identifier) @local.definition.var
|
||||
(accent_quoted) @local.definition.var
|
||||
]))))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.parameter ; parameters
|
||||
|
||||
(parameter_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted) @local.definition.parameter
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted) @local.definition.parameter
|
||||
]))
|
||||
type: (type_expression)? @local.definition.associated)
|
||||
|
||||
(concept_declaration
|
||||
parameters:
|
||||
(parameter_list [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
]))
|
||||
(var_parameter [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
])
|
||||
(type_parameter [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
])
|
||||
(static_parameter [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
])
|
||||
(ref_parameter [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
])
|
||||
(pointer_parameter [
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted (identifier) @local.definition.parameter)
|
||||
])
|
||||
(parameter_list
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
]))
|
||||
|
||||
(var_parameter
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
])
|
||||
|
||||
(type_parameter
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
])
|
||||
|
||||
(static_parameter
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
])
|
||||
|
||||
(ref_parameter
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
])
|
||||
|
||||
(pointer_parameter
|
||||
[
|
||||
(identifier) @local.definition.parameter
|
||||
(accent_quoted
|
||||
(identifier) @local.definition.parameter)
|
||||
])
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.macro ; preprocessor macros
|
||||
|
||||
(template_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.macro
|
||||
(accent_quoted) @local.definition.macro
|
||||
(exported_symbol (identifier) @local.definition.macro)
|
||||
(exported_symbol (accent_quoted) @local.definition.macro)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.macro
|
||||
(accent_quoted) @local.definition.macro
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.macro)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.macro)
|
||||
]
|
||||
(#set! "definition.macro.scope" "parent"))
|
||||
|
||||
(macro_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.macro
|
||||
(accent_quoted) @local.definition.macro
|
||||
(exported_symbol (identifier) @local.definition.macro)
|
||||
(exported_symbol (accent_quoted) @local.definition.macro)
|
||||
]
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.macro
|
||||
(accent_quoted) @local.definition.macro
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.macro)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.macro)
|
||||
]
|
||||
(#set! "definition.macro.scope" "parent"))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.type ; types or classes
|
||||
|
||||
(type_declaration
|
||||
(type_symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.type
|
||||
(accent_quoted) @local.definition.type
|
||||
(exported_symbol (identifier) @local.definition.type)
|
||||
(exported_symbol (accent_quoted) @local.definition.type)
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.type
|
||||
(accent_quoted) @local.definition.type
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.type)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.type)
|
||||
]))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.field ; fields or properties
|
||||
|
||||
; object_declaration
|
||||
; variant_declaration
|
||||
; conditional_declaration
|
||||
|
|
@ -201,29 +246,31 @@
|
|||
(field_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.field
|
||||
(accent_quoted) @local.definition.field
|
||||
(exported_symbol (identifier) @local.definition.field)
|
||||
(exported_symbol (accent_quoted) @local.definition.field)
|
||||
]))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.field
|
||||
(accent_quoted) @local.definition.field
|
||||
(exported_symbol
|
||||
(identifier) @local.definition.field)
|
||||
(exported_symbol
|
||||
(accent_quoted) @local.definition.field)
|
||||
]))
|
||||
type: (type_expression)? @local.definition.associated)
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.enum ; enumerations
|
||||
|
||||
(enum_declaration
|
||||
(enum_field_declaration
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @local.definition.enum
|
||||
(accent_quoted) @local.definition.enum
|
||||
])))
|
||||
name:
|
||||
[
|
||||
(identifier) @local.definition.enum
|
||||
(accent_quoted) @local.definition.enum
|
||||
])))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.definition.namespace ; modules or namespaces
|
||||
; @local.definition.import ; imported names
|
||||
|
||||
(import_statement
|
||||
(expression_list
|
||||
(identifier) @local.definition.namespace))
|
||||
|
|
@ -238,28 +285,30 @@
|
|||
(expression_list
|
||||
(infix_expression
|
||||
operator: (operator) @_operator
|
||||
right: [
|
||||
(identifier) @local.definition.namespace
|
||||
(array_construction (identifier) @local.definition.namespace)
|
||||
]))
|
||||
right:
|
||||
[
|
||||
(identifier) @local.definition.namespace
|
||||
(array_construction
|
||||
(identifier) @local.definition.namespace)
|
||||
]))
|
||||
(#eq? @_operator "/"))
|
||||
|
||||
(import_from_statement
|
||||
module: (infix_expression
|
||||
operator: (operator) @_operator
|
||||
right: (identifier) @local.definition.namespace)
|
||||
(expression_list [
|
||||
(identifier) @local.definition.import
|
||||
(accent_quoted) @local.definition.import
|
||||
])
|
||||
module:
|
||||
(infix_expression
|
||||
operator: (operator) @_operator
|
||||
right: (identifier) @local.definition.namespace)
|
||||
(expression_list
|
||||
[
|
||||
(identifier) @local.definition.import
|
||||
(accent_quoted) @local.definition.import
|
||||
])
|
||||
(#eq? @_operator "/"))
|
||||
|
||||
; ==============================================================================
|
||||
; @local.scope ; scope block
|
||||
|
||||
; (when)
|
||||
; NOTE: `when` does actually not create a scope
|
||||
|
||||
(if
|
||||
consequence: (statement_list) @local.scope
|
||||
alternative: (elif_branch)* @local.scope
|
||||
|
|
@ -280,7 +329,6 @@
|
|||
(while)
|
||||
(block)
|
||||
(static_statement)
|
||||
|
||||
(proc_declaration)
|
||||
(func_declaration)
|
||||
(method_declaration)
|
||||
|
|
@ -288,16 +336,14 @@
|
|||
(converter_declaration)
|
||||
(template_declaration)
|
||||
(macro_declaration)
|
||||
|
||||
(proc_expression)
|
||||
(func_expression)
|
||||
(iterator_expression)
|
||||
|
||||
(concept_declaration)
|
||||
] @local.scope
|
||||
|
||||
; ==============================================================================
|
||||
; @local.reference ; identifier reference
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
(accent_quoted) @local.reference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue