From 5024fe17f64898c16d3070ca9c288cdd7d942cba Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Mon, 24 Feb 2020 12:51:03 -0600 Subject: [PATCH] Make rust auto-indenter ignore most things inside comments. Fixes #3352. --- rc/filetype/rust.kak | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 7e7248b3..be440f75 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -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 s ^\h*\K//[!/]?\h* y gh j P } - # preserve previous line indent - try %{ execute-keys -draft K } + try %{ + execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P + } catch %| + # preserve previous line indent + try %{ execute-keys -draft K } + # indent after lines ending with { or ( + try %[ execute-keys -draft k [{(]\h*$ j ] + # indent after lines ending with [{(].+ and move first parameter to own line + try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > + | # filter previous line try %{ execute-keys -draft k : rust-trim-indent } - # indent after lines ending with { or ( - try %[ execute-keys -draft k [{(]\h*$ j ] - # indent after lines ending with [{(].+ and move first parameter to own line - try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > > ~