diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 9117de8e..8588789e 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -152,9 +152,11 @@ define-command -hidden rust-indent-on-new-line %~ try %{ execute-keys -draft K } # indent after lines ending with [{(].+ and move first parameter to own line try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > - # 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 without s - try %< execute-keys -draft k s [^\h].+ \A[-+*/&|^})#] [,](\h*/[/*].*|)$ j > + try %< execute-keys -draft k s [^\h].+ \A[-+*/&|^})#] [,{](\h*/[/*].*|)$ j > + # indent after lines ending with { + try %< execute-keys -draft k \{$ j > # dedent after lines starting with . and ending with } or ) or , or ; try %_ execute-keys -draft k ^\h*\..*[}),]\h*$ j _ # align to opening curly brace or paren when newline is inserted before a single closing diff --git a/test/indent/rust/line-start-with-operator/in b/test/indent/rust/line-start-with-operator/in index 063f771e..72d6b5c7 100644 --- a/test/indent/rust/line-start-with-operator/in +++ b/test/indent/rust/line-start-with-operator/in @@ -26,3 +26,8 @@ #[derive(Debug)]%( ) + fn foo( + ) -> {%( ) + + } else {%( ) + diff --git a/test/indent/rust/line-start-with-operator/out b/test/indent/rust/line-start-with-operator/out index f270d0d9..0ded93f9 100644 --- a/test/indent/rust/line-start-with-operator/out +++ b/test/indent/rust/line-start-with-operator/out @@ -40,3 +40,10 @@ #[derive(Debug)] bar + fn foo( + ) -> { + bar + + } else { + bar +