diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 9d8709591..14071511e 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -102,6 +102,8 @@ define-command -hidden rust-indent-on-opening-curly-brace %[ evaluate-commands -draft -itersel %_ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] + # dedent standalone { after impl or fn block without any { in between + try %< execute-keys -draft hh impl|fn|struct|enum|union \{ ll ^\h*\{$ > _ ] diff --git a/test/indent/rust/on-open-paren/cmd b/test/indent/rust/on-open-paren/cmd new file mode 100644 index 000000000..723e4fa37 --- /dev/null +++ b/test/indent/rust/on-open-paren/cmd @@ -0,0 +1 @@ +c{ diff --git a/test/indent/rust/on-open-paren/in b/test/indent/rust/on-open-paren/in new file mode 100644 index 000000000..1ca71d623 --- /dev/null +++ b/test/indent/rust/on-open-paren/in @@ -0,0 +1,35 @@ + fn foo(x: T) + where + T: Debug + %( ) + + fn foo(x: T) where T: Debug %( ) + + impl X for T + where + T: Debug + %( ) + + impl X for T where T: Debug %( ) + + struct X + where + T: Debug + %( ) + + struct X where T: Debug %( ) + + enum X + where + T: Debug + %( ) + + enum X where T: Debug %( ) + + union X + where + T: Debug + %( ) + + union X where T: Debug %( ) + diff --git a/test/indent/rust/on-open-paren/out b/test/indent/rust/on-open-paren/out new file mode 100644 index 000000000..de125ea77 --- /dev/null +++ b/test/indent/rust/on-open-paren/out @@ -0,0 +1,35 @@ + fn foo(x: T) + where + T: Debug + { + + fn foo(x: T) where T: Debug { + + impl X for T + where + T: Debug + { + + impl X for T where T: Debug { + + struct X + where + T: Debug + { + + struct X where T: Debug { + + enum X + where + T: Debug + { + + enum X where T: Debug { + + union X + where + T: Debug + { + + union X where T: Debug { + diff --git a/test/indent/rust/on-open-paren/rc b/test/indent/rust/on-open-paren/rc new file mode 100644 index 000000000..64064c258 --- /dev/null +++ b/test/indent/rust/on-open-paren/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust