diff options
| author | Ivan Tham <pickfire@riseup.net> | 2021-03-07 14:22:43 +0800 |
|---|---|---|
| committer | Ivan Tham <pickfire@riseup.net> | 2021-03-07 14:22:43 +0800 |
| commit | ebe7f82bb2c53f980115c0f3df1f3602bf63e7dc (patch) | |
| tree | b7c28b4d0aed1921575e960fbacdf7f55a6933ee | |
| parent | 8df562133470d0f62c0c9c707ad0bba1e642d20c (diff) | |
Support rust visibility for enum and others
| -rw-r--r-- | rc/filetype/rust.kak | 4 | ||||
| -rw-r--r-- | test/indent/rust/on-open-paren/in | 5 | ||||
| -rw-r--r-- | test/indent/rust/on-open-paren/out | 5 |
3 files changed, 12 insertions, 2 deletions
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 <a-x> <a-k> ^\h*where\b <ret> hh <a-?> ^\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 <ret> <a-S> 1<a-&> % + try %% execute-keys -draft k <a-x> <a-k> ^\h*where\b <ret> hh <a-?> ^\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 <ret> <a-S> 1<a-&> % # preserve previous line indent try %{ execute-keys -draft <semicolon> K <a-&> } # 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 <a-F> ) M <a-k> \A\(.*\)\h*\n\h*\{\z <ret> s \A|.\z <ret> 1<a-&> ] # dedent standalone { after impl and related block without any { in between - try %@ execute-keys -draft hh <a-?> ^\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 <ret> <a-K> \{ <ret> <a-semicolon> <semicolon> ll <a-x> <a-k> ^\h*\{$ <ret> <a-lt> @ + try %@ execute-keys -draft hh <a-?> ^\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 <ret> <a-K> \{ <ret> <a-semicolon> <semicolon> ll <a-x> <a-k> ^\h*\{$ <ret> <a-lt> @ ~ ] 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<T> + where + T: Debug + %( ) + struct X<T> where T: Debug %( ) enum X<T> 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<T> + where + T: Debug + { + struct X<T> where T: Debug { enum X<T> |
