|
|
|
@ -14,9 +14,11 @@
|
|
|
|
|
(call_expression)
|
|
|
|
|
(binary_expression)
|
|
|
|
|
(field_expression)
|
|
|
|
|
(await_expression)
|
|
|
|
|
(tuple_expression)
|
|
|
|
|
(array_expression)
|
|
|
|
|
(where_clause)
|
|
|
|
|
(type_cast_expression)
|
|
|
|
|
|
|
|
|
|
(token_tree)
|
|
|
|
|
(macro_definition)
|
|
|
|
@ -48,10 +50,16 @@
|
|
|
|
|
(#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")
|
|
|
|
|
)
|
|
|
|
@ -69,6 +77,22 @@
|
|
|
|
|
(#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.
|
|
|
|
@ -77,5 +101,48 @@
|
|
|
|
|
(field_expression
|
|
|
|
|
value: (_) @val
|
|
|
|
|
"." @outdent
|
|
|
|
|
(#match? @val "(\\A[^\\n\\r]+\\([\\t ]*(\\n|\\r).*)|(\\A[^\\n\\r]*\\{[\\t ]*(\\n|\\r))")
|
|
|
|
|
; 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")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|