From 89b50daa66cc843e256f599462bb57bce694d923 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Mon, 22 Jul 2019 19:01:40 -0700 Subject: [PATCH] Use module alias pattern for markdown dynamic loading --- rc/filetype/c-family.kak | 6 ++++++ rc/filetype/javascript.kak | 3 +++ rc/filetype/markdown.kak | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index e4217a0b..75e7359d 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -1,3 +1,4 @@ +# Detection hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{ set-option buffer filetype cpp } @@ -58,6 +59,11 @@ hook -group objc-highlight global WinSetOption filetype=objc %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc } } +# Module aliases +provide-module c %{ require-module c-family } +provide-module cpp %{ require-module c-family } +provide-module objc %{ require-module c-family } + provide-module c-family %§ diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 6f60a4ec..c1985195 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -34,6 +34,9 @@ hook -group typescript-highlight global WinSetOption filetype=typescript %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typescript } } +# Aliases +# ‾‾‾‾‾‾‾ +provide-module typescript %{ require-module javascript } provide-module javascript %§ diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 5b456393..f3295ab0 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -16,13 +16,14 @@ hook global WinSetOption filetype=markdown %{ hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } - - hook -group markdown-load buffer NormalIdle .* %{ try %{ evaluate-commands -draft %{ - execute-keys '%s^\h*```\h*\K[^\n]+$' - evaluate-commands -itersel %{ require-module %val{selection} } - }}} } +hook -group markdown-load-languages global WinSetOption filetype=markdown %{ + hook window NormalIdle .* markdown-load-languages + hook window InsertIdle .* markdown-load-languages +} + + hook -group markdown-highlight global WinSetOption filetype=markdown %{ add-highlighter window/markdown ref markdown hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/markdown } @@ -94,4 +95,11 @@ define-command -hidden markdown-indent-on-new-line %{ } } +define-command -hidden markdown-load-languages %{ + evaluate-commands -draft %{ try %{ + execute-keys 'gtGbGls```\h*\K[^\s]+' + evaluate-commands -itersel %{ require-module %val{selection} } + }} +} + }