AutoYADM commit: 2025-06-24 20:30:05
This commit is contained in:
parent
6d4c81fc68
commit
2bbd2e7fc1
1 changed files with 26 additions and 23 deletions
|
@ -1,7 +1,6 @@
|
||||||
declare-option -hidden str fmt_command %{
|
declare-option -hidden str fmt_command %{
|
||||||
fmt -u | perl -CS -pe 's/([.!?])\s{2,}/\1 /g'
|
# fmt --uniform-spacing "--goal=$kak_opt_fmt_width" "--width=$kak_opt_fmt_width" | perl -CS -pe 's/([.!?])\s{2,}/\1 /g'
|
||||||
# original:
|
fmt -u -w "$kak_opt_fmt_width" | perl -CS -pe 's/([.!?])\s{2,}/\1 /g'
|
||||||
# fmt --uniform-spacing "--goal=$kak_opt_fmt_width" "--width=$kak_opt_fmt_width" | sed "s/\. /. /g"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare-option -hidden str fmt_mode fail
|
declare-option -hidden str fmt_mode fail
|
||||||
|
@ -27,32 +26,36 @@ define-command -docstring "enable autofmt at window scope" fmt-enable-window %{
|
||||||
}
|
}
|
||||||
|
|
||||||
define-command -hidden fmt-impl-window %{
|
define-command -hidden fmt-impl-window %{
|
||||||
evaluate-commands -save-regs "c|s" %{
|
try %{
|
||||||
evaluate-commands -draft %{
|
# do nothing if the line isn't too long
|
||||||
execute-keys ';'
|
execute-keys -draft "x<a-k>^[^\n]{%opt{fmt_width},}[^\n]<ret>"
|
||||||
|
evaluate-commands -save-regs "c|s" %{
|
||||||
|
evaluate-commands -draft %{
|
||||||
|
execute-keys ';'
|
||||||
|
|
||||||
# Insert a newline after selections which close a
|
# Insert a newline after selections which close a
|
||||||
# paragraph.
|
# paragraph.
|
||||||
try %{ execute-keys -draft 'L<a-k>\n\n<ret><a-o>' }
|
try %{ execute-keys -draft 'L<a-k>\n\n<ret><a-o>' }
|
||||||
|
|
||||||
# If we were to yank newlines and paste them in the below
|
# If we were to yank newlines and paste them in the below
|
||||||
# 'execute-keys', we would end up typing in reverse,
|
# 'execute-keys', we would end up typing in reverse,
|
||||||
# as the newline would be repeatedly pasted and removed
|
# as the newline would be repeatedly pasted and removed
|
||||||
# before the typed content. So, we remove them.
|
# before the typed content. So, we remove them.
|
||||||
evaluate-commands %exp{ set-register c %sh{
|
evaluate-commands %exp{ set-register c %sh{
|
||||||
printf %s "$kak_quoted_selections" | tr -d "\n"
|
printf %s "$kak_quoted_selections" | tr -d "\n"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
set-register | %opt{fmt_command}
|
set-register | %opt{fmt_command}
|
||||||
|
|
||||||
# We use '' (U+E000) to save and restore the cursor
|
# We use '' (U+E000) to save and restore the cursor
|
||||||
# position after the pipe.
|
# position after the pipe.
|
||||||
execute-keys 'c<esc><a-i>p<a-j>S\n+\z<ret>|<ret>s<ret>d"cP'
|
execute-keys 'c<esc><a-i>p<a-j>S\n+\z<ret>|<ret>s<ret>d"cP'
|
||||||
|
|
||||||
set-register s "%val{selections_desc}"
|
set-register s "%val{selections_desc}"
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluate-commands %exp{ select %reg{s} }
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate-commands %exp{ select %reg{s} }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue