1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 20:41:49 +03:00

Dedent rust await function with ?

This commit is contained in:
Ivan Tham 2021-02-17 01:16:58 +08:00
parent 049591f6b4
commit 4e594e034a
7 changed files with 30 additions and 7 deletions

View File

@ -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

View File

@ -3,3 +3,6 @@
foo().await%( )
foo()
.await?%( )

View File

@ -5,3 +5,7 @@
foo().await
bar
foo()
.await?
bar

View File

@ -11,5 +11,9 @@ fn foo() -> i32 {%( )bar()
fn foo() -> i32 {
bar()%( )}
fn foo() -> i32 {
bar()%( )}
fn foo() -> i32 {
bar()%( )}
fn foo() -> i32 {
bar()?%( )}

View File

@ -16,6 +16,11 @@ fn foo() -> i32 {
bar()
}
fn foo() -> i32 {
bar()
}
fn foo() -> i32 {
bar()
}
fn foo() -> i32 {
bar()?
}

View File

@ -27,5 +27,8 @@
{(
bar()%( ))}
{(
bar()?%( ))}
{(
bar()%( ))}

View File

@ -38,6 +38,10 @@
bar()
)}
{(
bar()?
)}
{(
bar()
)}