From 12cafe3ed4dbc6d16fb7e54d07d6941985631942 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 31 May 2020 19:19:09 +0800 Subject: [PATCH] Rust dedent { after where clause --- rc/filetype/rust.kak | 2 ++ test/indent/rust/on-open-paren/cmd | 1 + test/indent/rust/on-open-paren/in | 35 ++++++++++++++++++++++++++++++ test/indent/rust/on-open-paren/out | 35 ++++++++++++++++++++++++++++++ test/indent/rust/on-open-paren/rc | 3 +++ 5 files changed, 76 insertions(+) create mode 100644 test/indent/rust/on-open-paren/cmd create mode 100644 test/indent/rust/on-open-paren/in create mode 100644 test/indent/rust/on-open-paren/out create mode 100644 test/indent/rust/on-open-paren/rc diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 9d870959..14071511 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 00000000..723e4fa3 --- /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 00000000..1ca71d62 --- /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 00000000..de125ea7 --- /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 00000000..64064c25 --- /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