1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-28 22:22:41 +03:00

Make rust auto-indenter ignore most things inside comments.

Fixes #3352.
This commit is contained in:
Joe Neeman 2020-02-24 12:51:03 -06:00
parent 93a889bd44
commit 5024fe17f6

View File

@ -74,15 +74,18 @@ define-command -hidden rust-trim-indent %{
define-command -hidden rust-indent-on-new-line %~
evaluate-commands -draft -itersel %<
# copy // comments prefix and following white spaces
try %{ execute-keys -draft k <a-x> s ^\h*\K//[!/]?\h* <ret> y gh j P }
# preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> }
try %{
execute-keys -draft k <a-x> s ^\h*\K//[!/]?\h* <ret> y gh j P
} catch %|
# preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> }
# indent after lines ending with { or (
try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
# indent after lines ending with [{(].+ and move first parameter to own line
try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]+\n[^\n]*\n?\z <ret> L i<ret><esc> <gt> <a-S> <a-&> >
|
# filter previous line
try %{ execute-keys -draft k : rust-trim-indent <ret> }
# indent after lines ending with { or (
try %[ execute-keys -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
# indent after lines ending with [{(].+ and move first parameter to own line
try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]+\n[^\n]*\n?\z <ret> L i<ret><esc> <gt> <a-S> <a-&> >
>
~