mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 02:40:09 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -3,15 +3,12 @@
|
|||
(struct_definition)
|
||||
(macro_definition)
|
||||
(function_definition)
|
||||
|
||||
(if_statement)
|
||||
(try_statement)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(let_statement)
|
||||
(quote_statement)
|
||||
|
||||
(do_clause)
|
||||
(compound_statement)
|
||||
] @fold
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
;;; Identifiers
|
||||
|
||||
; Identifiers
|
||||
(identifier) @variable
|
||||
|
||||
; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
|
||||
; ((identifier) @type
|
||||
; (match? @type "^[A-Z][^_]")) ; exception: Highlight `A_foo` sort of identifiers as variables
|
||||
|
||||
(macro_identifier) @function.macro
|
||||
|
||||
(macro_identifier
|
||||
(identifier) @function.macro) ; for any one using the variable highlight
|
||||
|
||||
|
|
@ -15,37 +14,46 @@
|
|||
|
||||
(quote_expression
|
||||
":" @string.special.symbol
|
||||
[(identifier) (operator)] @string.special.symbol)
|
||||
[
|
||||
(identifier)
|
||||
(operator)
|
||||
] @string.special.symbol)
|
||||
|
||||
(field_expression
|
||||
(identifier) @variable.member .)
|
||||
|
||||
|
||||
;;; Function names
|
||||
|
||||
;; Definitions
|
||||
|
||||
; Function names
|
||||
; Definitions
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(short_function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_definition
|
||||
name: (field_expression (identifier) @function .))
|
||||
name:
|
||||
(field_expression
|
||||
(identifier) @function .))
|
||||
|
||||
(short_function_definition
|
||||
name: (field_expression (identifier) @function .))
|
||||
|
||||
;; calls
|
||||
name:
|
||||
(field_expression
|
||||
(identifier) @function .))
|
||||
|
||||
; calls
|
||||
(call_expression
|
||||
(identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
(field_expression (identifier) @function.call .))
|
||||
(field_expression
|
||||
(identifier) @function.call .))
|
||||
|
||||
(broadcast_call_expression
|
||||
(identifier) @function.call)
|
||||
|
||||
(broadcast_call_expression
|
||||
(field_expression (identifier) @function.call .))
|
||||
(field_expression
|
||||
(identifier) @function.call .))
|
||||
|
||||
(binary_expression
|
||||
(_)
|
||||
|
|
@ -53,24 +61,18 @@
|
|||
(identifier) @function.call
|
||||
(#eq? @_pipe "|>"))
|
||||
|
||||
;; Builtins
|
||||
|
||||
; Builtins
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"_abstracttype" "_apply_iterate" "_apply_pure" "_call_in_world" "_call_in_world_total"
|
||||
"_call_latest" "_equiv_typedef" "_expr" "_primitivetype" "_setsuper!" "_structtype"
|
||||
"_typebody!" "_typevar" "applicable" "apply_type" "arrayref" "arrayset" "arraysize"
|
||||
"const_arrayref" "donotdelete" "fieldtype" "get_binding_type" "getfield" "ifelse" "invoke" "isa"
|
||||
"isdefined" "modifyfield!" "nfields" "replacefield!" "set_binding_type!" "setfield!" "sizeof"
|
||||
"svec" "swapfield!" "throw" "tuple" "typeassert" "typeof"))
|
||||
|
||||
|
||||
;;; Parameters
|
||||
(#any-of? @function.builtin "_abstracttype" "_apply_iterate" "_apply_pure" "_call_in_world" "_call_in_world_total" "_call_latest" "_equiv_typedef" "_expr" "_primitivetype" "_setsuper!" "_structtype" "_typebody!" "_typevar" "applicable" "apply_type" "arrayref" "arrayset" "arraysize" "const_arrayref" "donotdelete" "fieldtype" "get_binding_type" "getfield" "ifelse" "invoke" "isa" "isdefined" "modifyfield!" "nfields" "replacefield!" "set_binding_type!" "setfield!" "sizeof" "svec" "swapfield!" "throw" "tuple" "typeassert" "typeof"))
|
||||
|
||||
; Parameters
|
||||
(parameter_list
|
||||
(identifier) @variable.parameter)
|
||||
(optional_parameter .
|
||||
|
||||
(optional_parameter
|
||||
.
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(slurp_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
|
|
@ -79,28 +81,32 @@
|
|||
type: (_) @type)
|
||||
|
||||
(function_expression
|
||||
. (identifier) @variable.parameter) ; Single parameter arrow functions
|
||||
|
||||
|
||||
;;; Types
|
||||
|
||||
;; Definitions
|
||||
.
|
||||
(identifier) @variable.parameter) ; Single parameter arrow functions
|
||||
|
||||
; Types
|
||||
; Definitions
|
||||
(abstract_definition
|
||||
name: (identifier) @type.definition) @keyword
|
||||
|
||||
(primitive_definition
|
||||
name: (identifier) @type.definition) @keyword
|
||||
|
||||
(struct_definition
|
||||
name: (identifier) @type)
|
||||
|
||||
(type_clause
|
||||
[(identifier) @type
|
||||
(field_expression (identifier) @type .)])
|
||||
|
||||
;; Annotations
|
||||
[
|
||||
(identifier) @type
|
||||
(field_expression
|
||||
(identifier) @type .)
|
||||
])
|
||||
|
||||
; Annotations
|
||||
(parametrized_type_expression
|
||||
(_) @type
|
||||
(curly_expression (_) @type))
|
||||
(curly_expression
|
||||
(_) @type))
|
||||
|
||||
(type_parameter_list
|
||||
(identifier) @type)
|
||||
|
|
@ -110,22 +116,24 @@
|
|||
|
||||
(function_definition
|
||||
return_type: (identifier) @type)
|
||||
|
||||
(short_function_definition
|
||||
return_type: (identifier) @type)
|
||||
|
||||
(where_clause
|
||||
(identifier) @type)
|
||||
|
||||
(where_clause
|
||||
(curly_expression (_) @type))
|
||||
(curly_expression
|
||||
(_) @type))
|
||||
|
||||
;; Builtins
|
||||
|
||||
;; This list was generated with:
|
||||
;;
|
||||
;; istype(x) = typeof(x) === DataType || typeof(x) === UnionAll
|
||||
;; get_types(m) = filter(x -> istype(Base.eval(m, x)), names(m))
|
||||
;; type_names = sort(union(get_types(Core), get_types(Base)))
|
||||
;;
|
||||
; Builtins
|
||||
; This list was generated with:
|
||||
;
|
||||
; istype(x) = typeof(x) === DataType || typeof(x) === UnionAll
|
||||
; get_types(m) = filter(x -> istype(Base.eval(m, x)), names(m))
|
||||
; type_names = sort(union(get_types(Core), get_types(Base)))
|
||||
;
|
||||
((identifier) @type.builtin
|
||||
; format-ignore
|
||||
(#any-of? @type.builtin
|
||||
|
|
@ -347,71 +355,129 @@
|
|||
(#any-of? @variable.builtin "begin" "end")
|
||||
(#has-ancestor? @variable.builtin range_expression))
|
||||
|
||||
;;; Keywords
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"global"
|
||||
"local"
|
||||
] @keyword
|
||||
|
||||
|
||||
(compound_statement
|
||||
["begin" "end"] @keyword)
|
||||
[
|
||||
"begin"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(quote_statement
|
||||
["quote" "end"] @keyword)
|
||||
[
|
||||
"quote"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(let_statement
|
||||
["let" "end"] @keyword)
|
||||
[
|
||||
"let"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(if_statement
|
||||
["if" "end"] @keyword.conditional)
|
||||
[
|
||||
"if"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
(elseif_clause
|
||||
"elseif" @keyword.conditional)
|
||||
|
||||
(else_clause
|
||||
"else" @keyword.conditional)
|
||||
|
||||
(if_clause
|
||||
"if" @keyword.conditional) ; `if` clause in comprehensions
|
||||
|
||||
(ternary_expression
|
||||
["?" ":"] @keyword.conditional.ternary)
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
(try_statement
|
||||
["try" "end"] @keyword.exception)
|
||||
[
|
||||
"try"
|
||||
"end"
|
||||
] @keyword.exception)
|
||||
|
||||
(finally_clause
|
||||
"finally" @keyword.exception)
|
||||
|
||||
(catch_clause
|
||||
"catch" @keyword.exception)
|
||||
|
||||
(for_statement
|
||||
["for" "end"] @keyword.repeat)
|
||||
[
|
||||
"for"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
(while_statement
|
||||
["while" "end"] @keyword.repeat)
|
||||
[
|
||||
"while"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
(for_clause
|
||||
"for" @keyword.repeat)
|
||||
|
||||
[
|
||||
(break_statement)
|
||||
(continue_statement)
|
||||
] @keyword.repeat
|
||||
|
||||
(module_definition
|
||||
["module" "baremodule" "end"] @keyword.import)
|
||||
[
|
||||
"module"
|
||||
"baremodule"
|
||||
"end"
|
||||
] @keyword.import)
|
||||
|
||||
(import_statement
|
||||
["import" "using"] @keyword.import)
|
||||
[
|
||||
"import"
|
||||
"using"
|
||||
] @keyword.import)
|
||||
|
||||
(import_alias
|
||||
"as" @keyword.import)
|
||||
|
||||
(export_statement
|
||||
"export" @keyword.import)
|
||||
|
||||
(selected_import
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
(struct_definition
|
||||
["struct" "end"] @keyword)
|
||||
[
|
||||
"struct"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(macro_definition
|
||||
["macro" "end"] @keyword)
|
||||
[
|
||||
"macro"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(function_definition
|
||||
["function" "end"] @keyword.function)
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
(do_clause
|
||||
["do" "end"] @keyword.function)
|
||||
[
|
||||
"do"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
(return_statement
|
||||
"return" @keyword.return)
|
||||
|
||||
|
|
@ -420,25 +486,30 @@
|
|||
"mutable"
|
||||
] @type.qualifier
|
||||
|
||||
|
||||
;;; Operators & Punctuation
|
||||
|
||||
; Operators & Punctuation
|
||||
[
|
||||
"="
|
||||
"∈"
|
||||
(operator)
|
||||
] @operator
|
||||
|
||||
(adjoint_expression "'" @operator)
|
||||
(range_expression ":" @operator)
|
||||
(adjoint_expression
|
||||
"'" @operator)
|
||||
|
||||
(range_expression
|
||||
":" @operator)
|
||||
|
||||
((operator) @keyword.operator
|
||||
(#any-of? @keyword.operator "in" "isa"))
|
||||
|
||||
(for_binding "in" @keyword.operator)
|
||||
(for_binding
|
||||
"in" @keyword.operator)
|
||||
|
||||
(where_clause "where" @keyword.operator)
|
||||
(where_expression "where" @keyword.operator)
|
||||
(where_clause
|
||||
"where" @keyword.operator)
|
||||
|
||||
(where_expression
|
||||
"where" @keyword.operator)
|
||||
|
||||
[
|
||||
","
|
||||
|
|
@ -448,50 +519,57 @@
|
|||
"->"
|
||||
] @punctuation.delimiter
|
||||
|
||||
"..." @punctuation.special
|
||||
|
||||
[
|
||||
"..."
|
||||
] @punctuation.special
|
||||
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
|
||||
|
||||
;;; Literals
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Literals
|
||||
(boolean_literal) @boolean
|
||||
|
||||
(integer_literal) @number
|
||||
|
||||
(float_literal) @number.float
|
||||
|
||||
((identifier) @number.float
|
||||
(#any-of? @number.float "NaN" "NaN16" "NaN32"
|
||||
"Inf" "Inf16" "Inf32"))
|
||||
(#any-of? @number.float "NaN" "NaN16" "NaN32" "Inf" "Inf16" "Inf32"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "nothing" "missing"))
|
||||
|
||||
(character_literal) @character
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(string_literal) @string
|
||||
|
||||
(prefixed_string_literal
|
||||
prefix: (identifier) @function.macro) @string
|
||||
|
||||
(command_literal) @string.special
|
||||
|
||||
(prefixed_command_literal
|
||||
prefix: (identifier) @function.macro) @string.special
|
||||
|
||||
((string_literal) @string.documentation @spell
|
||||
. [
|
||||
(module_definition)
|
||||
(abstract_definition)
|
||||
(struct_definition)
|
||||
(function_definition)
|
||||
(short_function_definition)
|
||||
(assignment)
|
||||
(const_statement)
|
||||
])
|
||||
.
|
||||
[
|
||||
(module_definition)
|
||||
(abstract_definition)
|
||||
(struct_definition)
|
||||
(function_definition)
|
||||
(short_function_definition)
|
||||
(assignment)
|
||||
(const_statement)
|
||||
])
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment @spell
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
(struct_definition)
|
||||
(macro_definition)
|
||||
(function_definition)
|
||||
|
||||
(compound_statement)
|
||||
(if_statement)
|
||||
(try_statement)
|
||||
|
|
@ -11,13 +10,10 @@
|
|||
(let_statement)
|
||||
(quote_statement)
|
||||
(do_clause)
|
||||
|
||||
(assignment)
|
||||
(for_binding)
|
||||
|
||||
(call_expression)
|
||||
(parenthesized_expression)
|
||||
|
||||
(tuple_expression)
|
||||
(comprehension_expression)
|
||||
(matrix_expression)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
;; Inject markdown in docstrings
|
||||
; Inject markdown in docstrings
|
||||
((string_literal) @injection.content
|
||||
. [
|
||||
.
|
||||
[
|
||||
(module_definition)
|
||||
(abstract_definition)
|
||||
(struct_definition)
|
||||
|
|
@ -9,18 +10,18 @@
|
|||
(assignment)
|
||||
(const_statement)
|
||||
]
|
||||
(#lua-match? @injection.content "^\"\"\"")
|
||||
(#set! injection.language "markdown")
|
||||
(#offset! @injection.content 0 3 0 -3))
|
||||
(#lua-match? @injection.content "^\"\"\"")
|
||||
(#set! injection.language "markdown")
|
||||
(#offset! @injection.content 0 3 0 -3))
|
||||
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((prefixed_string_literal
|
||||
prefix: (identifier) @_prefix) @injection.content
|
||||
(#eq? @_prefix "r")
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 2 0 -1))
|
||||
prefix: (identifier) @_prefix) @injection.content
|
||||
(#eq? @_prefix "r")
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 2 0 -1))
|
||||
|
|
|
|||
|
|
@ -1,50 +1,52 @@
|
|||
;;; Variables
|
||||
; Variables
|
||||
(assignment
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(assignment
|
||||
(tuple_expression
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
;;; let/const bindings
|
||||
; let/const bindings
|
||||
(let_binding
|
||||
(identifier) @local.definition.var)
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(let_binding
|
||||
(tuple_expression
|
||||
(identifier) @local.definition.var))
|
||||
(tuple_expression
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
|
||||
;;; For bindings
|
||||
; For bindings
|
||||
(for_binding
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(for_binding
|
||||
(tuple_expression
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
|
||||
;;; Types
|
||||
|
||||
; Types
|
||||
(struct_definition
|
||||
name: (identifier) @local.definition.type)
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @local.definition.type)
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @local.definition.type)
|
||||
|
||||
(type_parameter_list
|
||||
(identifier) @local.definition.type)
|
||||
|
||||
;;; Module imports
|
||||
|
||||
; Module imports
|
||||
(import_statement
|
||||
(identifier) @local.definition.import)
|
||||
|
||||
|
||||
;;; Parameters
|
||||
|
||||
; Parameters
|
||||
(parameter_list
|
||||
(identifier) @local.definition.parameter)
|
||||
(optional_parameter .
|
||||
|
||||
(optional_parameter
|
||||
.
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
(slurp_parameter
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
|
|
@ -52,18 +54,19 @@
|
|||
parameter: (identifier) @local.definition.parameter
|
||||
(_))
|
||||
|
||||
;; Single parameter arrow function
|
||||
; Single parameter arrow function
|
||||
(function_expression
|
||||
. (identifier) @local.definition.parameter)
|
||||
|
||||
|
||||
;;; Function/macro definitions
|
||||
.
|
||||
(identifier) @local.definition.parameter)
|
||||
|
||||
; Function/macro definitions
|
||||
(function_definition
|
||||
name: (identifier) @local.definition.function) @local.scope
|
||||
|
||||
(short_function_definition
|
||||
name: (identifier) @local.definition.function) @local.scope
|
||||
(macro_definition
|
||||
|
||||
(macro_definition
|
||||
name: (identifier) @local.definition.macro) @local.scope
|
||||
|
||||
(identifier) @local.reference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue