AutoYADM commit: 2025-07-09 12:51:02
This commit is contained in:
parent
5289d1995f
commit
2c49e5ee47
1 changed files with 19 additions and 4 deletions
|
@ -1,12 +1,26 @@
|
|||
declare-option str markdown_formatcmd %{
|
||||
if dprint output-resolved-config >/dev/null 2>&1; then
|
||||
dprint fmt --stdin md
|
||||
else
|
||||
dprint fmt --stdin md --config "$HOME/.dprint.jsonc"
|
||||
fi
|
||||
}
|
||||
define-command markdown-fmt-impl %{
|
||||
evaluate-commands -save-regs "fbs/" %{
|
||||
evaluate-commands -draft -save-regs "fbs/l" %{
|
||||
set-register b %reg{percent}
|
||||
execute-keys -draft '%"fy'
|
||||
edit -scratch
|
||||
execute-keys '"fR'
|
||||
set-register s %reg{percent}
|
||||
set-register / '(?S)^\h*!\[.*\]\(.*\)$'
|
||||
execute-keys '%s<ret>c<lt>!--FICMD<c-r>#--<gt>'
|
||||
# format
|
||||
execute-keys '%s<ret>"lyc<lt>!--𝅙--<gt><esc>'
|
||||
set-register | %opt{markdown_formatcmd}
|
||||
execute-keys '%|<ret>'
|
||||
set-register / '(?S)^\h*<!--𝅙-->'
|
||||
execute-keys '%s<ret>"lR%"fy'
|
||||
buffer %reg{b}
|
||||
delete-buffer %reg{s}
|
||||
execute-keys '%"fR'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +38,8 @@ hook global WinSetOption filetype=markdown %{
|
|||
dprint fmt --stdin md --config "$HOME/.dprint.jsonc"
|
||||
fi
|
||||
}
|
||||
hook -group markdown-auto-format window BufWritePre .* { format }
|
||||
hook -group markdown-auto-format window BufWritePre .* { markdown-fmt-impl }
|
||||
map window normal = ': markdown-fmt-impl<ret>'
|
||||
|
||||
# override formatting commands
|
||||
define-command -override -hidden markdown-trim-indent %{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue