Rust dedent after .await

This commit is contained in:
Ivan Tham 2020-12-17 20:07:44 +08:00
parent ffbdcaa95c
commit 1965b909e1
5 changed files with 18 additions and 2 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 ;
try %_ execute-keys -draft k <a-x> <a-k> ^\h*\..*[}),<semicolon>]\h*$ <ret> j <a-lt> _
# 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> _
# align to opening curly brace or paren when newline is inserted before a single closing
try %< execute-keys -draft <a-h> <a-k> ^\h*[)}] <ret> h m <a-S> 1<a-&> >
# todo dedent additional unmatched parenthesis

View File

@ -0,0 +1 @@
c<ret>bar<esc>

View File

@ -0,0 +1,5 @@
foo()
.await%( )
foo().await%( )

View File

@ -0,0 +1,7 @@
foo()
.await
bar
foo().await
bar

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust