mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 19:00:02 -04:00
chore: query formatting
This commit is contained in:
parent
79975d6557
commit
57a8acf0c4
674 changed files with 18466 additions and 12648 deletions
|
|
@ -1,32 +1,31 @@
|
|||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(global_variable) @variable.global
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"alias"
|
||||
"begin"
|
||||
"class"
|
||||
"do"
|
||||
"end"
|
||||
"ensure"
|
||||
"module"
|
||||
"rescue"
|
||||
"then"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"alias"
|
||||
"begin"
|
||||
"class"
|
||||
"do"
|
||||
"end"
|
||||
"ensure"
|
||||
"module"
|
||||
"rescue"
|
||||
"then"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"return"
|
||||
"yield"
|
||||
"return"
|
||||
"yield"
|
||||
] @keyword.return
|
||||
|
||||
[
|
||||
"and"
|
||||
"or"
|
||||
"in"
|
||||
"not"
|
||||
"and"
|
||||
"or"
|
||||
"in"
|
||||
"not"
|
||||
] @keyword.operator
|
||||
|
||||
[
|
||||
|
|
@ -38,139 +37,170 @@
|
|||
"end" @keyword.function)
|
||||
|
||||
[
|
||||
"case"
|
||||
"else"
|
||||
"elsif"
|
||||
"if"
|
||||
"unless"
|
||||
"when"
|
||||
"then"
|
||||
] @keyword.conditional
|
||||
"case"
|
||||
"else"
|
||||
"elsif"
|
||||
"if"
|
||||
"unless"
|
||||
"when"
|
||||
"then"
|
||||
] @keyword.conditional
|
||||
|
||||
(if
|
||||
"end" @keyword.conditional)
|
||||
|
||||
[
|
||||
"for"
|
||||
"until"
|
||||
"while"
|
||||
"break"
|
||||
"redo"
|
||||
"retry"
|
||||
"next"
|
||||
] @keyword.repeat
|
||||
"for"
|
||||
"until"
|
||||
"while"
|
||||
"break"
|
||||
"redo"
|
||||
"retry"
|
||||
"next"
|
||||
] @keyword.repeat
|
||||
|
||||
(constant) @constant
|
||||
|
||||
((identifier) @type.qualifier
|
||||
(#any-of? @type.qualifier "private" "protected" "public"))
|
||||
(#any-of? @type.qualifier "private" "protected" "public"))
|
||||
|
||||
[
|
||||
"rescue"
|
||||
"ensure"
|
||||
] @keyword.exception
|
||||
"rescue"
|
||||
"ensure"
|
||||
] @keyword.exception
|
||||
|
||||
((identifier) @keyword.exception
|
||||
(#any-of? @keyword.exception "fail" "raise"))
|
||||
(#any-of? @keyword.exception "fail" "raise"))
|
||||
|
||||
; Function calls
|
||||
|
||||
"defined?" @function
|
||||
|
||||
(call
|
||||
receiver: (constant)? @type
|
||||
method: [
|
||||
(identifier)
|
||||
(constant)
|
||||
] @function.call
|
||||
)
|
||||
receiver: (constant)? @type
|
||||
method:
|
||||
[
|
||||
(identifier)
|
||||
(constant)
|
||||
] @function.call)
|
||||
|
||||
(program
|
||||
(call
|
||||
(identifier) @keyword.import)
|
||||
(#any-of? @keyword.import "require" "require_relative" "load"))
|
||||
(call
|
||||
(identifier) @keyword.import)
|
||||
(#any-of? @keyword.import "require" "require_relative" "load"))
|
||||
|
||||
; Function definitions
|
||||
(alias
|
||||
(identifier) @function)
|
||||
|
||||
(alias (identifier) @function)
|
||||
(setter (identifier) @function)
|
||||
(setter
|
||||
(identifier) @function)
|
||||
|
||||
(method name: [
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
(method
|
||||
name:
|
||||
[
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
|
||||
(singleton_method name: [
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
(singleton_method
|
||||
name:
|
||||
[
|
||||
(identifier) @function
|
||||
(constant) @type
|
||||
])
|
||||
|
||||
(class name: (constant) @type)
|
||||
(module name: (constant) @type)
|
||||
(superclass (constant) @type)
|
||||
(class
|
||||
name: (constant) @type)
|
||||
|
||||
(module
|
||||
name: (constant) @type)
|
||||
|
||||
(superclass
|
||||
(constant) @type)
|
||||
|
||||
; Identifiers
|
||||
[
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @label
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @label
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__(callee|dir|id|method|send|ENCODING|FILE|LINE)__$"))
|
||||
(#match? @constant.builtin "^__(callee|dir|id|method|send|ENCODING|FILE|LINE)__$"))
|
||||
|
||||
((constant) @type
|
||||
(#not-lua-match? @type "^[A-Z0-9_]+$"))
|
||||
(#not-lua-match? @type "^[A-Z0-9_]+$"))
|
||||
|
||||
[
|
||||
(self)
|
||||
(super)
|
||||
] @variable.builtin
|
||||
(self)
|
||||
(super)
|
||||
] @variable.builtin
|
||||
|
||||
(method_parameters (identifier) @variable.parameter)
|
||||
(lambda_parameters (identifier) @variable.parameter)
|
||||
(block_parameters (identifier) @variable.parameter)
|
||||
(splat_parameter (identifier) @variable.parameter)
|
||||
(hash_splat_parameter (identifier) @variable.parameter)
|
||||
(optional_parameter (identifier) @variable.parameter)
|
||||
(destructured_parameter (identifier) @variable.parameter)
|
||||
(block_parameter (identifier) @variable.parameter)
|
||||
(keyword_parameter (identifier) @variable.parameter)
|
||||
(method_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(lambda_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(block_parameters
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(splat_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(hash_splat_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(optional_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(destructured_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(block_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(keyword_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
; TODO: Re-enable this once it is supported
|
||||
; ((identifier) @function
|
||||
; (#is-not? local))
|
||||
|
||||
; Literals
|
||||
[
|
||||
(string)
|
||||
(bare_string)
|
||||
(subshell)
|
||||
(heredoc_body)
|
||||
] @string
|
||||
|
||||
[
|
||||
(string)
|
||||
(bare_string)
|
||||
(subshell)
|
||||
(heredoc_body)
|
||||
] @string
|
||||
(heredoc_beginning)
|
||||
(heredoc_end)
|
||||
] @constant
|
||||
|
||||
[
|
||||
(heredoc_beginning)
|
||||
(heredoc_end)
|
||||
] @constant
|
||||
(bare_symbol)
|
||||
(simple_symbol)
|
||||
(delimited_symbol)
|
||||
(hash_key_symbol)
|
||||
] @string.special.symbol
|
||||
|
||||
[
|
||||
(bare_symbol)
|
||||
(simple_symbol)
|
||||
(delimited_symbol)
|
||||
(hash_key_symbol)
|
||||
] @string.special.symbol
|
||||
(pair
|
||||
key: (hash_key_symbol)
|
||||
":" @constant)
|
||||
|
||||
(pair key: (hash_key_symbol) ":" @constant)
|
||||
(regex) @string.regexp
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(integer) @number
|
||||
|
||||
(float) @number.float
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
|
|
@ -182,75 +212,76 @@
|
|||
|
||||
(module
|
||||
(comment)+ @comment.documentation
|
||||
(body_statement (class)))
|
||||
(body_statement
|
||||
(class)))
|
||||
|
||||
(class
|
||||
(comment)+ @comment.documentation
|
||||
(body_statement (method)))
|
||||
(body_statement
|
||||
(method)))
|
||||
|
||||
(body_statement
|
||||
(comment)+ @comment.documentation
|
||||
(method))
|
||||
|
||||
; Operators
|
||||
[
|
||||
"!"
|
||||
"="
|
||||
"=="
|
||||
"==="
|
||||
"<=>"
|
||||
"=>"
|
||||
"->"
|
||||
">>"
|
||||
"<<"
|
||||
">"
|
||||
"<"
|
||||
">="
|
||||
"<="
|
||||
"**"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"+"
|
||||
"-"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"&&"
|
||||
"||"
|
||||
"||="
|
||||
"&&="
|
||||
"!="
|
||||
"%="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"=~"
|
||||
"!~"
|
||||
"?"
|
||||
":"
|
||||
".."
|
||||
"..."
|
||||
] @operator
|
||||
|
||||
[
|
||||
"!"
|
||||
"="
|
||||
"=="
|
||||
"==="
|
||||
"<=>"
|
||||
"=>"
|
||||
"->"
|
||||
">>"
|
||||
"<<"
|
||||
">"
|
||||
"<"
|
||||
">="
|
||||
"<="
|
||||
"**"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"+"
|
||||
"-"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"&&"
|
||||
"||"
|
||||
"||="
|
||||
"&&="
|
||||
"!="
|
||||
"%="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"=~"
|
||||
"!~"
|
||||
"?"
|
||||
":"
|
||||
".."
|
||||
"..."
|
||||
] @operator
|
||||
","
|
||||
";"
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
|
||||
(interpolation
|
||||
"#{" @punctuation.special
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(heredoc_body
|
||||
(heredoc_content) @injection.content
|
||||
(heredoc_end) @injection.language
|
||||
(#downcase! @injection.language))
|
||||
(heredoc_content) @injection.content
|
||||
(heredoc_end) @injection.language
|
||||
(#downcase! @injection.language))
|
||||
|
||||
(regex
|
||||
(string_content) @injection.content
|
||||
(regex
|
||||
(string_content) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
|
|
|||
|
|
@ -19,37 +19,77 @@
|
|||
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
; SOFTWARE.
|
||||
|
||||
;;; DECLARATIONS AND SCOPES
|
||||
; DECLARATIONS AND SCOPES
|
||||
(method) @local.scope
|
||||
|
||||
(class) @local.scope
|
||||
|
||||
[
|
||||
(block)
|
||||
(do_block)
|
||||
] @local.scope
|
||||
(block)
|
||||
(do_block)
|
||||
] @local.scope
|
||||
|
||||
(identifier) @local.reference
|
||||
|
||||
(constant) @local.reference
|
||||
|
||||
(instance_variable) @local.reference
|
||||
|
||||
(module name: (constant) @local.definition.namespace)
|
||||
(class name: (constant) @local.definition.type)
|
||||
(method name: [(identifier) (constant)] @local.definition.function)
|
||||
(singleton_method name: [(identifier) (constant)] @local.definition.function)
|
||||
(module
|
||||
name: (constant) @local.definition.namespace)
|
||||
|
||||
(method_parameters (identifier) @local.definition.var)
|
||||
(lambda_parameters (identifier) @local.definition.var)
|
||||
(block_parameters (identifier) @local.definition.var)
|
||||
(splat_parameter (identifier) @local.definition.var)
|
||||
(hash_splat_parameter (identifier) @local.definition.var)
|
||||
(optional_parameter name: (identifier) @local.definition.var)
|
||||
(destructured_parameter (identifier) @local.definition.var)
|
||||
(block_parameter name: (identifier) @local.definition.var)
|
||||
(keyword_parameter name: (identifier) @local.definition.var)
|
||||
(class
|
||||
name: (constant) @local.definition.type)
|
||||
|
||||
(assignment left: (_) @local.definition.var)
|
||||
(method
|
||||
name:
|
||||
[
|
||||
(identifier)
|
||||
(constant)
|
||||
] @local.definition.function)
|
||||
|
||||
(left_assignment_list (identifier) @local.definition.var)
|
||||
(rest_assignment (identifier) @local.definition.var)
|
||||
(destructured_left_assignment (identifier) @local.definition.var)
|
||||
(singleton_method
|
||||
name:
|
||||
[
|
||||
(identifier)
|
||||
(constant)
|
||||
] @local.definition.function)
|
||||
|
||||
(method_parameters
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(lambda_parameters
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(block_parameters
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(splat_parameter
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(hash_splat_parameter
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(optional_parameter
|
||||
name: (identifier) @local.definition.var)
|
||||
|
||||
(destructured_parameter
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(block_parameter
|
||||
name: (identifier) @local.definition.var)
|
||||
|
||||
(keyword_parameter
|
||||
name: (identifier) @local.definition.var)
|
||||
|
||||
(assignment
|
||||
left: (_) @local.definition.var)
|
||||
|
||||
(left_assignment_list
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(rest_assignment
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(destructured_left_assignment
|
||||
(identifier) @local.definition.var)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue