Merge remote-tracking branch 'johnisom/deindent-closing-braces'

This commit is contained in:
Maxime Coste 2020-07-30 21:14:37 +10:00
commit 55fbdb3606
65 changed files with 584 additions and 44 deletions

View File

@ -76,6 +76,8 @@ define-command -hidden awk-indent-on-new-line %[
try %[ execute-keys -draft k <a-x> s \h+$ <ret> d ] try %[ execute-keys -draft k <a-x> s \h+$ <ret> d ]
# indent after line ending in opening curly brace # indent after line ending in opening curly brace
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> ]
# deindent closing brace when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
] ]
] ]

View File

@ -83,7 +83,7 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i
# remove previous empty lines resulting from the automatic indent # remove previous empty lines resulting from the automatic indent
try %< execute-keys -draft k <a-x> <a-k>^\h+$<ret> Hd > try %< execute-keys -draft k <a-x> <a-k>^\h+$<ret> Hd >
# indent after an opening brace or parenthesis at end of line # indent after an opening brace or parenthesis at end of line
try %< execute-keys -draft k <a-x> s[{(]\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k>[{(]\h*$<ret> j <a-gt> >
# indent after a label # indent after a label
try %< execute-keys -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> > try %< execute-keys -draft k <a-x> s[a-zA-Z0-9_-]+:\h*$<ret> j <a-gt> >
# indent after a statement not followed by an opening brace # indent after a statement not followed by an opening brace
@ -98,6 +98,8 @@ define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -i
try %< execute-keys -draft K <a-x> <a-k>\;\h*(//[^\n]+)?$<ret> \ try %< execute-keys -draft K <a-x> <a-k>\;\h*(//[^\n]+)?$<ret> \
K <a-x> s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z<ret> \ K <a-x> s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z<ret> \
<a-S>1<a-&> > <a-S>1<a-&> >
# deindent closing brace(s) when after cursor
try %< execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <esc> m <a-S> 1<a-&> >
# align to the opening parenthesis or opening brace (whichever is first) # align to the opening parenthesis or opening brace (whichever is first)
# on a previous line if its followed by text on the same line # on a previous line if its followed by text on the same line
try %< evaluate-commands -draft %< try %< evaluate-commands -draft %<

View File

@ -52,14 +52,16 @@ define-command -hidden cabal-trim-indent %{
define-command -hidden cabal-indent-on-new-line %[ define-command -hidden cabal-indent-on-new-line %[
evaluate-commands -draft -itersel %[ evaluate-commands -draft -itersel %[
# copy '#' comment prefix and following white spaces # copy '--' comment 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 ]
# 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 # filter previous line
try %[ execute-keys -draft k : cabal-trim-indent <ret> ] try %[ execute-keys -draft k : cabal-trim-indent <ret> ]
# indent after lines ending with { or : # indent after lines ending with { or :
try %[ execute-keys -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ] try %[ execute-keys -draft <space> k <a-x> <a-k> [:{]$ <ret> j <a-gt> ]
# deindent closing brace when after cursor
try %[ execute-keys -draft <a-x> <a-k> \h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
] ]
] ]

View File

@ -71,6 +71,8 @@ define-command -hidden css-indent-on-new-line %[
try %[ execute-keys -draft k : css-trim-indent <ret> ] try %[ execute-keys -draft k : css-trim-indent <ret> ]
# indent after lines ending with with { # indent after lines ending with with {
try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
# deindent closing brace when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
] ]
] ]

View File

@ -136,6 +136,8 @@ define-command -hidden cue-indent-on-new-line %~
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-&> >
# deindent closing brace(s) when after cursor
try %< execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> >
| |
# filter previous line # filter previous line
try %{ execute-keys -draft k : cue-trim-indent <ret> } try %{ execute-keys -draft k : cue-trim-indent <ret> }

View File

@ -121,6 +121,8 @@ define-command -hidden d-indent-on-new-line %~
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
# deindent closing brace(s) when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
= =
~ ~

View File

@ -97,6 +97,8 @@ define-command -hidden dart-indent-on-new-line %~
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
# deindent closing brace when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
= =
~ ~

View File

@ -31,7 +31,7 @@ hook -group gluon-highlight global WinSetOption filetype=gluon %{
} }
provide-module gluon %[ provide-module gluon %§
# Highlighters # Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾
@ -78,8 +78,8 @@ define-command -hidden gluon-trim-indent %{
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden gluon-indent-on-new-line %{ define-command -hidden gluon-indent-on-new-line %~
evaluate-commands -draft -itersel %{ evaluate-commands -draft -itersel %_
# copy // and /// comments prefix and following white spaces # copy // and /// 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 }
# preserve previous line indent # preserve previous line indent
@ -88,12 +88,10 @@ define-command -hidden gluon-indent-on-new-line %{
try %{ execute-keys -draft k : gluon-trim-indent <ret> } try %{ execute-keys -draft k : gluon-trim-indent <ret> }
# indent after lines ending with (open) braces, =, ->, condition, rec, # indent after lines ending with (open) braces, =, ->, condition, rec,
# or in # or in
try %{ try %{ execute-keys -draft \; k x <a-k> (\(|\{|\[|=|->|then|else|rec|in)$ <ret> j <a-gt> }
execute-keys -draft \ # deindent closing brace(s) when after cursor
\; k x <a-k> (\(|\{|\[|=|->|then|else|rec|in)$ <ret> j <a-gt> try %< execute-keys -draft <a-x> <a-k> ^\h*[})\]] <ret> gh / \})\]] <ret> m <a-S> 1<a-&> >
# balance out brackets } ] _
} ~
}
}
] §

View File

@ -89,6 +89,8 @@ define-command -hidden go-indent-on-new-line %~
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
# deindent closing brace(s) when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
= =
~ ~

View File

@ -56,6 +56,8 @@ define-command -hidden java-indent-on-new-line %~
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after keywords # indent after keywords
try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
# deindent closing brace(s) when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
= =
~ ~

View File

@ -61,7 +61,9 @@ define-command -hidden javascript-indent-on-new-line %<
# filter previous line # filter previous line
try %{ execute-keys -draft k : javascript-trim-indent <ret> } try %{ execute-keys -draft k : javascript-trim-indent <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _ try %_ execute-keys -draft k <a-x> s [[({] <ret> <space> <a-l> <a-K> [\])}] <ret> j <a-gt> _
# deindent closing token(s) when after cursor
try %_ execute-keys -draft <a-x> <a-k> ^\h*[})\]] <ret> gh / [})\]] <ret> m <a-S> 1<a-&> _
> >
> >

View File

@ -49,7 +49,7 @@ define-command -hidden json-trim-indent %{
define-command -hidden json-indent-on-char %< define-command -hidden json-indent-on-char %<
evaluate-commands -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m <a-S> 1<a-&> >
> >
> >
@ -59,8 +59,10 @@ define-command -hidden json-indent-on-new-line %<
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# filter previous line # filter previous line
try %{ execute-keys -draft k : json-trim-indent <ret> } try %{ execute-keys -draft k : json-trim-indent <ret> }
# indent after lines beginning with opener token # indent after lines ending with opener token
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> >
# deindent closer token(s) when after cursor
try %< execute-keys -draft <a-x> <a-k> ^\h*[}\]] <ret> gh / [}\]] <ret> m <a-S> 1<a-&> >
> >
> >

View File

@ -90,8 +90,8 @@ add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden kak-indent-on-new-line %{ define-command -hidden kak-indent-on-new-line %~
evaluate-commands -draft -itersel %{ evaluate-commands -draft -itersel %=
# copy '#' comment prefix and following white spaces # copy '#' comment prefix and following white spaces
try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent # preserve previous line indent
@ -100,8 +100,12 @@ define-command -hidden kak-indent-on-new-line %{
try %{ execute-keys -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with %\w*[^\s\w] # indent after line ending with %\w*[^\s\w]
try %{ execute-keys -draft k <a-x> <a-k> \%\w*[^\s\w]$ <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-k> \%\w*[^\s\w]$ <ret> j <a-gt> }
} # deindent closing brace when after cursor
} try %_ execute-keys -draft -itersel <a-x> <a-k> ^\h*([>)}\]]) <ret> gh / <c-r>1 <ret> m <a-S> 1<a-&> _
# deindent closing char(s)
try %{ execute-keys -draft -itersel <a-x> <a-k> ^\h*([^\s\w]) <ret> gh / <c-r>1 <ret> <a-?> <c-r>1 <ret> <a-T>% <a-k> \w*<c-r>1$ <ret> <a-S> 1<a-&> }
=
~
define-command -hidden kak-indent-on-closing-matching %~ define-command -hidden kak-indent-on-closing-matching %~
# align to opening matching brace when alone on a line # align to opening matching brace when alone on a line

View File

@ -68,6 +68,8 @@ define-command -hidden latex-indent-newline %(
try %{ execute-keys -draft k<a-x> s\h+$<ret> d } try %{ execute-keys -draft k<a-x> s\h+$<ret> d }
# indent after line ending with { # indent after line ending with {
try %( execute-keys -draft k<a-x> <a-k>\{$<ret> j<a-gt> ) try %( execute-keys -draft k<a-x> <a-k>\{$<ret> j<a-gt> )
# deindent closing brace(s) when after cursor
try %( execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> )
# indent after line ending with \begin{...}[...]{...}, with multiple # indent after line ending with \begin{...}[...]{...}, with multiple
# sets of arguments possible # sets of arguments possible
try %( try %(

View File

@ -95,7 +95,7 @@ define-command -hidden nix-trim-indent %{
define-command -hidden nix-indent-on-char %< define-command -hidden nix-indent-on-char %<
evaluate-commands -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
@ -109,6 +109,8 @@ define-command -hidden nix-indent-on-new-line %<
try %{ execute-keys -draft k : nix-trim-indent <ret> } try %{ execute-keys -draft k : nix-trim-indent <ret> }
# indent after lines beginning / ending with opener token # indent after lines beginning / ending with opener token
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> _
# deindent closer token(s) when after cursor
try %_ execute-keys -draft <a-x> <a-k> ^\h*[}\]] <ret> gh / [}\]] <ret> m <a-S> 1<a-&> _
> >
> >

View File

@ -111,12 +111,14 @@ define-command -hidden perl-indent-on-new-line %~
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & } try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> s \A\(\h*.|.\z <ret> '<a-;>' & }
# copy // comments prefix # copy # comments prefix
try %{ execute-keys -draft <semicolon><c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> } try %{ execute-keys -draft <semicolon><c-s>k<a-x> s ^\h*\K# <ret> y<c-o>P<esc> }
# indent after a switch's case/default statements # indent after a switch's case/default statements
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ] try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
# indent after if|else|while|for # indent after if|else|while|for
try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ] try %[ execute-keys -draft <semicolon><a-F>)MB <a-k> \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z <ret> s \A|.\z <ret> 1<a-&>1<a-space><a-gt> ]
# deindent closing brace(s) when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
= =
~ ~

View File

@ -23,7 +23,7 @@ hook -group php-highlight global WinSetOption filetype=php %{
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file } hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file }
} }
provide-module php %( provide-module php %§
require-module html require-module html
# Highlighters # Highlighters
@ -77,7 +77,7 @@ define-command -hidden php-trim-indent %{
define-command -hidden php-indent-on-char %< define-command -hidden php-indent-on-char %<
evaluate-commands -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %/ execute-keys -draft <a-h> <a-k> ^\h+[]}]$ <ret> m s \A|.\z <ret> 1<a-&> / try %/ execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
> >
> >
@ -93,7 +93,9 @@ define-command -hidden php-indent-on-new-line %<
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> _
# append " * " on lines starting a multiline /** or /* comment # append " * " on lines starting a multiline /** or /* comment
try %{ execute-keys -draft k <a-x> s ^\h*/[*][* ]? <ret> j gi i <space>*<space> } try %{ execute-keys -draft k <a-x> s ^\h*/[*][* ]? <ret> j gi i <space>*<space> }
# deindent closer token(s) when after cursor
try %_ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> _
> >
> >
) §

View File

@ -76,6 +76,8 @@ define-command -hidden protobuf-indent-on-newline %~
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d } try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
# copy // comments prefix # copy // comments prefix
try %{ execute-keys -draft <semicolon><c-s>k<a-x> s ^\h*\K/{2,}(\h*(?=\S))? <ret> y<c-o>P<esc> } try %{ execute-keys -draft <semicolon><c-s>k<a-x> s ^\h*\K/{2,}(\h*(?=\S))? <ret> y<c-o>P<esc> }
# deindent closing brace(s) when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
] ]
~ ~

