AutoYADM commit: 2025-07-09 13:06:20
This commit is contained in:
parent
2c49e5ee47
commit
0947338afb
1 changed files with 13 additions and 24 deletions
|
@ -1,26 +1,15 @@
|
||||||
declare-option str markdown_formatcmd %{
|
# format markdown, ignoring block images!
|
||||||
if dprint output-resolved-config >/dev/null 2>&1; then
|
define-command markdown-fmt %{
|
||||||
dprint fmt --stdin md
|
evaluate-commands -draft -save-regs "/l" %{
|
||||||
else
|
# block level images regex
|
||||||
dprint fmt --stdin md --config "$HOME/.dprint.jsonc"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
define-command markdown-fmt-impl %{
|
|
||||||
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*!\[.*\]\(.*\)$'
|
set-register / '(?S)^\h*!\[.*\]\(.*\)$'
|
||||||
execute-keys '%s<ret>"lyc<lt>!--𝅙--<gt><esc>'
|
# select, yank, replace with comment
|
||||||
set-register | %opt{markdown_formatcmd}
|
execute-keys '%s<ret>"lyc<lt>!--img𝅙img--<gt><esc>'
|
||||||
execute-keys '%|<ret>'
|
# pass to formatter
|
||||||
set-register / '(?S)^\h*<!--𝅙-->'
|
format
|
||||||
execute-keys '%s<ret>"lR%"fy'
|
# select the comments, replace with original image
|
||||||
buffer %reg{b}
|
set-register / '(?S)^\h*<!--img𝅙img-->'
|
||||||
delete-buffer %reg{s}
|
execute-keys '%s<ret>"lR'
|
||||||
execute-keys '%"fR'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +27,8 @@ hook global WinSetOption filetype=markdown %{
|
||||||
dprint fmt --stdin md --config "$HOME/.dprint.jsonc"
|
dprint fmt --stdin md --config "$HOME/.dprint.jsonc"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
hook -group markdown-auto-format window BufWritePre .* { markdown-fmt-impl }
|
hook -group markdown-auto-format window BufWritePre .* %{ markdown-fmt }
|
||||||
map window normal = ': markdown-fmt-impl<ret>'
|
map window normal = ': markdown-fmt<ret>'
|
||||||
|
|
||||||
# override formatting commands
|
# override formatting commands
|
||||||
define-command -override -hidden markdown-trim-indent %{
|
define-command -override -hidden markdown-trim-indent %{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue