Merge remote-tracking branch 'SeerLite/markdown-fixes'

This commit is contained in:
Maxime Coste 2021-04-07 19:49:33 +10:00
commit 2f31fc7744
6 changed files with 12 additions and 9 deletions

View File

@ -14,6 +14,7 @@ hook global BufCreate .*[.](markdown|md|mkd) %{
hook global WinSetOption filetype=markdown %{ hook global WinSetOption filetype=markdown %{
require-module markdown require-module markdown
hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line
hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ }
} }
@ -47,7 +48,7 @@ evaluate-commands %sh{
ruby rust sass scala scss sh swift toml tupfile typescript yaml sql ruby rust sass scala scss sh swift toml tupfile typescript yaml sql
" "
for lang in ${languages}; do for lang in ${languages}; do
printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*(%s|\\{[.=]?%s\\}))\\b ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}" printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*(%s\\b|\\{[.=]?%s\\}) ^(\h*)``` regions\n' "${lang}" "${lang}" "${lang}"
printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}" printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}"
[ "${lang}" = kak ] && ref=kakrc || ref="${lang}" [ "${lang}" = kak ] && ref=kakrc || ref="${lang}"
printf 'add-highlighter shared/markdown/%s/inner region \A```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}" printf 'add-highlighter shared/markdown/%s/inner region \A```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}"
@ -96,14 +97,16 @@ add-highlighter shared/markdown/inline/text/ regex "^( {4}|\t)+([^\n]+)" 2:meta
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden markdown-insert-on-new-line %{
try %{ execute-keys -draft -itersel k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
}
define-command -hidden markdown-indent-on-new-line %{ define-command -hidden markdown-indent-on-new-line %{
evaluate-commands -draft -itersel %{ evaluate-commands -draft -itersel %{
# copy block quote(s), list item prefix and following white spaces
try %{ execute-keys -draft k <a-x> s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* <ret> y gh j P }
# preserve previous line indent # preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> } try %{ execute-keys -draft <semicolon> K <a-&> }
# remove trailing white spaces # remove trailing white spaces
try %{ execute-keys -draft -itersel %{ k<a-x> s \h+$ <ret> d } } try %{ execute-keys -draft k <a-x> s \h+$ <ret> d }
} }
} }