Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/rust/indents.scm')
| -rw-r--r-- | runtime/queries/rust/indents.scm | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/runtime/queries/rust/indents.scm b/runtime/queries/rust/indents.scm index af2e05e3..5c2c70d0 100644 --- a/runtime/queries/rust/indents.scm +++ b/runtime/queries/rust/indents.scm @@ -14,11 +14,9 @@ (call_expression) (binary_expression) (field_expression) - (await_expression) (tuple_expression) (array_expression) (where_clause) - (type_cast_expression) (token_tree) (macro_definition) @@ -50,16 +48,10 @@ (#set! "scope" "all") ) (let_declaration - "let" @expr-start - value: (_) @indent - alternative: (_)? @indent - (#not-same-line? @indent @expr-start) - (#set! "scope" "all") -) -(let_condition . (_) @expr-start value: (_) @indent + alternative: (_)? @indent (#not-same-line? @indent @expr-start) (#set! "scope" "all") ) @@ -77,22 +69,6 @@ (#not-same-line? @indent @expr-start) (#set! "scope" "all") ) -(field_pattern - . - (_) @expr-start - pattern: (_) @indent - (#not-same-line? @indent @expr-start) - (#set! "scope" "all") -) -; Indent type aliases that span multiple lines, similar to -; regular assignment expressions -(type_item - . - (_) @expr-start - type: (_) @indent - (#not-same-line? @indent @expr-start) - (#set! "scope" "all") -) ; Some field expressions where the left part is a multiline expression are not ; indented by cargo fmt. @@ -101,48 +77,5 @@ (field_expression value: (_) @val "." @outdent - ; Check whether the first line ends with `(`, `{` or `[` (up to whitespace). - (#match? @val "(\\A[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r))") -) -; Same as above, but with an additional `call_expression`. This is required since otherwise -; the arguments of the function call won't be outdented. -(call_expression - function: (field_expression - value: (_) @val - "." @outdent - (#match? @val "(\\A[^\\n\\r]+(\\(|\\{|\\[)[\\t ]*(\\n|\\r))") - ) - arguments: (_) @outdent -) - - -; Indent if guards in patterns. -; Since the tree-sitter grammar doesn't create a node for the if expression, -; it's not possible to do this correctly in all cases. Indenting the tail of the -; whole pattern whenever it contains an `if` only fails if the `if` appears after -; the second line of the pattern (which should only rarely be the case) -(match_pattern - . - (_) @expr-start - "if" @pattern-guard - (#not-same-line? @expr-start @pattern-guard) -) @indent - -; Align closure parameters if they span more than one line -(closure_parameters - "|" - . - (_) @anchor - (_) @expr-end - . - (#not-same-line? @anchor @expr-end) -) @align - -(for_expression - "in" @in - . - (_) @indent - (#not-same-line? @in @indent) - (#set! "scope" "all") + (#match? @val "(\\A[^\\n\\r]+\\([\\t ]*(\\n|\\r).*)|(\\A[^\\n\\r]*\\{[\\t ]*(\\n|\\r))") ) - |