From df68a77ed2612ec1d73c7de767fa698a98302c61 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 28 Sep 2020 00:03:53 +0800 Subject: [PATCH] Rust reindent where to match block --- rc/filetype/rust.kak | 2 ++ test/indent/rust/before-where/cmd | 1 + test/indent/rust/before-where/in | 2 ++ test/indent/rust/before-where/out | 4 ++++ test/indent/rust/before-where/rc | 3 +++ 5 files changed, 12 insertions(+) create mode 100644 test/indent/rust/before-where/cmd create mode 100644 test/indent/rust/before-where/in create mode 100644 test/indent/rust/before-where/out create mode 100644 test/indent/rust/before-where/rc diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 51b5ef67..b1024424 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -146,6 +146,8 @@ define-command -hidden rust-indent-on-new-line %~ execute-keys K1s^[^*]*(\*)& ] } catch %` + # re-indent previous line if it starts with where to match previous block + try %+ execute-keys -draft k ^\h*where\b hh impl|fn|struct|enum|union 1 + # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with [{(].+ and move first parameter to own line diff --git a/test/indent/rust/before-where/cmd b/test/indent/rust/before-where/cmd new file mode 100644 index 00000000..fe3daa48 --- /dev/null +++ b/test/indent/rust/before-where/cmd @@ -0,0 +1 @@ +cwherebar diff --git a/test/indent/rust/before-where/in b/test/indent/rust/before-where/in new file mode 100644 index 00000000..0c1161c1 --- /dev/null +++ b/test/indent/rust/before-where/in @@ -0,0 +1,2 @@ + impl X for T%( ) + diff --git a/test/indent/rust/before-where/out b/test/indent/rust/before-where/out new file mode 100644 index 00000000..caa373e4 --- /dev/null +++ b/test/indent/rust/before-where/out @@ -0,0 +1,4 @@ + impl X for T + where + bar + diff --git a/test/indent/rust/before-where/rc b/test/indent/rust/before-where/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/indent/rust/before-where/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust