From 5c03e2bd5445c5bd9c9535d30223e81fd28e2107 Mon Sep 17 00:00:00 2001 From: SeerLite Date: Thu, 1 Apr 2021 21:18:11 -0300 Subject: [PATCH] rc markdown: Add -insert hook --- rc/filetype/markdown.kak | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 43f3e6012..38e32ea31 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -14,6 +14,7 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ hook global WinSetOption filetype=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 -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } } @@ -96,10 +97,12 @@ add-highlighter shared/markdown/inline/text/ regex "^( {4}|\t)+([^\n]+)" 2:meta # Commands # ‾‾‾‾‾‾‾‾ +define-command -hidden markdown-insert-on-new-line %{ + try %{ execute-keys -draft -itersel k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } +} + define-command -hidden markdown-indent-on-new-line %{ evaluate-commands -draft -itersel %{ - # copy block quote(s), list item prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # remove trailing white spaces