View File

@ -28,7 +28,7 @@ hook -group python-highlight global WinSetOption filetype=python %{
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python } hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python }
} }
provide-module python %{ provide-module python %§
# Highlighters & Completion # Highlighters & Completion
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
@ -149,15 +149,17 @@ define-command -hidden python-insert-on-new-line %{
try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P } try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
} }
} }
define-command -hidden python-indent-on-new-line %{ define-command -hidden python-indent-on-new-line %<
evaluate-commands -draft -itersel %{ evaluate-commands -draft -itersel %<
# preserve previous line indent # preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# cleanup trailing whitespaces from previous line # cleanup trailing whitespaces from previous line
try %{ execute-keys -draft k <a-x> s \h+$ <ret> d } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with : # indent after line ending with :
try %{ execute-keys -draft <space> k <a-x> <a-k> :$ <ret> j <a-gt> } try %{ execute-keys -draft <space> k <a-x> <a-k> :$ <ret> j <a-gt> }
} # deindent closing brace/bracket when after cursor (for arrays and dictionaries)
} try %[ execute-keys -draft <a-x> <a-k> ^\h*[}\]] <ret> gh / [}\]] <ret> m <a-S> 1<a-&> ]
>
>
} §

View File

@ -55,7 +55,7 @@ define-command -hidden ragel-trim-indent %{
define-command -hidden ragel-indent-on-char %< define-command -hidden ragel-indent-on-char %<
evaluate-commands -draft -itersel %< evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line # align closer token to its opener when alone on a line
try %< execute-keys -draft <a-h> <a-k> ^\h+[]})]$ <ret> m s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+[\]})]$ <ret> m s \A|.\z <ret> 1<a-&> >
try %< execute-keys -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> > try %< execute-keys -draft <a-h> <a-k> ^\h+ [*]$ <ret> <a-?> [*]$ <ret> s \A|.\z <ret> 1<a-&> >
> >
> >
@ -70,6 +70,8 @@ define-command -hidden ragel-indent-on-new-line %<
try %{ execute-keys -draft k : ragel-trim-indent <ret> } try %{ execute-keys -draft k : ragel-trim-indent <ret> }
# indent after lines ending with opener token # indent after lines ending with opener token
try %< execute-keys -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> > try %< execute-keys -draft k <a-x> <a-k> [[{(*]$ <ret> j <a-gt> >
# align closer token to its opener when after cursor
try %< execute-keys -draft <a-x> <a-k> ^\h*[})\]] <ret> gh / [})\]] <ret> m <a-S> 1<a-&> >
> >
> >

View File

@ -112,6 +112,8 @@ define-command -hidden rust-indent-on-new-line %~
try %+ execute-keys -draft k <a-x> <a-k> ^\h*where\h*$ <ret> j <a-gt> + try %+ execute-keys -draft k <a-x> <a-k> ^\h*where\h*$ <ret> j <a-gt> +
# dedent after lines starting with . and ending with , or ; # dedent after lines starting with . and ending with , or ;
try %_ execute-keys -draft k <a-x> <a-k> ^\h*\..*[,<semicolon>]\h*$ <ret> j <a-lt> _ try %_ execute-keys -draft k <a-x> <a-k> ^\h*\..*[,<semicolon>]\h*$ <ret> j <a-lt> _
# deindent closing brace(s) when after cursor
try %= execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> =
# todo dedent additional unmatched parenthesis # todo dedent additional unmatched parenthesis
# try %& execute-keys -draft k <a-x> s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{ # try %& execute-keys -draft k <a-x> s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{
# count previous selections length # count previous selections length

View File

@ -11,15 +11,16 @@ hook global BufCreate .*[.](sass) %{
# Initialization # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=sass %{ hook global WinSetOption filetype=sass %<
require-module sass require-module sass
hook window ModeChange pop:insert:.* -group sass-trim-indent sass-trim-indent hook window ModeChange pop:insert:.* -group sass-trim-indent sass-trim-indent
hook window InsertChar \} -group sass-indent sass-indent-on-closing-brace
hook window InsertChar \n -group sass-indent sass-indent-on-new-line hook window InsertChar \n -group sass-indent sass-indent-on-new-line
set-option buffer extra_word_chars '_' '-' set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ }
} >
hook -group sass-highlight global WinSetOption filetype=sass %{ hook -group sass-highlight global WinSetOption filetype=sass %{
add-highlighter window/sass ref sass add-highlighter window/sass ref sass
@ -27,7 +28,7 @@ hook -group sass-highlight global WinSetOption filetype=sass %{
} }
provide-module sass %{ provide-module sass %§
# Highlighters # Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾
@ -53,8 +54,15 @@ define-command -hidden sass-trim-indent %{
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d } try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
} }
define-command -hidden sass-indent-on-new-line %{ define-command -hidden sass-indent-on-closing-brace %<
evaluate-commands -draft -itersel %{ evaluate-commands -draft -itersel %<
# align closing brace to same indentation as the line that the opening brace resides on
try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m <a-S> 1<a-&> ]
>
>
define-command -hidden sass-indent-on-new-line %<
evaluate-commands -draft -itersel %<
# copy '/' comment prefix and following white spaces # copy '/' comment 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 }
# preserve previous line indent # preserve previous line indent
@ -63,7 +71,9 @@ define-command -hidden sass-indent-on-new-line %{
try %{ execute-keys -draft k : sass-trim-indent <ret> } try %{ execute-keys -draft k : sass-trim-indent <ret> }
# avoid indent after properties and comments # avoid indent after properties and comments
try %{ execute-keys -draft k <a-x> <a-K> [:/] <ret> j <a-gt> } try %{ execute-keys -draft k <a-x> <a-K> [:/] <ret> j <a-gt> }
} # deindent closing brace when after cursor
} try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
>
>
} §

View File

@ -69,6 +69,8 @@ define-command -hidden scala-indent-on-new-line %[
try %[ execute-keys -draft k : scala-trim-indent <ret> ] try %[ execute-keys -draft k : scala-trim-indent <ret> ]
# indent after lines ending with { # indent after lines ending with {
try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ] try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
# deindent closing brace when after cursor
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
] ]
] ]

View File

@ -182,6 +182,8 @@ define-command -hidden sh-indent-on-new-line %[
try %= execute-keys -draft <space> k <a-x> <a-k> (\s|^)\{$ <ret> j <a-gt> = try %= execute-keys -draft <space> k <a-x> <a-k> (\s|^)\{$ <ret> j <a-gt> =
# deindent closing } # deindent closing }
try %= execute-keys -draft <space> k <a-x> <a-k> ^\s*\}$ <ret> <a-lt> j K <a-&> = try %= execute-keys -draft <space> k <a-x> <a-k> ^\s*\}$ <ret> <a-lt> j K <a-&> =
# deindent closing } when after cursor
try %= execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> =
] ]
] ]

View File

@ -121,6 +121,8 @@ define-command -hidden zig-indent-on-new-line %<
try %< execute-keys -draft <semicolon> K <a-&> > try %< execute-keys -draft <semicolon> K <a-&> >
# indent after lines ending in { # indent after lines ending in {
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> >
# deindent closing } when after cursor
try %< execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> >
> >
# filter previous line # filter previous line
try %< execute-keys -draft k : zig-trim-indent <ret> > try %< execute-keys -draft k : zig-trim-indent <ret> >

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,15 @@
void foo(void) {%( )}
void foo(void) {%( )
}
void foo(void) {%( )bar()}
void foo(void) {%( )bar()
}
void foo(void) {
bar()%( )}
void foo(void) {
bar()%( )}

View File

