diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index d4016fd4..1267f52a 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -98,7 +98,7 @@ define-command -hidden rust-trim-indent %{ } define-command -hidden rust-indent-on-new-line %~ - evaluate-commands -draft -itersel %< + evaluate-commands -draft -itersel %@ try %{ try %[ # line comment evaluate-commands -draft -save-regs '/"' %[ @@ -159,6 +159,8 @@ define-command -hidden rust-indent-on-new-line %~ try %< execute-keys -draft k \{$ j > # dedent after lines starting with . and ending with } or ) or , or ; or .await try %_ execute-keys -draft k ^\h*\. ([}),]|\.await)\h*$ j _ + # dedent after lines ending with " => {}" - part of empty match + try %# execute-keys -draft k \ =>\ \{\}\h*$ j # # align to opening curly brace or paren when newline is inserted before a single closing try %< execute-keys -draft ^\h*[)}] h m 1 > # todo dedent additional unmatched parenthesis @@ -169,7 +171,7 @@ define-command -hidden rust-indent-on-new-line %~ ` # filter previous line try %{ execute-keys -draft k : rust-trim-indent } - > + @ ~ define-command -hidden rust-indent-on-opening-curly-brace %[ diff --git a/test/indent/rust/empty-match/cmd b/test/indent/rust/empty-match/cmd new file mode 100644 index 00000000..8682d51e --- /dev/null +++ b/test/indent/rust/empty-match/cmd @@ -0,0 +1 @@ +cbar diff --git a/test/indent/rust/empty-match/in b/test/indent/rust/empty-match/in new file mode 100644 index 00000000..a6fe6584 --- /dev/null +++ b/test/indent/rust/empty-match/in @@ -0,0 +1,3 @@ +match a { + Some(a) => {}%( ) + diff --git a/test/indent/rust/empty-match/out b/test/indent/rust/empty-match/out new file mode 100644 index 00000000..8cea9300 --- /dev/null +++ b/test/indent/rust/empty-match/out @@ -0,0 +1,4 @@ +match a { + Some(a) => {} + bar + diff --git a/test/indent/rust/empty-match/rc b/test/indent/rust/empty-match/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/indent/rust/empty-match/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust