Dedent rust await function with ?
This commit is contained in:
parent
049591f6b4
commit
4e594e034a
|
@ -157,8 +157,8 @@ define-command -hidden rust-indent-on-new-line %~
|
|||
try %< execute-keys -draft k <a-x> s [^\h].+ <ret> <a-K> \A[-+*/&|^})<gt><lt>#] <ret> <a-K> [,<semicolon>{](\h*/[/*].*|)$ <ret> j <a-gt> >
|
||||
# indent after lines ending with {
|
||||
try %< execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> >
|
||||
# dedent after lines starting with . and ending with } or ) or , or ; or .await
|
||||
try %_ execute-keys -draft k <a-x> <a-k> ^\h*\. <ret> <a-k>([}),<semicolon>]|\.await)\h*$ <ret> j <a-lt> _
|
||||
# dedent after lines starting with . and ending with } or ) or , or ; or .await (} or ) or .await maybe with ?)
|
||||
try %_ execute-keys -draft k <a-x> <a-k> ^\h*\. <ret> <a-k> ([,<semicolon>]|(([})]|\.await)\?*))\h*$ <ret> j <a-lt> _
|
||||
# dedent after lines ending with " => {}" - part of empty match
|
||||
try %# execute-keys -draft k <a-x> <a-k> \ =>\ \{\}\h*$ <ret> j <a-lt> #
|
||||
# align to opening curly brace or paren when newline is inserted before a single closing
|
||||
|
|
|
@ -3,3 +3,6 @@
|
|||
|
||||
foo().await%( )
|
||||
|
||||
foo()
|
||||
.await?%( )
|
||||
|
||||
|
|
|
@ -5,3 +5,7 @@
|
|||
foo().await
|
||||
bar
|
||||
|
||||
foo()
|
||||
.await?
|
||||
bar
|
||||
|
||||
|
|
|
@ -11,5 +11,9 @@ fn foo() -> i32 {%( )bar()
|
|||
fn foo() -> i32 {
|
||||
bar()%( )}
|
||||
|
||||
fn foo() -> i32 {
|
||||
bar()%( )}
|
||||
fn foo() -> i32 {
|
||||
bar()%( )}
|
||||
|
||||
fn foo() -> i32 {
|
||||
bar()?%( )}
|
||||
|
||||
|
|
|
@ -16,6 +16,11 @@ fn foo() -> i32 {
|
|||
bar()
|
||||
}
|
||||
|
||||
fn foo() -> i32 {
|
||||
bar()
|
||||
}
|
||||
fn foo() -> i32 {
|
||||
bar()
|
||||
}
|
||||
|
||||
fn foo() -> i32 {
|
||||
bar()?
|
||||
}
|
||||
|
||||
|
|
|
@ -27,5 +27,8 @@
|
|||
{(
|
||||
bar()%( ))}
|
||||
|
||||
{(
|
||||
bar()?%( ))}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
bar()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()?
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
||||
|
|
Loading…
Reference in New Issue
Block a user