mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 17:31:44 +03:00
Give commands that do not indent their own insert
hook
This commit is contained in:
parent
ad06f3f92c
commit
a31d947e1d
@ -75,10 +75,15 @@ def -hidden _ruby_indent_on_new_line %{
|
|||||||
eval -draft -itersel %{
|
eval -draft -itersel %{
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
try %{ exec -draft K <a-&> }
|
try %{ exec -draft K <a-&> }
|
||||||
# copy _#_ comment prefix and following white spaces
|
|
||||||
try %{ exec -draft k x s ^ \h * \K \# \h * <ret> y j p }
|
|
||||||
# indent after start structure
|
# indent after start structure
|
||||||
try %{ exec -draft k x <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> }
|
try %{ exec -draft k x <a-k> ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b <ret> j <a-gt> }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def -hidden _ruby_insert_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 }
|
||||||
# wisely add end structure
|
# wisely add end structure
|
||||||
eval -save-regs x %{
|
eval -save-regs x %{
|
||||||
try %{ exec -draft k x s ^ \h + <ret> \" x y } catch %{ reg x '' }
|
try %{ exec -draft k x s ^ \h + <ret> \" x y } catch %{ reg x '' }
|
||||||
@ -95,6 +100,7 @@ hook global WinSetOption filetype=ruby %{
|
|||||||
|
|
||||||
hook window InsertChar .* -group ruby-indent _ruby_indent_on_char
|
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-indent _ruby_indent_on_new_line
|
||||||
|
hook window InsertChar \n -group ruby-insert _ruby_insert_on_new_line
|
||||||
|
|
||||||
set window comment_line_chars '#'
|
set window comment_line_chars '#'
|
||||||
set window comment_selection_chars '^begin=:^=end'
|
set window comment_selection_chars '^begin=:^=end'
|
||||||
|
Loading…
Reference in New Issue
Block a user