diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index cacc801a..8588789e 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -152,11 +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 > - # addition to previous case where it starts with ) and ends with { - try %< execute-keys -draft k s [^\h].+ \A\) \{$ 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 c1121942..72d6b5c7 100644 --- a/test/indent/rust/line-start-with-operator/in +++ b/test/indent/rust/line-start-with-operator/in @@ -29,3 +29,5 @@ fn foo( ) -> {%( ) + } else {%( ) + diff --git a/test/indent/rust/line-start-with-operator/out b/test/indent/rust/line-start-with-operator/out index 070561f5..0ded93f9 100644 --- a/test/indent/rust/line-start-with-operator/out +++ b/test/indent/rust/line-start-with-operator/out @@ -44,3 +44,6 @@ ) -> { bar + } else { + bar +