semi ok
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
[
|
||||
(mod_item)
|
||||
(foreign_mod_item)
|
||||
(function_item)
|
||||
(struct_item)
|
||||
(trait_item)
|
||||
(enum_item)
|
||||
(impl_item)
|
||||
(type_item)
|
||||
(union_item)
|
||||
(const_item)
|
||||
(let_declaration)
|
||||
(loop_expression)
|
||||
(for_expression)
|
||||
(while_expression)
|
||||
(if_expression)
|
||||
(match_expression)
|
||||
(call_expression)
|
||||
(array_expression)
|
||||
(macro_definition)
|
||||
(macro_invocation)
|
||||
(attribute_item)
|
||||
(block)
|
||||
(use_declaration)+
|
||||
] @fold
|
||||
@@ -0,0 +1,531 @@
|
||||
; Forked from https://github.com/tree-sitter/tree-sitter-rust
|
||||
; Copyright (c) 2017 Maxim Sokolov
|
||||
; Licensed under the MIT license.
|
||||
; Identifier conventions
|
||||
(shebang) @keyword.directive
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(const_item
|
||||
name: (identifier) @constant)
|
||||
|
||||
; Assume all-caps names are constants
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||
|
||||
; Other identifiers
|
||||
(type_identifier) @type
|
||||
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
(field_identifier) @variable.member
|
||||
|
||||
(shorthand_field_identifier) @variable.member
|
||||
|
||||
(shorthand_field_initializer
|
||||
(identifier) @variable.member)
|
||||
|
||||
(mod_item
|
||||
name: (identifier) @module)
|
||||
|
||||
(self) @variable.builtin
|
||||
|
||||
"_" @character.special
|
||||
|
||||
(label
|
||||
[
|
||||
"'"
|
||||
(identifier)
|
||||
] @label)
|
||||
|
||||
; Function definitions
|
||||
(function_item
|
||||
(identifier) @function)
|
||||
|
||||
(function_signature_item
|
||||
(identifier) @function)
|
||||
|
||||
(parameter
|
||||
[
|
||||
(identifier)
|
||||
"_"
|
||||
] @variable.parameter)
|
||||
|
||||
(parameter
|
||||
(ref_pattern
|
||||
[
|
||||
(mut_pattern
|
||||
(identifier) @variable.parameter)
|
||||
(identifier) @variable.parameter
|
||||
]))
|
||||
|
||||
(closure_parameters
|
||||
(_) @variable.parameter)
|
||||
|
||||
; Function calls
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
(identifier) @function.call .))
|
||||
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call))
|
||||
|
||||
(generic_function
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(generic_function
|
||||
function: (scoped_identifier
|
||||
name: (identifier) @function.call))
|
||||
|
||||
(generic_function
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call))
|
||||
|
||||
; Assume other uppercase names are enum constructors
|
||||
((field_identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
(enum_variant
|
||||
name: (identifier) @constant)
|
||||
|
||||
; Assume that uppercase names in paths are types
|
||||
(scoped_identifier
|
||||
path: (identifier) @module)
|
||||
|
||||
(scoped_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @module))
|
||||
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @module)
|
||||
|
||||
(scoped_type_identifier
|
||||
path: (identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(scoped_type_identifier
|
||||
(scoped_identifier
|
||||
name: (identifier) @module))
|
||||
|
||||
((scoped_identifier
|
||||
path: (identifier) @type)
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
((scoped_identifier
|
||||
name: (identifier) @type)
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
((scoped_identifier
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||
|
||||
((scoped_identifier
|
||||
path: (identifier) @type
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @type "^[A-Z]")
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((scoped_type_identifier
|
||||
path: (identifier) @type
|
||||
name: (type_identifier) @constant)
|
||||
(#lua-match? @type "^[A-Z]")
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
] @module
|
||||
|
||||
(scoped_use_list
|
||||
path: (identifier) @module)
|
||||
|
||||
(scoped_use_list
|
||||
path: (scoped_identifier
|
||||
(identifier) @module))
|
||||
|
||||
(use_list
|
||||
(scoped_identifier
|
||||
(identifier) @module
|
||||
.
|
||||
(_)))
|
||||
|
||||
(use_list
|
||||
(identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(use_as_clause
|
||||
alias: (identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
; Correct enum constructors
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
"::"
|
||||
name: (identifier) @constant)
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
; Assume uppercase names in a match arm are constants.
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(identifier) @constant))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((match_arm
|
||||
pattern: (match_pattern
|
||||
(scoped_identifier
|
||||
name: (identifier) @constant)))
|
||||
(#lua-match? @constant "^[A-Z]"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
|
||||
|
||||
; Macro definitions
|
||||
"$" @function.macro
|
||||
|
||||
(metavariable) @function.macro
|
||||
|
||||
(macro_definition
|
||||
"macro_rules!" @function.macro)
|
||||
|
||||
; Attribute macros
|
||||
(attribute_item
|
||||
(attribute
|
||||
(identifier) @function.macro))
|
||||
|
||||
(inner_attribute_item
|
||||
(attribute
|
||||
(identifier) @function.macro))
|
||||
|
||||
(attribute
|
||||
(scoped_identifier
|
||||
(identifier) @function.macro .))
|
||||
|
||||
; Derive macros (assume all arguments are types)
|
||||
; (attribute
|
||||
; (identifier) @_name
|
||||
; arguments: (attribute (attribute (identifier) @type))
|
||||
; (#eq? @_name "derive"))
|
||||
; Function-like macros
|
||||
(macro_invocation
|
||||
macro: (identifier) @function.macro)
|
||||
|
||||
(macro_invocation
|
||||
macro: (scoped_identifier
|
||||
(identifier) @function.macro .))
|
||||
|
||||
; Literals
|
||||
(boolean_literal) @boolean
|
||||
|
||||
(integer_literal) @number
|
||||
|
||||
(float_literal) @number.float
|
||||
|
||||
[
|
||||
(raw_string_literal)
|
||||
(string_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(char_literal) @character
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"use"
|
||||
"mod"
|
||||
] @keyword.import
|
||||
|
||||
(use_as_clause
|
||||
"as" @keyword.import)
|
||||
|
||||
[
|
||||
"default"
|
||||
"impl"
|
||||
"let"
|
||||
"move"
|
||||
"unsafe"
|
||||
"where"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"enum"
|
||||
"struct"
|
||||
"union"
|
||||
"trait"
|
||||
"type"
|
||||
] @keyword.type
|
||||
|
||||
[
|
||||
"async"
|
||||
"await"
|
||||
"gen"
|
||||
] @keyword.coroutine
|
||||
|
||||
"try" @keyword.exception
|
||||
|
||||
[
|
||||
"ref"
|
||||
"pub"
|
||||
"raw"
|
||||
(mutable_specifier)
|
||||
"const"
|
||||
"static"
|
||||
"dyn"
|
||||
"extern"
|
||||
] @keyword.modifier
|
||||
|
||||
(lifetime
|
||||
"'" @keyword.modifier)
|
||||
|
||||
(lifetime
|
||||
(identifier) @attribute)
|
||||
|
||||
(lifetime
|
||||
(identifier) @attribute.builtin
|
||||
(#any-of? @attribute.builtin "static" "_"))
|
||||
|
||||
"fn" @keyword.function
|
||||
|
||||
[
|
||||
"return"
|
||||
"yield"
|
||||
] @keyword.return
|
||||
|
||||
(type_cast_expression
|
||||
"as" @keyword.operator)
|
||||
|
||||
(qualified_type
|
||||
"as" @keyword.operator)
|
||||
|
||||
(use_list
|
||||
(self) @module)
|
||||
|
||||
(scoped_use_list
|
||||
(self) @module)
|
||||
|
||||
(scoped_identifier
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
(self)
|
||||
] @module)
|
||||
|
||||
(visibility_modifier
|
||||
[
|
||||
(crate)
|
||||
(super)
|
||||
(self)
|
||||
] @module)
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"match"
|
||||
] @keyword.conditional
|
||||
|
||||
[
|
||||
"break"
|
||||
"continue"
|
||||
"in"
|
||||
"loop"
|
||||
"while"
|
||||
] @keyword.repeat
|
||||
|
||||
"for" @keyword
|
||||
|
||||
(for_expression
|
||||
"for" @keyword.repeat)
|
||||
|
||||
; Operators
|
||||
[
|
||||
"!"
|
||||
"!="
|
||||
"%"
|
||||
"%="
|
||||
"&"
|
||||
"&&"
|
||||
"&="
|
||||
"*"
|
||||
"*="
|
||||
"+"
|
||||
"+="
|
||||
"-"
|
||||
"-="
|
||||
".."
|
||||
"..="
|
||||
"..."
|
||||
"/"
|
||||
"/="
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"?"
|
||||
"@"
|
||||
"^"
|
||||
"^="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
] @operator
|
||||
|
||||
(use_wildcard
|
||||
"*" @character.special)
|
||||
|
||||
(remaining_field_pattern
|
||||
".." @character.special)
|
||||
|
||||
(range_pattern
|
||||
[
|
||||
".."
|
||||
"..="
|
||||
"..."
|
||||
] @character.special)
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(closure_parameters
|
||||
"|" @punctuation.bracket)
|
||||
|
||||
(type_arguments
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(type_parameters
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(bracketed_type
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(for_lifetimes
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
"::"
|
||||
";"
|
||||
"->"
|
||||
"=>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(attribute_item
|
||||
"#" @punctuation.special)
|
||||
|
||||
(inner_attribute_item
|
||||
[
|
||||
"!"
|
||||
"#"
|
||||
] @punctuation.special)
|
||||
|
||||
(macro_invocation
|
||||
"!" @function.macro)
|
||||
|
||||
(never_type
|
||||
"!" @type.builtin)
|
||||
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier @keyword.exception
|
||||
"!" @keyword.exception
|
||||
(#eq? @_identifier "panic"))
|
||||
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier @keyword.exception
|
||||
"!" @keyword.exception
|
||||
(#contains? @_identifier "assert"))
|
||||
|
||||
(macro_invocation
|
||||
macro: (identifier) @_identifier @keyword.debug
|
||||
"!" @keyword.debug
|
||||
(#eq? @_identifier "dbg"))
|
||||
|
||||
; Comments
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(outer_doc_comment_marker)
|
||||
(inner_doc_comment_marker)
|
||||
] @comment @spell
|
||||
|
||||
(line_comment
|
||||
(doc_comment)) @comment.documentation
|
||||
|
||||
(block_comment
|
||||
(doc_comment)) @comment.documentation
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex
|
||||
(#any-of? @_regex "Regex" "ByteRegexBuilder")
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp)))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex
|
||||
(#any-of? @_regex "Regex" "ByteRegexBuilder") .)
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp)))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex
|
||||
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp))))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex
|
||||
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @string.regexp))))
|
||||
@@ -0,0 +1,89 @@
|
||||
(macro_invocation
|
||||
macro: [
|
||||
(scoped_identifier
|
||||
name: (_) @_macro_name)
|
||||
(identifier) @_macro_name
|
||||
]
|
||||
(token_tree) @injection.content
|
||||
(#not-any-of? @_macro_name "slint" "html" "json")
|
||||
(#set! injection.language "rust")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(macro_invocation
|
||||
macro: [
|
||||
(scoped_identifier
|
||||
name: (_) @injection.language)
|
||||
(identifier) @injection.language
|
||||
]
|
||||
(token_tree) @injection.content
|
||||
(#any-of? @injection.language "slint" "html" "json")
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.include-children))
|
||||
|
||||
(macro_definition
|
||||
(macro_rule
|
||||
left: (token_tree_pattern) @injection.content
|
||||
(#set! injection.language "rust")))
|
||||
|
||||
(macro_definition
|
||||
(macro_rule
|
||||
right: (token_tree) @injection.content
|
||||
(#set! injection.language "rust")))
|
||||
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex
|
||||
(#any-of? @_regex "Regex" "RegexBuilder")
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
(string_content) @injection.content))
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex
|
||||
(#any-of? @_regex "Regex" "RegexBuilder") .)
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(raw_string_literal
|
||||
(string_content) @injection.content))
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (identifier) @_regex
|
||||
(#any-of? @_regex "RegexSet" "RegexSetBuilder")
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @injection.content)))
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
path: (scoped_identifier
|
||||
(identifier) @_regex
|
||||
(#any-of? @_regex "RegexSet" "RegexSetBuilder") .)
|
||||
name: (identifier) @_new
|
||||
(#eq? @_new "new"))
|
||||
arguments: (arguments
|
||||
(array_expression
|
||||
(raw_string_literal
|
||||
(string_content) @injection.content)))
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
((block_comment) @injection.content
|
||||
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||
(#set! injection.language "re2c"))
|
||||
@@ -0,0 +1,98 @@
|
||||
; Imports
|
||||
(extern_crate_declaration
|
||||
name: (identifier) @local.definition.import)
|
||||
|
||||
(use_declaration
|
||||
argument: (scoped_identifier
|
||||
name: (identifier) @local.definition.import))
|
||||
|
||||
(use_as_clause
|
||||
alias: (identifier) @local.definition.import)
|
||||
|
||||
(use_list
|
||||
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
|
||||
|
||||
; Functions
|
||||
(function_item
|
||||
name: (identifier) @local.definition.function)
|
||||
|
||||
(function_item
|
||||
name: (identifier) @local.definition.method
|
||||
parameters: (parameters
|
||||
(self_parameter)))
|
||||
|
||||
; Variables
|
||||
(parameter
|
||||
pattern: (identifier) @local.definition.var)
|
||||
|
||||
(let_declaration
|
||||
pattern: (identifier) @local.definition.var)
|
||||
|
||||
(const_item
|
||||
name: (identifier) @local.definition.var)
|
||||
|
||||
(tuple_pattern
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(let_condition
|
||||
pattern: (_
|
||||
(identifier) @local.definition.var))
|
||||
|
||||
(tuple_struct_pattern
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(closure_parameters
|
||||
(identifier) @local.definition.var)
|
||||
|
||||
(self_parameter
|
||||
(self) @local.definition.var)
|
||||
|
||||
(for_expression
|
||||
pattern: (identifier) @local.definition.var)
|
||||
|
||||
; Types
|
||||
(struct_item
|
||||
name: (type_identifier) @local.definition.type)
|
||||
|
||||
(enum_item
|
||||
name: (type_identifier) @local.definition.type)
|
||||
|
||||
; Fields
|
||||
(field_declaration
|
||||
name: (field_identifier) @local.definition.field)
|
||||
|
||||
(enum_variant
|
||||
name: (identifier) @local.definition.field)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
||||
((type_identifier) @local.reference
|
||||
(#set! reference.kind "type"))
|
||||
|
||||
((field_identifier) @local.reference
|
||||
(#set! reference.kind "field"))
|
||||
|
||||
; Macros
|
||||
(macro_definition
|
||||
name: (identifier) @local.definition.macro)
|
||||
|
||||
; Module
|
||||
(mod_item
|
||||
name: (identifier) @local.definition.namespace)
|
||||
|
||||
; Scopes
|
||||
[
|
||||
(block)
|
||||
(function_item)
|
||||
(closure_expression)
|
||||
(while_expression)
|
||||
(for_expression)
|
||||
(loop_expression)
|
||||
(if_expression)
|
||||
(match_expression)
|
||||
(match_arm)
|
||||
(struct_item)
|
||||
(enum_item)
|
||||
(impl_item)
|
||||
] @local.scope
|
||||
@@ -0,0 +1,409 @@
|
||||
; functions
|
||||
(function_signature_item) @function.outer
|
||||
|
||||
(function_item) @function.outer
|
||||
|
||||
(function_item
|
||||
body: (block
|
||||
.
|
||||
"{"
|
||||
_+ @function.inner
|
||||
"}"))
|
||||
|
||||
; quantifies as class(es)
|
||||
(struct_item) @class.outer
|
||||
|
||||
(struct_item
|
||||
body: (field_declaration_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
(enum_item) @class.outer
|
||||
|
||||
(enum_item
|
||||
body: (enum_variant_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
(union_item) @class.outer
|
||||
|
||||
(union_item
|
||||
body: (field_declaration_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
(trait_item) @class.outer
|
||||
|
||||
(trait_item
|
||||
body: (declaration_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
(impl_item) @class.outer
|
||||
|
||||
(impl_item
|
||||
body: (declaration_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
(mod_item) @class.outer
|
||||
|
||||
(mod_item
|
||||
body: (declaration_list
|
||||
.
|
||||
"{"
|
||||
_+ @class.inner
|
||||
"}"))
|
||||
|
||||
; conditionals
|
||||
(if_expression
|
||||
alternative: (_
|
||||
(_) @conditional.inner)?) @conditional.outer
|
||||
|
||||
(if_expression
|
||||
alternative: (else_clause
|
||||
(block) @conditional.inner))
|
||||
|
||||
(if_expression
|
||||
condition: (_) @conditional.inner)
|
||||
|
||||
(if_expression
|
||||
consequence: (block) @conditional.inner)
|
||||
|
||||
(match_arm
|
||||
(_)) @conditional.inner
|
||||
|
||||
(match_expression) @conditional.outer
|
||||
|
||||
; loops
|
||||
(loop_expression
|
||||
body: (block
|
||||
.
|
||||
"{"
|
||||
_+ @loop.inner
|
||||
"}")) @loop.outer
|
||||
|
||||
(while_expression
|
||||
body: (block
|
||||
.
|
||||
"{"
|
||||
_+ @loop.inner
|
||||
"}")) @loop.outer
|
||||
|
||||
(for_expression
|
||||
body: (block
|
||||
.
|
||||
"{"
|
||||
_+ @loop.inner
|
||||
"}")) @loop.outer
|
||||
|
||||
; blocks
|
||||
(block
|
||||
(_)* @block.inner) @block.outer
|
||||
|
||||
(unsafe_block
|
||||
(_)* @block.inner) @block.outer
|
||||
|
||||
; calls
|
||||
(macro_invocation) @call.outer
|
||||
|
||||
(macro_invocation
|
||||
(token_tree
|
||||
.
|
||||
"("
|
||||
_+ @call.inner
|
||||
")"))
|
||||
|
||||
(call_expression) @call.outer
|
||||
|
||||
(call_expression
|
||||
arguments: (arguments
|
||||
.
|
||||
"("
|
||||
_+ @call.inner
|
||||
")"))
|
||||
|
||||
; returns
|
||||
(return_expression
|
||||
(_)? @return.inner) @return.outer
|
||||
|
||||
; statements
|
||||
(block
|
||||
(_) @statement.outer)
|
||||
|
||||
; comments
|
||||
(line_comment) @comment.outer
|
||||
|
||||
(block_comment) @comment.outer
|
||||
|
||||
; parameter
|
||||
(parameters
|
||||
"," @parameter.outer
|
||||
.
|
||||
[
|
||||
(self_parameter)
|
||||
(parameter)
|
||||
(type_identifier)
|
||||
] @parameter.inner @parameter.outer)
|
||||
|
||||
(parameters
|
||||
.
|
||||
[
|
||||
(self_parameter)
|
||||
(parameter)
|
||||
(type_identifier)
|
||||
] @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(parameters
|
||||
[
|
||||
(self_parameter)
|
||||
(parameter)
|
||||
(type_identifier)
|
||||
] @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(type_parameters
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(type_parameters
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(type_parameters
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(tuple_pattern
|
||||
"," @parameter.outer
|
||||
.
|
||||
(identifier) @parameter.inner @parameter.outer)
|
||||
|
||||
(tuple_pattern
|
||||
.
|
||||
(identifier) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(tuple_pattern
|
||||
(identifier) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(tuple_struct_pattern
|
||||
"," @parameter.outer
|
||||
.
|
||||
(identifier) @parameter.inner @parameter.outer)
|
||||
|
||||
(tuple_struct_pattern
|
||||
.
|
||||
(identifier) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(tuple_struct_pattern
|
||||
(identifier) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(tuple_expression
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(tuple_expression
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(tuple_expression
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(tuple_type
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(tuple_type
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(tuple_type
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(struct_item
|
||||
body: (field_declaration_list
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer))
|
||||
|
||||
(struct_item
|
||||
body: (field_declaration_list
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer))
|
||||
|
||||
; last element, with trailing comma
|
||||
(struct_item
|
||||
body: (field_declaration_list
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .))
|
||||
|
||||
(struct_expression
|
||||
body: (field_initializer_list
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer))
|
||||
|
||||
(struct_expression
|
||||
body: (field_initializer_list
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer))
|
||||
|
||||
; last element, with trailing comma
|
||||
(struct_expression
|
||||
body: (field_initializer_list
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .))
|
||||
|
||||
(closure_parameters
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(closure_parameters
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(closure_parameters
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(arguments
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(arguments
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(arguments
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(type_arguments
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(type_arguments
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(type_arguments
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(token_tree
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer)
|
||||
|
||||
(token_tree
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer)
|
||||
|
||||
; last element, with trailing comma
|
||||
(token_tree
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .)
|
||||
|
||||
(scoped_use_list
|
||||
list: (use_list
|
||||
"," @parameter.outer
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer))
|
||||
|
||||
(scoped_use_list
|
||||
list: (use_list
|
||||
.
|
||||
(_) @parameter.inner @parameter.outer
|
||||
.
|
||||
","? @parameter.outer))
|
||||
|
||||
; last element, with trailing comma
|
||||
(scoped_use_list
|
||||
list: (use_list
|
||||
(_) @parameter.outer
|
||||
.
|
||||
"," @parameter.outer .))
|
||||
|
||||
[
|
||||
(integer_literal)
|
||||
(float_literal)
|
||||
] @number.inner
|
||||
|
||||
(let_declaration
|
||||
pattern: (_) @assignment.lhs
|
||||
value: (_) @assignment.inner @assignment.rhs) @assignment.outer
|
||||
|
||||
(let_declaration
|
||||
pattern: (_) @assignment.inner)
|
||||
|
||||
(assignment_expression
|
||||
left: (_) @assignment.lhs
|
||||
right: (_) @assignment.inner @assignment.rhs) @assignment.outer
|
||||
|
||||
(assignment_expression
|
||||
left: (_) @assignment.inner)
|
||||
Reference in New Issue
Block a user