diff options
| author | Phạm Huy Hoàng <hoangtun0810@gmail.com> | 2024-03-21 20:44:35 +0900 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-03-21 15:51:26 +0100 |
| commit | 722617e6726c1508adadf83d531f54987c703be0 (patch) | |
| tree | 951cdcf1cd2571647a3e5afdc11d6fae5e88b630 /queries/rust | |
| parent | feat(rust): improve indents (diff) | |
| download | nvim-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.scm | 49 | ||||
| -rw-r--r-- | queries/rust/indents.scm | 35 | ||||
| -rw-r--r-- | queries/rust/injections.scm | 96 | ||||
| -rw-r--r-- | queries/rust/locals.scm | 15 |
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) |
