Merge remote-tracking branch 'pickfire/indent-rust' into master

This commit is contained in:
Maxime Coste 2020-10-08 19:39:03 +11:00
commit 1635ddab78
3 changed files with 16 additions and 2 deletions

View File

@ -152,9 +152,11 @@ define-command -hidden rust-indent-on-new-line %~
try %{ execute-keys -draft <semicolon> K <a-&> }
# indent after lines ending with [{(].+ and move first parameter to own line
try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]+\n[^\n]*\n?\z <ret> L i<ret><esc> <gt> <a-S> <a-&> >
# indent after non-empty lines not starting with operator and not ending with , or ;
# indent after non-empty lines not starting with operator and not ending with , or ; or {
# XXX simplify this into a single <a-k> without s
try %< execute-keys -draft k <a-x> s [^\h].+ <ret> <a-K> \A[-+*/&|^})<gt><lt>#] <ret> <a-K> [,<semicolon>](\h*/[/*].*|)$ <ret> j <a-gt> >
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> _
# align to opening curly brace or paren when newline is inserted before a single closing

View File

@ -26,3 +26,8 @@
#[derive(Debug)]%( )
fn foo(
) -> {%( )
} else {%( )

View File

@ -40,3 +40,10 @@
#[derive(Debug)]
bar
fn foo(
) -> {
bar
} else {
bar