Dedent rust empty match

This commit is contained in:
Ivan Tham 2021-02-17 01:15:32 +08:00
parent 978dfe4bdf
commit 049591f6b4
5 changed files with 15 additions and 2 deletions

View File

@ -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 <a-x> <a-k> \{$ <ret> j <a-gt> >
# dedent after lines starting with . and ending with } or ) or , or ; or .await
try %_ execute-keys -draft k <a-x> <a-k> ^\h*\. <ret> <a-k>([}),<semicolon>]|\.await)\h*$ <ret> j <a-lt> _
# dedent after lines ending with " => {}" - part of empty match
try %# execute-keys -draft k <a-x> <a-k> \ =>\ \{\}\h*$ <ret> j <a-lt> #
# align to opening curly brace or paren when newline is inserted before a single closing
try %< execute-keys -draft <a-h> <a-k> ^\h*[)}] <ret> h m <a-S> 1<a-&> >
# 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 <ret> }
>
@
~
define-command -hidden rust-indent-on-opening-curly-brace %[

View File

@ -0,0 +1 @@
c<ret>bar<esc>

View File

@ -0,0 +1,3 @@
match a {
Some(a) => {}%( )

View File

@ -0,0 +1,4 @@
match a {
Some(a) => {}
bar

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust