Merge remote-tracking branch 'johnisom/deindent-closing-braces'
This commit is contained in:
commit
55fbdb3606
|
@ -76,6 +76,8 @@ define-command -hidden awk-indent-on-new-line %[
|
|||
try %[ execute-keys -draft k <a-x> s \h+$ <ret> d ]
|
||||
# indent after line ending in opening curly brace
|
||||
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-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
|
|
|
@ -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
|
||||
try %< execute-keys -draft k <a-x> <a-k>^\h+$<ret> Hd >
|
||||
# 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
|
||||
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
|
||||
|
@ -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> \
|
||||
K <a-x> s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z<ret> \
|
||||
<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)
|
||||
# on a previous line if its followed by text on the same line
|
||||
try %< evaluate-commands -draft %<
|
||||
|
|
|
@ -52,14 +52,16 @@ define-command -hidden cabal-trim-indent %{
|
|||
|
||||
define-command -hidden cabal-indent-on-new-line %[
|
||||
evaluate-commands -draft -itersel %[
|
||||
# copy '#' comment prefix and following white spaces
|
||||
try %[ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P ]
|
||||
# copy '--' comment prefix and following white spaces
|
||||
try %[ execute-keys -draft k <a-x> s ^\h*\K--\h* <ret> y gh j P ]
|
||||
# preserve previous line indent
|
||||
try %[ execute-keys -draft <semicolon> K <a-&> ]
|
||||
# filter previous line
|
||||
try %[ execute-keys -draft k : cabal-trim-indent <ret> ]
|
||||
# indent after lines ending with { or :
|
||||
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-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ define-command -hidden css-indent-on-new-line %[
|
|||
try %[ execute-keys -draft k : css-trim-indent <ret> ]
|
||||
# indent after lines ending with with {
|
||||
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-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
|
|
|
@ -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> ]
|
||||
# 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-&> >
|
||||
# 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
|
||||
try %{ execute-keys -draft k : cue-trim-indent <ret> }
|
||||
|
|
|
@ -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> ]
|
||||
# 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> ]
|
||||
# deindent closing brace(s) when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
|
||||
=
|
||||
~
|
||||
|
||||
|
|
|
@ -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> ]
|
||||
# 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> ]
|
||||
# deindent closing brace when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
|
||||
=
|
||||
~
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ hook -group gluon-highlight global WinSetOption filetype=gluon %{
|
|||
}
|
||||
|
||||
|
||||
provide-module gluon %[
|
||||
provide-module gluon %§
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
@ -78,8 +78,8 @@ define-command -hidden gluon-trim-indent %{
|
|||
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
||||
}
|
||||
|
||||
define-command -hidden gluon-indent-on-new-line %{
|
||||
evaluate-commands -draft -itersel %{
|
||||
define-command -hidden gluon-indent-on-new-line %~
|
||||
evaluate-commands -draft -itersel %_
|
||||
# copy // and /// comments prefix and following white spaces
|
||||
try %{ execute-keys -draft k <a-x> s ^\h*\K///?\h* <ret> y gh j P }
|
||||
# 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> }
|
||||
# indent after lines ending with (open) braces, =, ->, condition, rec,
|
||||
# or in
|
||||
try %{
|
||||
execute-keys -draft \
|
||||
\; k x <a-k> (\(|\{|\[|=|->|then|else|rec|in)$ <ret> j <a-gt>
|
||||
# balance out brackets } ]
|
||||
}
|
||||
}
|
||||
}
|
||||
try %{ execute-keys -draft \; k x <a-k> (\(|\{|\[|=|->|then|else|rec|in)$ <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-&> >
|
||||
_
|
||||
~
|
||||
|
||||
]
|
||||
§
|
||||
|
|
|
@ -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> ]
|
||||
# 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> ]
|
||||
# deindent closing brace(s) when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
|
||||
=
|
||||
~
|
||||
|
||||
|
|
|
@ -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> ]
|
||||
# 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> ]
|
||||
# deindent closing brace(s) when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
|
||||
=
|
||||
~
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ define-command -hidden javascript-indent-on-new-line %<
|
|||
# filter previous line
|
||||
try %{ execute-keys -draft k : javascript-trim-indent <ret> }
|
||||
# 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-&> _
|
||||
>
|
||||
>
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ define-command -hidden json-trim-indent %{
|
|||
define-command -hidden json-indent-on-char %<
|
||||
evaluate-commands -draft -itersel %<
|
||||
# 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-&> }
|
||||
# filter previous line
|
||||
try %{ execute-keys -draft k : json-trim-indent <ret> }
|
||||
# indent after lines beginning with opener token
|
||||
try %< execute-keys -draft k <a-x> <a-k> ^\h*[[{] <ret> j <a-gt> >
|
||||
# indent after lines ending with opener token
|
||||
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-&> >
|
||||
>
|
||||
>
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b
|
|||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
define-command -hidden kak-indent-on-new-line %{
|
||||
evaluate-commands -draft -itersel %{
|
||||
define-command -hidden kak-indent-on-new-line %~
|
||||
evaluate-commands -draft -itersel %=
|
||||
# copy '#' comment prefix and following white spaces
|
||||
try %{ execute-keys -draft k <a-x> s ^\h*#\h* <ret> y jgh P }
|
||||
# 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 }
|
||||
# indent after line ending with %\w*[^\s\w]
|
||||
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 %~
|
||||
# align to opening matching brace when alone on a line
|
||||
|
|
|
@ -68,6 +68,8 @@ define-command -hidden latex-indent-newline %(
|
|||
try %{ execute-keys -draft k<a-x> s\h+$<ret> d }
|
||||
# indent after line ending with {
|
||||
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
|
||||
# sets of arguments possible
|
||||
try %(
|
||||
|
|
|
@ -95,7 +95,7 @@ define-command -hidden nix-trim-indent %{
|
|||
define-command -hidden nix-indent-on-char %<
|
||||
evaluate-commands -draft -itersel %<
|
||||
# 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> }
|
||||
# indent after lines beginning / ending with opener token
|
||||
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-&> _
|
||||
>
|
||||
>
|
||||
|
||||
|
|
|
@ -111,12 +111,14 @@ define-command -hidden perl-indent-on-new-line %~
|
|||
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
|
||||
# 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-;>' & }
|
||||
# copy // comments prefix
|
||||
try %{ execute-keys -draft <semicolon><c-s>k<a-x> s ^\h*\K/{2,} <ret> y<c-o>P<esc> }
|
||||
# copy # comments prefix
|
||||
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
|
||||
try %[ execute-keys -draft k<a-x> <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
|
||||
# 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> ]
|
||||
# deindent closing brace(s) when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
|
||||
=
|
||||
~
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ hook -group php-highlight global WinSetOption filetype=php %{
|
|||
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file }
|
||||
}
|
||||
|
||||
provide-module php %(
|
||||
provide-module php %§
|
||||
require-module html
|
||||
|
||||
# Highlighters
|
||||
|
@ -77,7 +77,7 @@ define-command -hidden php-trim-indent %{
|
|||
define-command -hidden php-indent-on-char %<
|
||||
evaluate-commands -draft -itersel %<
|
||||
# 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> _
|
||||
# append " * " on lines starting a multiline /** or /* comment
|
||||
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-&> _
|
||||
>
|
||||
>
|
||||
|
||||
)
|
||||
§
|
||||
|
|
|
@ -76,6 +76,8 @@ define-command -hidden protobuf-indent-on-newline %~
|
|||
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
|
||||
# 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> }
|
||||
# deindent closing brace(s) when after cursor
|
||||
try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
|
||||
]
|
||||
~
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ hook -group python-highlight global WinSetOption filetype=python %{
|
|||
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python }
|
||||
}
|
||||
|
||||
provide-module python %{
|
||||
provide-module python %§
|
||||
|
||||
# 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 }
|
||||
}
|
||||
}
|
||||
define-command -hidden python-indent-on-new-line %{
|
||||
evaluate-commands -draft -itersel %{
|
||||
define-command -hidden python-indent-on-new-line %<
|
||||
evaluate-commands -draft -itersel %<
|
||||
# preserve previous line indent
|
||||
try %{ execute-keys -draft <semicolon> K <a-&> }
|
||||
# cleanup trailing whitespaces from previous line
|
||||
try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
|
||||
# indent after line ending with :
|
||||
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-&> ]
|
||||
>
|
||||
>
|
||||
|
||||
}
|
||||
§
|
||||
|
|
|
@ -55,8 +55,8 @@ define-command -hidden ragel-trim-indent %{
|
|||
define-command -hidden ragel-indent-on-char %<
|
||||
evaluate-commands -draft -itersel %<
|
||||
# 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> <a-?> [*]$ <ret> 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-&> >
|
||||
>
|
||||
>
|
||||
|
||||
|
@ -70,6 +70,8 @@ define-command -hidden ragel-indent-on-new-line %<
|
|||
try %{ execute-keys -draft k : ragel-trim-indent <ret> }
|
||||
# indent after lines ending with opener token
|
||||
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-&> >
|
||||
>
|
||||
>
|
||||
|
||||
|
|
|
@ -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> +
|
||||
# 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> _
|
||||
# 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
|
||||
# try %& execute-keys -draft k <a-x> s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{
|
||||
# count previous selections length
|
||||
|
|
|
@ -11,15 +11,16 @@ hook global BufCreate .*[.](sass) %{
|
|||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=sass %{
|
||||
hook global WinSetOption filetype=sass %<
|
||||
require-module sass
|
||||
|
||||
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
|
||||
set-option buffer extra_word_chars '_' '-'
|
||||
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ }
|
||||
}
|
||||
>
|
||||
|
||||
hook -group sass-highlight global WinSetOption filetype=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
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
@ -53,8 +54,15 @@ define-command -hidden sass-trim-indent %{
|
|||
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
||||
}
|
||||
|
||||
define-command -hidden sass-indent-on-new-line %{
|
||||
evaluate-commands -draft -itersel %{
|
||||
define-command -hidden sass-indent-on-closing-brace %<
|
||||
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
|
||||
try %{ execute-keys -draft k <a-x> s ^\h*\K/\h* <ret> y gh j P }
|
||||
# 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> }
|
||||
# avoid indent after properties and comments
|
||||
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-&> ]
|
||||
>
|
||||
>
|
||||
|
||||
}
|
||||
§
|
||||
|
|
|
@ -69,6 +69,8 @@ define-command -hidden scala-indent-on-new-line %[
|
|||
try %[ execute-keys -draft k : scala-trim-indent <ret> ]
|
||||
# indent after lines ending with {
|
||||
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-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
|
|
|
@ -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> =
|
||||
# deindent closing }
|
||||
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-&> =
|
||||
|
||||
]
|
||||
]
|
||||
|
|
|
@ -121,6 +121,8 @@ define-command -hidden zig-indent-on-new-line %<
|
|||
try %< execute-keys -draft <semicolon> K <a-&> >
|
||||
# indent after lines ending in {
|
||||
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
|
||||
try %< execute-keys -draft k : zig-trim-indent <ret> >
|
||||
|
|
1
test/indent/c-family/deindent-function-closing-brace/cmd
Normal file
1
test/indent/c-family/deindent-function-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
15
test/indent/c-family/deindent-function-closing-brace/in
Normal file
15
test/indent/c-family/deindent-function-closing-brace/in
Normal 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()%( )}
|
21
test/indent/c-family/deindent-function-closing-brace/out
Normal file
21
test/indent/c-family/deindent-function-closing-brace/out
Normal 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()
|
||||
}
|
3
test/indent/c-family/deindent-function-closing-brace/rc
Normal file
3
test/indent/c-family/deindent-function-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/c-family.kak"
|
||||
set buffer filetype cpp
|
1
test/indent/c-family/deindent-generic-closing-brace/cmd
Normal file
1
test/indent/c-family/deindent-generic-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
31
test/indent/c-family/deindent-generic-closing-brace/in
Normal file
31
test/indent/c-family/deindent-generic-closing-brace/in
Normal file
|
@ -0,0 +1,31 @@
|
|||
{%( )}
|
||||
|
||||
{%( )
|
||||
}
|
||||
|
||||
{%( )bar()}
|
||||
|
||||
{%( )bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{(%( ))}
|
||||
|
||||
{(%( )
|
||||
)}
|
||||
|
||||
{(%( )foo())}
|
||||
|
||||
{(%( )foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
43
test/indent/c-family/deindent-generic-closing-brace/out
Normal file
43
test/indent/c-family/deindent-generic-closing-brace/out
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
bar()}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{(
|
||||
)}
|
||||
|
||||
{(
|
||||
|
||||
)}
|
||||
|
||||
{(
|
||||
foo())}
|
||||
|
||||
{(
|
||||
foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
3
test/indent/c-family/deindent-generic-closing-brace/rc
Normal file
3
test/indent/c-family/deindent-generic-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/c-family.kak"
|
||||
set buffer filetype cpp
|
1
test/indent/c-family/deindent-if-closing-brace/cmd
Normal file
1
test/indent/c-family/deindent-if-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
15
test/indent/c-family/deindent-if-closing-brace/in
Normal file
15
test/indent/c-family/deindent-if-closing-brace/in
Normal file
|
@ -0,0 +1,15 @@
|
|||
if (1) {%( )}
|
||||
|
||||
if (1) {%( )
|
||||
}
|
||||
|
||||
if (1) {%( )bar()}
|
||||
|
||||
if (1) {%( )bar()
|
||||
}
|
||||
|
||||
if (1) {
|
||||
bar()%( )}
|
||||
|
||||
if (1) {
|
||||
bar()%( )}
|
21
test/indent/c-family/deindent-if-closing-brace/out
Normal file
21
test/indent/c-family/deindent-if-closing-brace/out
Normal file
|
@ -0,0 +1,21 @@
|
|||
if (1) {
|
||||
}
|
||||
|
||||
if (1) {
|
||||
|
||||
}
|
||||
|
||||
if (1) {
|
||||
bar()}
|
||||
|
||||
if (1) {
|
||||
bar()
|
||||
}
|
||||
|
||||
if (1) {
|
||||
bar()
|
||||
}
|
||||
|
||||
if (1) {
|
||||
bar()
|
||||
}
|
3
test/indent/c-family/deindent-if-closing-brace/rc
Normal file
3
test/indent/c-family/deindent-if-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/c-family.kak"
|
||||
set buffer filetype cpp
|
1
test/indent/go/deindent-function-closing-brace/cmd
Normal file
1
test/indent/go/deindent-function-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
15
test/indent/go/deindent-function-closing-brace/in
Normal file
15
test/indent/go/deindent-function-closing-brace/in
Normal 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()%( )}
|
21
test/indent/go/deindent-function-closing-brace/out
Normal file
21
test/indent/go/deindent-function-closing-brace/out
Normal 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()
|
||||
}
|
3
test/indent/go/deindent-function-closing-brace/rc
Normal file
3
test/indent/go/deindent-function-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/go.kak"
|
||||
set buffer filetype go
|
1
test/indent/go/deindent-generic-closing-brace/cmd
Normal file
1
test/indent/go/deindent-generic-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
31
test/indent/go/deindent-generic-closing-brace/in
Normal file
31
test/indent/go/deindent-generic-closing-brace/in
Normal file
|
@ -0,0 +1,31 @@
|
|||
{%( )}
|
||||
|
||||
{%( )
|
||||
}
|
||||
|
||||
{%( )bar()}
|
||||
|
||||
{%( )bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{(%( ))}
|
||||
|
||||
{(%( )
|
||||
)}
|
||||
|
||||
{(%( )foo())}
|
||||
|
||||
{(%( )foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
43
test/indent/go/deindent-generic-closing-brace/out
Normal file
43
test/indent/go/deindent-generic-closing-brace/out
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
bar()}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{(
|
||||
)}
|
||||
|
||||
{(
|
||||
|
||||
)}
|
||||
|
||||
{(
|
||||
foo())}
|
||||
|
||||
{(
|
||||
foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
3
test/indent/go/deindent-generic-closing-brace/rc
Normal file
3
test/indent/go/deindent-generic-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/go.kak"
|
||||
set buffer filetype go
|
1
test/indent/go/deindent-if-closing-brace/cmd
Normal file
1
test/indent/go/deindent-if-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
12
test/indent/go/deindent-if-closing-brace/in
Normal file
12
test/indent/go/deindent-if-closing-brace/in
Normal file
|
@ -0,0 +1,12 @@
|
|||
if true {%( )}
|
||||
|
||||
if true {%( )
|
||||
}
|
||||
|
||||
if true {%( )bar()}
|
||||
|
||||
if true {%( )bar()
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()%( )}
|
17
test/indent/go/deindent-if-closing-brace/out
Normal file
17
test/indent/go/deindent-if-closing-brace/out
Normal file
|
@ -0,0 +1,17 @@
|
|||
if true {
|
||||
}
|
||||
|
||||
if true {
|
||||
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()}
|
||||
|
||||
if true {
|
||||
bar()
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()
|
||||
}
|
3
test/indent/go/deindent-if-closing-brace/rc
Normal file
3
test/indent/go/deindent-if-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/go.kak"
|
||||
set buffer filetype go
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
|||
for (let i = 1; i < 5; ++i) {%( )}
|
12
test/indent/javascript/deindent-complex-brace-structure/out
Normal file
12
test/indent/javascript/deindent-complex-brace-structure/out
Normal file
|
@ -0,0 +1,12 @@
|
|||
for (let i = 1; i < 5; ++i) {
|
||||
if (true) {
|
||||
console.log(
|
||||
{
|
||||
foo: { bar: 1 },
|
||||
},
|
||||
{
|
||||
baz: { bam: 2 },
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/javascript.kak"
|
||||
set buffer filetype javascript
|
1
test/indent/rust/deindent-function-closing-brace/cmd
Normal file
1
test/indent/rust/deindent-function-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
15
test/indent/rust/deindent-function-closing-brace/in
Normal file
15
test/indent/rust/deindent-function-closing-brace/in
Normal 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()%( )}
|
21
test/indent/rust/deindent-function-closing-brace/out
Normal file
21
test/indent/rust/deindent-function-closing-brace/out
Normal 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()
|
||||
}
|
3
test/indent/rust/deindent-function-closing-brace/rc
Normal file
3
test/indent/rust/deindent-function-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/rust.kak"
|
||||
set buffer filetype rust
|
1
test/indent/rust/deindent-generic-closing-brace/cmd
Normal file
1
test/indent/rust/deindent-generic-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
31
test/indent/rust/deindent-generic-closing-brace/in
Normal file
31
test/indent/rust/deindent-generic-closing-brace/in
Normal file
|
@ -0,0 +1,31 @@
|
|||
{%( )}
|
||||
|
||||
{%( )
|
||||
}
|
||||
|
||||
{%( )bar()}
|
||||
|
||||
{%( )bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{
|
||||
bar()%( )}
|
||||
|
||||
{(%( ))}
|
||||
|
||||
{(%( )
|
||||
)}
|
||||
|
||||
{(%( )foo())}
|
||||
|
||||
{(%( )foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
||||
|
||||
{(
|
||||
bar()%( ))}
|
43
test/indent/rust/deindent-generic-closing-brace/out
Normal file
43
test/indent/rust/deindent-generic-closing-brace/out
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
bar()}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{
|
||||
bar()
|
||||
}
|
||||
|
||||
{(
|
||||
)}
|
||||
|
||||
{(
|
||||
|
||||
)}
|
||||
|
||||
{(
|
||||
foo())}
|
||||
|
||||
{(
|
||||
foo()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
||||
|
||||
{(
|
||||
bar()
|
||||
)}
|
3
test/indent/rust/deindent-generic-closing-brace/rc
Normal file
3
test/indent/rust/deindent-generic-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/rust.kak"
|
||||
set buffer filetype rust
|
1
test/indent/rust/deindent-if-closing-brace/cmd
Normal file
1
test/indent/rust/deindent-if-closing-brace/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
c<ret>
|
15
test/indent/rust/deindent-if-closing-brace/in
Normal file
15
test/indent/rust/deindent-if-closing-brace/in
Normal file
|
@ -0,0 +1,15 @@
|
|||
if true {%( )}
|
||||
|
||||
if true {%( )
|
||||
}
|
||||
|
||||
if true {%( )bar()}
|
||||
|
||||
if true {%( )bar()
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()%( )}
|
||||
|
||||
if true {
|
||||
bar()%( )}
|
21
test/indent/rust/deindent-if-closing-brace/out
Normal file
21
test/indent/rust/deindent-if-closing-brace/out
Normal file
|
@ -0,0 +1,21 @@
|
|||
if true {
|
||||
}
|
||||
|
||||
if true {
|
||||
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()}
|
||||
|
||||
if true {
|
||||
bar()
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()
|
||||
}
|
||||
|
||||
if true {
|
||||
bar()
|
||||
}
|
3
test/indent/rust/deindent-if-closing-brace/rc
Normal file
3
test/indent/rust/deindent-if-closing-brace/rc
Normal file
|
@ -0,0 +1,3 @@
|
|||
source "%val{runtime}/colors/default.kak"
|
||||
source "%val{runtime}/rc/filetype/rust.kak"
|
||||
set buffer filetype rust
|
Loading…
Reference in New Issue
Block a user