@ -0,0 +1,21 @@
void foo(void) {
}
void foo(void) {
}
void foo(void) {
bar()}
void foo(void) {
bar()
}
void foo(void) {
bar()
}
void foo(void) {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/c-family.kak"
set buffer filetype cpp

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,31 @@
{%( )}
{%( )
}
{%( )bar()}
{%( )bar()
}
{
bar()%( )}
{(%( ))}
{(%( )
)}
{(%( )foo())}
{(%( )foo()
)}
{(
bar()%( ))}
{
bar()%( )}
{(
bar()%( ))}

View File

@ -0,0 +1,43 @@
{
}
{
}
{
bar()}
{
bar()
}
{
bar()
}
{(
)}
{(
)}
{(
foo())}
{(
foo()
)}
{(
bar()
)}
{
bar()
}
{(
bar()
)}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/c-family.kak"
set buffer filetype cpp

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,15 @@
if (1) {%( )}
if (1) {%( )
}
if (1) {%( )bar()}
if (1) {%( )bar()
}
if (1) {
bar()%( )}
if (1) {
bar()%( )}

View File

@ -0,0 +1,21 @@
if (1) {
}
if (1) {
}
if (1) {
bar()}
if (1) {
bar()
}
if (1) {
bar()
}
if (1) {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/c-family.kak"
set buffer filetype cpp

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,15 @@
func foo(x int) int {%( )}
func foo(x int) int {%( )
}
func foo(x int) int {%( )bar()}
func foo(x int) int {%( )bar()
}
func foo(x int) int {
bar()%( )}
func foo(x int) int {
bar()%( )}

View File

@ -0,0 +1,21 @@
func foo(x int) int {
}
func foo(x int) int {
}
func foo(x int) int {
bar()}
func foo(x int) int {
bar()
}
func foo(x int) int {
bar()
}
func foo(x int) int {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/go.kak"
set buffer filetype go

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,31 @@
{%( )}
{%( )
}
{%( )bar()}
{%( )bar()
}
{
bar()%( )}
{
bar()%( )}
{(%( ))}
{(%( )
)}
{(%( )foo())}
{(%( )foo()
)}
{(
bar()%( ))}
{(
bar()%( ))}

View File

@ -0,0 +1,43 @@
{
}
{
}
{
bar()}
{
bar()
}
{
bar()
}
{
bar()
}
{(
)}
{(
)}
{(
foo())}
{(
foo()
)}
{(
bar()
)}
{(
bar()
)}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/go.kak"
set buffer filetype go

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,12 @@
if true {%( )}
if true {%( )
}
if true {%( )bar()}
if true {%( )bar()
}
if true {
bar()%( )}

View File

@ -0,0 +1,17 @@
if true {
}
if true {
}
if true {
bar()}
if true {
bar()
}
if true {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/go.kak"
set buffer filetype go

View File

@ -0,0 +1 @@
c<ret><esc>Oif (true) {}<esc>hi<ret><esc>Oconsole.log();<esc>hhi<ret><esc>O{},<ret>{},<esc>hh<a-C>i<ret><esc>1<space>Ofoo: { bar: 1 },<esc>jjobaz: { bam: 2 },<esc>

View File

@ -0,0 +1 @@
for (let i = 1; i < 5; ++i) {%( )}

View File

@ -0,0 +1,12 @@
for (let i = 1; i < 5; ++i) {
if (true) {
console.log(
{
foo: { bar: 1 },
},
{
baz: { bam: 2 },
},
);
}
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/javascript.kak"
set buffer filetype javascript

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,15 @@
fn foo() -> i32 {%( )}
fn foo() -> i32 {%( )
}
fn foo() -> i32 {%( )bar()}
fn foo() -> i32 {%( )bar()
}
fn foo() -> i32 {
bar()%( )}
fn foo() -> i32 {
bar()%( )}

View File

@ -0,0 +1,21 @@
fn foo() -> i32 {
}
fn foo() -> i32 {
}
fn foo() -> i32 {
bar()}
fn foo() -> i32 {
bar()
}
fn foo() -> i32 {
bar()
}
fn foo() -> i32 {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,31 @@
{%( )}
{%( )
}
{%( )bar()}
{%( )bar()
}
{
bar()%( )}
{
bar()%( )}
{(%( ))}
{(%( )
)}
{(%( )foo())}
{(%( )foo()
)}
{(
bar()%( ))}
{(
bar()%( ))}

View File

@ -0,0 +1,43 @@
{
}
{
}
{
bar()}
{
bar()
}
{
bar()
}
{
bar()
}
{(
)}
{(
)}
{(
foo())}
{(
foo()
)}
{(
bar()
)}
{(
bar()
)}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust

View File

@ -0,0 +1 @@
c<ret>

View File

@ -0,0 +1,15 @@
if true {%( )}
if true {%( )
}
if true {%( )bar()}
if true {%( )bar()
}
if true {
bar()%( )}
if true {
bar()%( )}

View File

@ -0,0 +1,21 @@
if true {
}
if true {
}
if true {
bar()}
if true {
bar()
}
if true {
bar()
}
if true {
bar()
}

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust