Block indent on newline when previous line is '(stuff' and move 'stuff' to own line
Also, align closing paren on own line with opening paren
This commit is contained in:
parent
4b98b89437
commit
71c5077bec
|
@ -52,8 +52,8 @@ define-command -hidden rust-indent-on-new-line %~
|
||||||
try %{ execute-keys -draft k : rust-trim-indent <ret> }
|
try %{ execute-keys -draft k : rust-trim-indent <ret> }
|
||||||
# indent after lines ending with { or (
|
# indent after lines ending with { or (
|
||||||
try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
|
try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
|
||||||
# align to opening paren of previous line
|
# indent after lines ending with [{(].+ and move first parameter to own line
|
||||||
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> & }
|
try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]+\n[^\n]*\n?\z <ret> L i<ret><esc> <gt> <a-S> <a-&> >
|
||||||
>
|
>
|
||||||
~
|
~
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ define-command -hidden rust-indent-on-opening-curly-brace %[
|
||||||
_
|
_
|
||||||
]
|
]
|
||||||
|
|
||||||
define-command -hidden rust-indent-on-closing-curly-brace %[
|
define-command -hidden rust-indent-on-closing %[
|
||||||
evaluate-commands -draft -itersel %_
|
evaluate-commands -draft -itersel %_
|
||||||
# align to opening curly brace when alone on a line
|
# align to opening curly brace or paren when alone on a line
|
||||||
try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \A|.\z <ret> 1<a-&> ]
|
try %< execute-keys -draft <a-h> <a-k> ^\h*[)}]$ <ret> h m <a-S> 1<a-&> >
|
||||||
_
|
_
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ hook global WinSetOption filetype=rust %[
|
||||||
hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent
|
hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent
|
||||||
hook window InsertChar \n -group rust-indent rust-indent-on-new-line
|
hook window InsertChar \n -group rust-indent rust-indent-on-new-line
|
||||||
hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace
|
hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace
|
||||||
hook window InsertChar \} -group rust-indent rust-indent-on-closing-curly-brace
|
hook window InsertChar [)}] -group rust-indent rust-indent-on-closing
|
||||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ }
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
1
test/indent/rust/after-open-with-chars/cmd
Normal file
1
test/indent/rust/after-open-with-chars/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c<ret>baz<esc>
|
3
test/indent/rust/after-open-with-chars/in
Normal file
3
test/indent/rust/after-open-with-chars/in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Foo {bar,%( )
|
||||||
|
|
||||||
|
foo(bar,%( )
|
7
test/indent/rust/after-open-with-chars/out
Normal file
7
test/indent/rust/after-open-with-chars/out
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Foo {
|
||||||
|
bar,
|
||||||
|
baz
|
||||||
|
|
||||||
|
foo(
|
||||||
|
bar,
|
||||||
|
baz
|
3
test/indent/rust/after-open-with-chars/rc
Normal file
3
test/indent/rust/after-open-with-chars/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/rust.kak"
|
||||||
|
set buffer filetype rust
|
1
test/indent/rust/after-open/cmd
Normal file
1
test/indent/rust/after-open/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c<ret>bar<esc>
|
3
test/indent/rust/after-open/in
Normal file
3
test/indent/rust/after-open/in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Foo {%( )
|
||||||
|
|
||||||
|
foo(%( )
|
5
test/indent/rust/after-open/out
Normal file
5
test/indent/rust/after-open/out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Foo {
|
||||||
|
bar
|
||||||
|
|
||||||
|
foo(
|
||||||
|
bar
|
3
test/indent/rust/after-open/rc
Normal file
3
test/indent/rust/after-open/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/rust.kak"
|
||||||
|
set buffer filetype rust
|
1
test/indent/rust/align-closing-brace/cmd
Normal file
1
test/indent/rust/align-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c<ret>}<esc>
|
3
test/indent/rust/align-closing-brace/in
Normal file
3
test/indent/rust/align-closing-brace/in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Foo {
|
||||||
|
bar,
|
||||||
|
baz,%( )
|
4
test/indent/rust/align-closing-brace/out
Normal file
4
test/indent/rust/align-closing-brace/out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Foo {
|
||||||
|
bar,
|
||||||
|
baz,
|
||||||
|
}
|
3
test/indent/rust/align-closing-brace/rc
Normal file
3
test/indent/rust/align-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/rust.kak"
|
||||||
|
set buffer filetype rust
|
1
test/indent/rust/align-closing-paren/cmd
Normal file
1
test/indent/rust/align-closing-paren/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c<ret>)<esc>
|
3
test/indent/rust/align-closing-paren/in
Normal file
3
test/indent/rust/align-closing-paren/in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
foo(
|
||||||
|
bar,
|
||||||
|
baz,%( )
|
4
test/indent/rust/align-closing-paren/out
Normal file
4
test/indent/rust/align-closing-paren/out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
foo(
|
||||||
|
bar,
|
||||||
|
baz,
|
||||||
|
)
|
3
test/indent/rust/align-closing-paren/rc
Normal file
3
test/indent/rust/align-closing-paren/rc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
source "%val{runtime}/colors/default.kak"
|
||||||
|
source "%val{runtime}/rc/filetype/rust.kak"
|
||||||
|
set buffer filetype rust
|
Loading…
Reference in New Issue
Block a user