From b1beea86381ae61a2e286a28901b0b563c15ee15 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 31 May 2020 18:13:04 +0800 Subject: [PATCH] Rust indent after standalone where --- rc/filetype/rust.kak | 2 ++ test/indent/rust/after-where/cmd | 1 + test/indent/rust/after-where/in | 5 +++++ test/indent/rust/after-where/out | 7 +++++++ test/indent/rust/after-where/rc | 3 +++ 5 files changed, 18 insertions(+) create mode 100644 test/indent/rust/after-where/cmd create mode 100644 test/indent/rust/after-where/in create mode 100644 test/indent/rust/after-where/out create mode 100644 test/indent/rust/after-where/rc diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 5dca28a2..9d870959 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -83,6 +83,8 @@ define-command -hidden rust-indent-on-new-line %~ try %[ execute-keys -draft k [{(]\h*$ j ] # 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 lines with a standalone where + try %+ execute-keys -draft k ^\h*where\h*$ j + # dedent after lines starting with . and ending with , or ; try %_ execute-keys -draft k ^\h*\..*[,]\h*$ j _ # todo dedent additional unmatched parenthesis diff --git a/test/indent/rust/after-where/cmd b/test/indent/rust/after-where/cmd new file mode 100644 index 00000000..8682d51e --- /dev/null +++ b/test/indent/rust/after-where/cmd @@ -0,0 +1 @@ +cbar diff --git a/test/indent/rust/after-where/in b/test/indent/rust/after-where/in new file mode 100644 index 00000000..412f13d3 --- /dev/null +++ b/test/indent/rust/after-where/in @@ -0,0 +1,5 @@ + impl X for T where%( ) + + impl X for T + where%( ) + diff --git a/test/indent/rust/after-where/out b/test/indent/rust/after-where/out new file mode 100644 index 00000000..3cc8383e --- /dev/null +++ b/test/indent/rust/after-where/out @@ -0,0 +1,7 @@ + impl X for T where + bar + + impl X for T + where + bar + diff --git a/test/indent/rust/after-where/rc b/test/indent/rust/after-where/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/indent/rust/after-where/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust