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