diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 8764489c..8f9627ec 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -148,7 +148,7 @@ define-command -hidden rust-indent-on-new-line %~ } catch %` # re-indent previous line if it starts with where to match previous block # string literal parsing within extern does not handle escape - try %% execute-keys -draft k ^\h*where\b hh ^\h*\b(impl|(|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )(async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union)\b 1 % + try %% execute-keys -draft k ^\h*where\b hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union)))\b 1 % # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with [{([].+ and move first parameter to own line @@ -180,7 +180,7 @@ define-command -hidden rust-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] # dedent standalone { after impl and related block without any { in between - try %@ execute-keys -draft hh ^\h*\b(impl|(|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )(async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union|if|for)\b \{ ll ^\h*\{$ @ + try %@ execute-keys -draft hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union))|if|for)\b \{ ll ^\h*\{$ @ ~ ] diff --git a/test/indent/rust/on-open-paren/in b/test/indent/rust/on-open-paren/in index cc452565..137baf5a 100644 --- a/test/indent/rust/on-open-paren/in +++ b/test/indent/rust/on-open-paren/in @@ -27,6 +27,11 @@ T: Debug %( ) + pub(crate) struct X + where + T: Debug + %( ) + struct X where T: Debug %( ) enum X diff --git a/test/indent/rust/on-open-paren/out b/test/indent/rust/on-open-paren/out index d7e4aad3..39f83f23 100644 --- a/test/indent/rust/on-open-paren/out +++ b/test/indent/rust/on-open-paren/out @@ -27,6 +27,11 @@ T: Debug { + pub(crate) struct X + where + T: Debug + { + struct X where T: Debug { enum X