From c148fdbe9ab9ef84dd2366a83788b9f4aede4745 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 4 Oct 2020 23:40:47 +0800 Subject: [PATCH] Rust always indent after { --- rc/filetype/rust.kak | 8 ++++---- test/indent/rust/line-start-with-operator/in | 2 ++ test/indent/rust/line-start-with-operator/out | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) 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 +