diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 7e7248b33..be440f75f 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -74,15 +74,18 @@ define-command -hidden rust-trim-indent %{ define-command -hidden rust-indent-on-new-line %~ evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P } - # preserve previous line indent - try %{ execute-keys -draft K } + try %{ + execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P + } catch %| + # preserve previous line indent + try %{ execute-keys -draft K } + # indent after lines ending with { or ( + try %[ execute-keys -draft k [{(]\h*$ j ] + # 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 > + | # filter previous line try %{ execute-keys -draft k : rust-trim-indent } - # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] - # 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 > > ~