Make rust auto-indenter ignore most things inside comments.
Fixes #3352.
This commit is contained in:
parent
93a889bd44
commit
5024fe17f6
|
@ -74,15 +74,18 @@ define-command -hidden rust-trim-indent %{
|
||||||
define-command -hidden rust-indent-on-new-line %~
|
define-command -hidden rust-indent-on-new-line %~
|
||||||
evaluate-commands -draft -itersel %<
|
evaluate-commands -draft -itersel %<
|
||||||
# copy // comments prefix and following white spaces
|
# copy // comments prefix and following white spaces
|
||||||
try %{ execute-keys -draft k <a-x> s ^\h*\K//[!/]?\h* <ret> y gh j P }
|
try %{
|
||||||
|
execute-keys -draft k <a-x> s ^\h*\K//[!/]?\h* <ret> y gh j P
|
||||||
|
} catch %|
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
try %{ execute-keys -draft <semicolon> K <a-&> }
|
try %{ execute-keys -draft <semicolon> K <a-&> }
|
||||||
# filter previous line
|
|
||||||
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> ]
|
||||||
# indent after lines ending with [{(].+ and move first parameter to own line
|
# 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-&> >
|
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> }
|
||||||
>
|
>
|
||||||
~
|
~
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user