mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 18:30: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,20 +1,19 @@
|
|||
[
|
||||
(const_declaration)
|
||||
(expression_switch_statement)
|
||||
(expression_case)
|
||||
(default_case)
|
||||
(type_switch_statement)
|
||||
(type_case)
|
||||
(for_statement)
|
||||
(func_literal)
|
||||
(function_declaration)
|
||||
(if_statement)
|
||||
(import_declaration)
|
||||
(method_declaration)
|
||||
(type_declaration)
|
||||
(var_declaration)
|
||||
(composite_literal)
|
||||
(literal_element)
|
||||
(block)
|
||||
(const_declaration)
|
||||
(expression_switch_statement)
|
||||
(expression_case)
|
||||
(default_case)
|
||||
(type_switch_statement)
|
||||
(type_case)
|
||||
(for_statement)
|
||||
(func_literal)
|
||||
(function_declaration)
|
||||
(if_statement)
|
||||
(import_declaration)
|
||||
(method_declaration)
|
||||
(type_declaration)
|
||||
(var_declaration)
|
||||
(composite_literal)
|
||||
(literal_element)
|
||||
(block)
|
||||
] @fold
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
;; Forked from tree-sitter-go
|
||||
;; Copyright (c) 2014 Max Brunsfeld (The MIT License)
|
||||
|
||||
;;
|
||||
; Forked from tree-sitter-go
|
||||
; Copyright (c) 2014 Max Brunsfeld (The MIT License)
|
||||
;
|
||||
; Identifiers
|
||||
|
||||
(type_identifier) @type
|
||||
(type_spec name: (type_identifier) @type.definition)
|
||||
|
||||
(type_spec
|
||||
name: (type_identifier) @type.definition)
|
||||
|
||||
(field_identifier) @property
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(package_identifier) @module
|
||||
|
||||
(parameter_declaration (identifier) @variable.parameter)
|
||||
(variadic_parameter_declaration (identifier) @variable.parameter)
|
||||
(parameter_declaration
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(variadic_parameter_declaration
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(label_name) @label
|
||||
|
||||
|
|
@ -19,16 +25,15 @@
|
|||
name: (identifier) @constant)
|
||||
|
||||
; Function calls
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @function.method.call))
|
||||
function:
|
||||
(selector_expression
|
||||
field: (field_identifier) @function.method.call))
|
||||
|
||||
; Function definitions
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
|
|
@ -39,15 +44,15 @@
|
|||
name: (field_identifier) @function.method)
|
||||
|
||||
; Constructors
|
||||
|
||||
((call_expression (identifier) @constructor)
|
||||
((call_expression
|
||||
(identifier) @constructor)
|
||||
(#lua-match? @constructor "^[nN]ew.+$"))
|
||||
|
||||
((call_expression (identifier) @constructor)
|
||||
((call_expression
|
||||
(identifier) @constructor)
|
||||
(#lua-match? @constructor "^[mM]ake.+$"))
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"--"
|
||||
"-"
|
||||
|
|
@ -91,7 +96,6 @@
|
|||
] @operator
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"break"
|
||||
"const"
|
||||
|
|
@ -109,7 +113,9 @@
|
|||
] @keyword
|
||||
|
||||
"func" @keyword.function
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
"go" @keyword.coroutine
|
||||
|
||||
"for" @keyword.repeat
|
||||
|
|
@ -124,128 +130,103 @@
|
|||
"case"
|
||||
"switch"
|
||||
"if"
|
||||
] @keyword.conditional
|
||||
] @keyword.conditional
|
||||
|
||||
|
||||
;; Builtin types
|
||||
|
||||
[ "chan" "map" ] @type.builtin
|
||||
; Builtin types
|
||||
[
|
||||
"chan"
|
||||
"map"
|
||||
] @type.builtin
|
||||
|
||||
((type_identifier) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
"any"
|
||||
"bool"
|
||||
"byte"
|
||||
"comparable"
|
||||
"complex128"
|
||||
"complex64"
|
||||
"error"
|
||||
"float32"
|
||||
"float64"
|
||||
"int"
|
||||
"int16"
|
||||
"int32"
|
||||
"int64"
|
||||
"int8"
|
||||
"rune"
|
||||
"string"
|
||||
"uint"
|
||||
"uint16"
|
||||
"uint32"
|
||||
"uint64"
|
||||
"uint8"
|
||||
"uintptr"))
|
||||
|
||||
|
||||
;; Builtin functions
|
||||
(#any-of? @type.builtin "any" "bool" "byte" "comparable" "complex128" "complex64" "error" "float32" "float64" "int" "int16" "int32" "int64" "int8" "rune" "string" "uint" "uint16" "uint32" "uint64" "uint8" "uintptr"))
|
||||
|
||||
; Builtin functions
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"append"
|
||||
"cap"
|
||||
"clear"
|
||||
"close"
|
||||
"complex"
|
||||
"copy"
|
||||
"delete"
|
||||
"imag"
|
||||
"len"
|
||||
"make"
|
||||
"max"
|
||||
"min"
|
||||
"new"
|
||||
"panic"
|
||||
"print"
|
||||
"println"
|
||||
"real"
|
||||
"recover"))
|
||||
|
||||
(#any-of? @function.builtin "append" "cap" "clear" "close" "complex" "copy" "delete" "imag" "len" "make" "max" "min" "new" "panic" "print" "println" "real" "recover"))
|
||||
|
||||
; Delimiters
|
||||
|
||||
"." @punctuation.delimiter
|
||||
|
||||
"," @punctuation.delimiter
|
||||
|
||||
":" @punctuation.delimiter
|
||||
|
||||
";" @punctuation.delimiter
|
||||
|
||||
"(" @punctuation.bracket
|
||||
|
||||
")" @punctuation.bracket
|
||||
|
||||
"{" @punctuation.bracket
|
||||
|
||||
"}" @punctuation.bracket
|
||||
|
||||
"[" @punctuation.bracket
|
||||
|
||||
"]" @punctuation.bracket
|
||||
|
||||
|
||||
; Literals
|
||||
|
||||
(interpreted_string_literal) @string
|
||||
|
||||
(raw_string_literal) @string
|
||||
|
||||
(rune_literal) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(int_literal) @number
|
||||
|
||||
(float_literal) @number.float
|
||||
|
||||
(imaginary_literal) @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
[
|
||||
(nil)
|
||||
(iota)
|
||||
(nil)
|
||||
(iota)
|
||||
] @constant.builtin
|
||||
|
||||
(keyed_element
|
||||
. (literal_element (identifier) @variable.member))
|
||||
(field_declaration name: (field_identifier) @variable.member)
|
||||
.
|
||||
(literal_element
|
||||
(identifier) @variable.member))
|
||||
|
||||
(field_declaration
|
||||
name: (field_identifier) @variable.member)
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
;; Doc Comments
|
||||
|
||||
(source_file . (comment)+ @comment.documentation)
|
||||
; Doc Comments
|
||||
(source_file
|
||||
.
|
||||
(comment)+ @comment.documentation)
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (const_declaration))
|
||||
.
|
||||
(const_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (function_declaration))
|
||||
.
|
||||
(function_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (type_declaration))
|
||||
.
|
||||
(type_declaration))
|
||||
|
||||
(source_file
|
||||
(comment)+ @comment.documentation
|
||||
. (var_declaration))
|
||||
.
|
||||
(var_declaration))
|
||||
|
||||
; Spell
|
||||
|
||||
((interpreted_string_literal) @spell
|
||||
(#not-has-parent? @spell import_spec))
|
||||
|
|
|
|||
|
|
@ -15,19 +15,23 @@
|
|||
(struct_type)
|
||||
] @indent.begin
|
||||
|
||||
"}" @indent.branch
|
||||
|
||||
(const_declaration
|
||||
")" @indent.branch)
|
||||
|
||||
(import_spec_list
|
||||
")" @indent.branch)
|
||||
|
||||
(var_declaration
|
||||
")" @indent.branch)
|
||||
|
||||
[
|
||||
"}"
|
||||
] @indent.branch
|
||||
|
||||
(const_declaration ")" @indent.branch)
|
||||
(import_spec_list ")" @indent.branch)
|
||||
(var_declaration ")" @indent.branch)
|
||||
|
||||
[
|
||||
"}"
|
||||
")"
|
||||
")"
|
||||
] @indent.end
|
||||
|
||||
(parameter_list ")" @indent.branch)
|
||||
(parameter_list
|
||||
")" @indent.branch)
|
||||
|
||||
(comment) @indent.ignore
|
||||
|
|
|
|||
|
|
@ -1,38 +1,41 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(call_expression
|
||||
(selector_expression) @_function (#any-of? @_function
|
||||
"regexp.Match"
|
||||
"regexp.MatchReader"
|
||||
"regexp.MatchString"
|
||||
"regexp.Compile"
|
||||
"regexp.CompilePOSIX"
|
||||
"regexp.MustCompile"
|
||||
"regexp.MustCompilePOSIX")
|
||||
(selector_expression) @_function
|
||||
(#any-of? @_function "regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX" "regexp.MustCompile" "regexp.MustCompilePOSIX")
|
||||
(argument_list
|
||||
.
|
||||
[
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
] @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "regex")))
|
||||
|
||||
|
||||
((comment) @injection.content
|
||||
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||
(#set! injection.language "re2c"))
|
||||
|
||||
((call_expression
|
||||
function: (selector_expression field: (field_identifier) @_method)
|
||||
arguments: (argument_list . (interpreted_string_literal) @injection.content))
|
||||
(#any-of? @_method "Printf" "Sprintf" "Fatalf" "Scanf")
|
||||
(#set! injection.language "printf"))
|
||||
function:
|
||||
(selector_expression
|
||||
field: (field_identifier) @_method)
|
||||
arguments:
|
||||
(argument_list
|
||||
.
|
||||
(interpreted_string_literal) @injection.content))
|
||||
(#any-of? @_method "Printf" "Sprintf" "Fatalf" "Scanf")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
((call_expression
|
||||
function: (selector_expression field: (field_identifier) @_method)
|
||||
arguments: (argument_list (_) . (interpreted_string_literal) @injection.content))
|
||||
(#eq? @_method "Fprintf")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
function:
|
||||
(selector_expression
|
||||
field: (field_identifier) @_method)
|
||||
arguments:
|
||||
(argument_list
|
||||
(_)
|
||||
.
|
||||
(interpreted_string_literal) @injection.content))
|
||||
(#eq? @_method "Fprintf")
|
||||
(#set! injection.language "printf"))
|
||||
|
|
|
|||
|
|
@ -1,79 +1,93 @@
|
|||
(
|
||||
(function_declaration
|
||||
name: (identifier) @local.definition.function) ; @function
|
||||
)
|
||||
((function_declaration
|
||||
name: (identifier) @local.definition.function) ; @function
|
||||
)
|
||||
|
||||
(
|
||||
(method_declaration
|
||||
name: (field_identifier) @local.definition.method) ; @function.method
|
||||
)
|
||||
((method_declaration
|
||||
name: (field_identifier) @local.definition.method) ; @function.method
|
||||
)
|
||||
|
||||
(short_var_declaration
|
||||
left: (expression_list
|
||||
(identifier) @local.definition.var))
|
||||
(short_var_declaration
|
||||
left:
|
||||
(expression_list
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(var_spec
|
||||
(var_spec
|
||||
name: (identifier) @local.definition.var)
|
||||
|
||||
(parameter_declaration (identifier) @local.definition.var)
|
||||
(variadic_parameter_declaration (identifier) @local.definition.var)
|
||||
(parameter_declaration
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(variadic_parameter_declaration
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(for_statement
|
||||
(range_clause
|
||||
left: (expression_list
|
||||
(identifier) @local.definition.var)))
|
||||
(range_clause
|
||||
left:
|
||||
(expression_list
|
||||
(identifier) @local.definition.var)))
|
||||
|
||||
(const_declaration
|
||||
(const_spec
|
||||
name: (identifier) @local.definition.var))
|
||||
(const_spec
|
||||
name: (identifier) @local.definition.var))
|
||||
|
||||
(type_declaration
|
||||
(type_declaration
|
||||
(type_spec
|
||||
name: (type_identifier) @local.definition.type))
|
||||
|
||||
;; reference
|
||||
; reference
|
||||
(identifier) @local.reference
|
||||
|
||||
(type_identifier) @local.reference
|
||||
|
||||
(field_identifier) @local.reference
|
||||
|
||||
((package_identifier) @local.reference
|
||||
(#set! reference.kind "namespace"))
|
||||
|
||||
(package_clause
|
||||
(package_identifier) @local.definition.namespace)
|
||||
(package_identifier) @local.definition.namespace)
|
||||
|
||||
(import_spec_list
|
||||
(import_spec
|
||||
name: (package_identifier) @local.definition.namespace))
|
||||
|
||||
;; Call references
|
||||
; Call references
|
||||
((call_expression
|
||||
function: (identifier) @local.reference)
|
||||
(#set! reference.kind "call" ))
|
||||
function: (identifier) @local.reference)
|
||||
(#set! reference.kind "call"))
|
||||
|
||||
((call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @local.reference))
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
function:
|
||||
(selector_expression
|
||||
field: (field_identifier) @local.reference))
|
||||
(#set! reference.kind "call"))
|
||||
|
||||
((call_expression
|
||||
function: (parenthesized_expression
|
||||
(identifier) @local.reference))
|
||||
(#set! reference.kind "call" ))
|
||||
function:
|
||||
(parenthesized_expression
|
||||
(identifier) @local.reference))
|
||||
(#set! reference.kind "call"))
|
||||
|
||||
((call_expression
|
||||
function: (parenthesized_expression
|
||||
(selector_expression
|
||||
field: (field_identifier) @local.reference)))
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
;; Scopes
|
||||
function:
|
||||
(parenthesized_expression
|
||||
(selector_expression
|
||||
field: (field_identifier) @local.reference)))
|
||||
(#set! reference.kind "call"))
|
||||
|
||||
; Scopes
|
||||
(func_literal) @local.scope
|
||||
|
||||
(source_file) @local.scope
|
||||
|
||||
(function_declaration) @local.scope
|
||||
|
||||
(if_statement) @local.scope
|
||||
|
||||
(block) @local.scope
|
||||
|
||||
(expression_switch_statement) @local.scope
|
||||
|
||||
(for_statement) @local.scope
|
||||
|
||||
(method_declaration) @local.scope
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue