diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 9117de8e..cacc801a 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -155,6 +155,8 @@ define-command -hidden rust-indent-on-new-line %~ # indent after non-empty lines not starting with operator and not ending with , or ; # XXX simplify this into a single without s try %< execute-keys -draft k s [^\h].+ \A[-+*/&|^})#] [,](\h*/[/*].*|)$ j > + # addition to previous case where it starts with ) and ends with { + try %< execute-keys -draft k s [^\h].+ \A\) \{$ 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..c1121942 100644 --- a/test/indent/rust/line-start-with-operator/in +++ b/test/indent/rust/line-start-with-operator/in @@ -26,3 +26,6 @@ #[derive(Debug)]%( ) + fn foo( + ) -> {%( ) + diff --git a/test/indent/rust/line-start-with-operator/out b/test/indent/rust/line-start-with-operator/out index f270d0d9..070561f5 100644 --- a/test/indent/rust/line-start-with-operator/out +++ b/test/indent/rust/line-start-with-operator/out @@ -40,3 +40,7 @@ #[derive(Debug)] bar + fn foo( + ) -> { + bar +