Copy comments *before* copying indentation

Fixes #1118
This commit is contained in:
Maxime Coste 2017-01-11 13:56:48 +00:00
parent 8c55acb076
commit 5989903e7c
21 changed files with 38 additions and 38 deletions

View File

@ -75,8 +75,8 @@ hook -group fish-highlight global WinSetOption filetype=fish %{ add-highlighter
hook global WinSetOption filetype=fish %{
hook window InsertChar .* -group fish-indent _fish_indent_on_char
hook window InsertChar \n -group fish-indent _fish_indent_on_new_line
hook window InsertChar \n -group fish-insert _fish_insert_on_new_line
hook window InsertChar \n -group fish-indent _fish_indent_on_new_line
}
hook -group fish-highlight global WinSetOption filetype=(?!fish).* %{ remove-highlighter fish }

View File

@ -38,14 +38,14 @@ def -hidden _haskell_filter_around_selections %{
def -hidden _haskell_indent_on_new_line %{
eval -draft -itersel %{
# copy -- comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K--\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# align to first clause
try %{ exec -draft <space> k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* <ret> s \`|.\' <ret> & }
# filter previous line
try %{ exec -draft k : _haskell_filter_around_selections <ret> }
# copy -- comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K--\h* <ret> y gh j P }
# indent after lines beginning with condition or ending with expression or =(
try %{ exec -draft <space> k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> }
}

View File

@ -51,12 +51,12 @@ def -hidden _javascript_indent_on_char %<
def -hidden _javascript_indent_on_new_line %<
eval -draft -itersel %<
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _javascript_filter_around_selections <ret> }
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# indent after lines beginning / ending with opener token
try %_ exec -draft k x <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
>

View File

@ -96,8 +96,8 @@ hook -group lua-highlight global WinSetOption filetype=lua %{ add-highlighter re
hook global WinSetOption filetype=lua %{
hook window InsertChar .* -group lua-indent _lua_indent_on_char
hook window InsertChar \n -group lua-indent _lua_indent_on_new_line
hook window InsertChar \n -group lua-insert _lua_insert_on_new_line
hook window InsertChar \n -group lua-indent _lua_indent_on_new_line
alias window alt lua-alternative-file
}

View File

@ -126,12 +126,12 @@ add-highlighter -group /markdown/content regex \H\K\h\h$ 0:PrimarySelection
def -hidden _markdown_indent_on_new_line %{
eval -draft -itersel %{
# copy block quote(s), list item prefix and following white spaces
try %{ exec -draft k x s ^\h*\K((>\h*)|[*+-])+\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# remove trailing white spaces
try %{ exec -draft -itersel %{ k<a-x> s \h+$ <ret> d } }
# copy block quote(s), list item prefix and following white spaces
try %{ exec -draft k x s ^\h*\K((>\h*)|[*+-])+\h* <ret> y gh j P }
}
}

View File

@ -148,8 +148,8 @@ hook -group ruby-highlight global WinSetOption filetype=ruby %{ add-highlighter
hook global WinSetOption filetype=ruby %{
hook window InsertChar .* -group ruby-indent _ruby_indent_on_char
hook window InsertChar \n -group ruby-indent _ruby_indent_on_new_line
hook window InsertChar \n -group ruby-insert _ruby_insert_on_new_line
hook window InsertChar \n -group ruby-indent _ruby_indent_on_new_line
alias window alt ruby-alternative-file
}

View File

@ -41,12 +41,12 @@ def -hidden _rust_filter_around_selections %{
def -hidden _rust_indent_on_new_line %~
eval -draft -itersel %<
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K//\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _rust_filter_around_selections <ret> }
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K//\h* <ret> y gh j P }
# indent after lines ending with { or (
try %[ exec -draft k <a-x> <a-k> [{(]\h*$ <ret> j <a-gt> ]
# align to opening paren of previous line

View File

@ -41,12 +41,12 @@ def -hidden _scala_filter_around_selections %{
def -hidden _scala_indent_on_new_line %[
eval -draft -itersel %[
# copy // comments prefix and following white spaces
try %[ exec -draft k x s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent
try %[ exec -draft <space> K <a-&> ]
# filter previous line
try %[ exec -draft k : _scala_filter_around_selections <ret> ]
# copy // comments prefix and following white spaces
try %[ exec -draft k x s ^\h*\K#\h* <ret> y gh j P ]
# indent after lines ending with {
try %[ exec -draft k x <a-k> \{$ <ret> j <a-gt> ]
]

View File

@ -34,12 +34,12 @@ def -hidden _yaml_filter_around_selections %{
def -hidden _yaml_indent_on_new_line %{
eval -draft -itersel %{
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _yaml_filter_around_selections <ret> }
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# indent after :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> }
}

View File

@ -238,11 +238,11 @@ hook global WinSetOption filetype=(c|cpp|objc) %[
}
hook -group c-family-indent window InsertEnd .* c-family-trim-autoindent
hook -group c-family-insert window InsertChar \n c-family-insert-on-newline
hook -group c-family-indent window InsertChar \n c-family-indent-on-newline
hook -group c-family-indent window InsertChar \{ c-family-indent-on-opening-curly-brace
hook -group c-family-indent window InsertChar \} c-family-indent-on-closing-curly-brace
hook -group c-family-insert window InsertChar \} c-family-insert-on-closing-curly-brace
hook -group c-family-insert window InsertChar \n c-family-insert-on-newline
alias window alt c-family-alternative-file
]

View File

@ -52,12 +52,12 @@ add-highlighter -group /kakrc/shell ref sh
def -hidden kak-indent-on-new-line %{
eval -draft -itersel %{
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d }
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*#\h* <ret> y jgh P }
# indent after line ending with %[[:punct:]]
try %{ exec -draft k <a-x> <a-k> \%[[:punct:]]$ <ret> j <a-gt> }
}

View File

@ -65,12 +65,12 @@ add-highlighter -group /python/comment fill comment
def -hidden python-indent-on-new-line %{
eval -draft -itersel %{
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*#\h* <ret> y jgh P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d }
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*#\h* <ret> y jgh P }
# indent after line ending with :
try %{ exec -draft <space> k x <a-k> :$ <ret> j <a-gt> }
}

View File

@ -31,12 +31,12 @@ def -hidden _cabal_filter_around_selections %{
def -hidden _cabal_indent_on_new_line %[
eval -draft -itersel %[
# copy '#' comment prefix and following white spaces
try %[ exec -draft k x s ^\h*\K#\h* <ret> y gh j P ]
# preserve previous line indent
try %[ exec -draft <space> K <a-&> ]
# filter previous line
try %[ exec -draft k : _cabal_filter_around_selections <ret> ]
# copy '#' comment prefix and following white spaces
try %[ exec -draft k x s ^\h*\K#\h* <ret> y gh j P ]
# indent after lines ending with { or :
try %[ exec -draft <space> k x <a-k> [:{]$ <ret> j <a-gt> ]
]

View File

@ -55,12 +55,12 @@ def -hidden _coffee_filter_around_selections %{
def -hidden _coffee_indent_on_new_line %{
eval -draft -itersel %{
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^ \h * \K \# \h * <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft K <a-&> }
# filter previous line
try %{ exec -draft k : _coffee_filter_around_selections <ret> }
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^ \h * \K \# \h * <ret> y gh j P }
# indent after start structure
try %{ exec -draft k x <a-k> ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ <ret> j <a-gt> }
}

View File

@ -63,12 +63,12 @@ def -hidden _cucumber_filter_around_selections %{
def -hidden _cucumber_indent_on_new_line %{
eval -draft -itersel %{
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _cucumber_filter_around_selections <ret> }
# copy '#' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# indent after lines containing :
try %{ exec -draft <space> k x <a-k> : <ret> j <a-gt> }
}

View File

@ -40,12 +40,12 @@ def -hidden _haml_filter_around_selections %{
def -hidden _haml_indent_on_new_line %{
eval -draft -itersel %{
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _haml_filter_around_selections <ret> }
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y gh j P }
# indent after lines beginning with : or -
try %{ exec -draft k x <a-k> ^\h*[:-] <ret> j <a-gt> }
}

View File

@ -41,12 +41,12 @@ def -hidden _hbs_filter_around_selections %{
def -hidden _hbs_indent_on_new_line %{
eval -draft -itersel %{
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y j p }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _hbs_filter_around_selections <ret> }
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y j p }
# indent after lines beginning with : or -
try %{ exec -draft k x <a-k> ^\h*[:-] <ret> j <a-gt> }
}

View File

@ -76,12 +76,12 @@ def -hidden _moon_indent_on_char %{
def -hidden _moon_indent_on_new_line %{
eval -draft -itersel %{
# copy -- comment prefix and following white spaces
try %{ exec -draft k x s ^ \h * \K -- \h * <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft K <a-&> }
# filter previous line
try %{ exec -draft k : _moon_filter_around_selections <ret> }
# copy -- comment prefix and following white spaces
try %{ exec -draft k x s ^ \h * \K -- \h * <ret> y gh j P }
# indent after start structure
try %{ exec -draft k x <a-k> ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ <ret> j <a-gt> }
# deindent after return statements

View File

@ -45,12 +45,12 @@ def -hidden _php_indent_on_char %<
def -hidden _php_indent_on_new_line %<
eval -draft -itersel %<
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _php_filter_around_selections <ret> }
# copy // comments prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# indent after lines beginning / ending with opener token
try %_ exec -draft k x <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
>

View File

@ -44,12 +44,12 @@ def -hidden _ragel_indent_on_char %<
def -hidden _ragel_indent_on_new_line %<
eval -draft -itersel %<
# copy _#_ comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _ragel_filter_around_selections <ret> }
# copy _#_ comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K#\h* <ret> y gh j P }
# indent after lines ending with opener token
try %< exec -draft k x <a-k> [[{(*]$ <ret> j <a-gt> >
>

View File

@ -36,12 +36,12 @@ def -hidden _sass_filter_around_selections %{
def -hidden _sass_indent_on_new_line %{
eval -draft -itersel %{
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y gh j P }
# preserve previous line indent
try %{ exec -draft <space> K <a-&> }
# filter previous line
try %{ exec -draft k : _sass_filter_around_selections <ret> }
# copy '/' comment prefix and following white spaces
try %{ exec -draft k x s ^\h*\K/\h* <ret> y gh j P }
# avoid indent after properties and comments
try %{ exec -draft k x <a-K> [:/] <ret> j <a-gt> }
}