aboutsummaryrefslogtreecommitdiffstats
path: root/queries/rust
diff options
context:
space:
mode:
authorPhạm Huy Hoàng <hoangtun0810@gmail.com>2024-03-21 20:44:35 +0900
committerChristian Clason <c.clason@uni-graz.at>2024-03-21 15:51:26 +0100
commit722617e6726c1508adadf83d531f54987c703be0 (patch)
tree951cdcf1cd2571647a3e5afdc11d6fae5e88b630 /queries/rust
parentfeat(rust): improve indents (diff)
downloadnvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.gz
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.bz2
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.lz
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.xz
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.zst
nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.zip
refactor(format): drop extra indentation for field
Diffstat (limited to 'queries/rust')
-rw-r--r--queries/rust/highlights.scm49
-rw-r--r--queries/rust/indents.scm35
-rw-r--r--queries/rust/injections.scm96
-rw-r--r--queries/rust/locals.scm15
4 files changed, 82 insertions, 113 deletions
diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm
index 332ee12fa..4b83014a0 100644
--- a/queries/rust/highlights.scm
+++ b/queries/rust/highlights.scm
@@ -55,27 +55,23 @@
function: (identifier) @function.call)
(call_expression
- function:
- (scoped_identifier
- (identifier) @function.call .))
+ function: (scoped_identifier
+ (identifier) @function.call .))
(call_expression
- function:
- (field_expression
- field: (field_identifier) @function.call))
+ function: (field_expression
+ field: (field_identifier) @function.call))
(generic_function
function: (identifier) @function.call)
(generic_function
- function:
- (scoped_identifier
- name: (identifier) @function.call))
+ function: (scoped_identifier
+ name: (identifier) @function.call))
(generic_function
- function:
- (field_expression
- field: (field_identifier) @function.call))
+ function: (field_expression
+ field: (field_identifier) @function.call))
; Assume other uppercase names are enum constructors
((field_identifier) @constant
@@ -136,9 +132,8 @@
path: (identifier) @module)
(scoped_use_list
- path:
- (scoped_identifier
- (identifier) @module))
+ path: (scoped_identifier
+ (identifier) @module))
(use_list
(scoped_identifier
@@ -156,24 +151,21 @@
; Correct enum constructors
(call_expression
- function:
- (scoped_identifier
- "::"
- name: (identifier) @constant)
+ 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))
+ pattern: (match_pattern
+ (identifier) @constant))
(#lua-match? @constant "^[A-Z]"))
((match_arm
- pattern:
- (match_pattern
- (scoped_identifier
- name: (identifier) @constant)))
+ pattern: (match_pattern
+ (scoped_identifier
+ name: (identifier) @constant)))
(#lua-match? @constant "^[A-Z]"))
((identifier) @constant.builtin
@@ -210,9 +202,8 @@
macro: (identifier) @function.macro)
(macro_invocation
- macro:
- (scoped_identifier
- (identifier) @function.macro .))
+ macro: (scoped_identifier
+ (identifier) @function.macro .))
; Literals
[
diff --git a/queries/rust/indents.scm b/queries/rust/indents.scm
index c4737ab80..d56a246c6 100644
--- a/queries/rust/indents.scm
+++ b/queries/rust/indents.scm
@@ -55,42 +55,35 @@
"}" @indent.end)
(enum_item
- body:
- (enum_variant_list
- "}" @indent.end))
+ body: (enum_variant_list
+ "}" @indent.end))
(impl_item
- body:
- (declaration_list
- "}" @indent.end))
+ body: (declaration_list
+ "}" @indent.end))
(match_expression
- body:
- (match_block
- "}" @indent.end))
+ body: (match_block
+ "}" @indent.end))
(mod_item
- body:
- (declaration_list
- "}" @indent.end))
+ body: (declaration_list
+ "}" @indent.end))
(struct_item
- body:
- (field_declaration_list
- "}" @indent.end))
+ body: (field_declaration_list
+ "}" @indent.end))
(struct_expression
- body:
- (field_initializer_list
- "}" @indent.end))
+ body: (field_initializer_list
+ "}" @indent.end))
(struct_pattern
"}" @indent.end)
(trait_item
- body:
- (declaration_list
- "}" @indent.end))
+ body: (declaration_list
+ "}" @indent.end))
(impl_item
(where_clause) @indent.dedent)
diff --git a/queries/rust/injections.scm b/queries/rust/injections.scm
index 629f707c7..c8c360199 100644
--- a/queries/rust/injections.scm
+++ b/queries/rust/injections.scm
@@ -1,22 +1,20 @@
(macro_invocation
- macro:
- [
- (scoped_identifier
- name: (_) @_macro_name)
- (identifier) @_macro_name
- ]
+ macro: [
+ (scoped_identifier
+ name: (_) @_macro_name)
+ (identifier) @_macro_name
+ ]
(token_tree) @injection.content
(#not-eq? @_macro_name "slint")
(#set! injection.language "rust")
(#set! injection.include-children))
(macro_invocation
- macro:
- [
- (scoped_identifier
- name: (_) @_macro_name)
- (identifier) @_macro_name
- ]
+ macro: [
+ (scoped_identifier
+ name: (_) @_macro_name)
+ (identifier) @_macro_name
+ ]
(token_tree) @injection.content
(#eq? @_macro_name "slint")
(#offset! @injection.content 0 1 0 -1)
@@ -45,57 +43,47 @@
(#any-of? @injection.language "html" "json"))
(call_expression
- function:
- (scoped_identifier
- path: (identifier) @_regex
- (#any-of? @_regex "Regex" "ByteRegexBuilder")
- name: (identifier) @_new
- (#eq? @_new "new"))
- arguments:
- (arguments
- (raw_string_literal) @injection.content)
+ function: (scoped_identifier
+ path: (identifier) @_regex
+ (#any-of? @_regex "Regex" "ByteRegexBuilder")
+ name: (identifier) @_new
+ (#eq? @_new "new"))
+ arguments: (arguments
+ (raw_string_literal) @injection.content)
(#set! injection.language "regex"))
(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) @injection.content)
+ function: (scoped_identifier
+ path: (scoped_identifier
+ (identifier) @_regex
+ (#any-of? @_regex "Regex" "ByteRegexBuilder") .)
+ name: (identifier) @_new
+ (#eq? @_new "new"))
+ arguments: (arguments
+ (raw_string_literal) @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) @injection.content))
+ function: (scoped_identifier
+ path: (identifier) @_regex
+ (#any-of? @_regex "RegexSet" "RegexSetBuilder")
+ name: (identifier) @_new
+ (#eq? @_new "new"))
+ arguments: (arguments
+ (array_expression
+ (raw_string_literal) @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) @injection.content))
+ 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) @injection.content))
(#set! injection.language "regex"))
((block_comment) @injection.content
diff --git a/queries/rust/locals.scm b/queries/rust/locals.scm
index bba614536..2b1469bf6 100644
--- a/queries/rust/locals.scm
+++ b/queries/rust/locals.scm
@@ -3,9 +3,8 @@
name: (identifier) @local.definition.import)
(use_declaration
- argument:
- (scoped_identifier
- name: (identifier) @local.definition.import))
+ argument: (scoped_identifier
+ name: (identifier) @local.definition.import))
(use_as_clause
alias: (identifier) @local.definition.import)
@@ -19,9 +18,8 @@
(function_item
name: (identifier) @local.definition.method
- parameters:
- (parameters
- (self_parameter)))
+ parameters: (parameters
+ (self_parameter)))
; Variables
(parameter
@@ -37,9 +35,8 @@
(identifier) @local.definition.var)
(let_condition
- pattern:
- (_
- (identifier) @local.definition.var))
+ pattern: (_
+ (identifier) @local.definition.var))
(tuple_struct_pattern
(identifier) @local.definition.var)