From 8e698e0054ddca64da603d4a26e37946bd5da7b1 Mon Sep 17 00:00:00 2001 From: Matt Schick Date: Sat, 6 Oct 2018 08:39:01 -0500 Subject: [PATCH] Simplify handlebars adding/removal hooks Removing the handlebars highlighters when a client toggles away from hbs window unintentionally causes other clients attached to hbs windows to no longer highlight correctly. The only other option is to copy the entire html highlighter and all of it's rules, but that seems like a maitenance headache. So instead, just leave the hbs rules injected into the html rules once the user opens any handlebars file. It's not ideal, but I'd say it's the least bad option. --- rc/extra/hbs.kak | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/rc/extra/hbs.kak b/rc/extra/hbs.kak index 0ce39c87..6f02ca32 100644 --- a/rc/extra/hbs.kak +++ b/rc/extra/hbs.kak @@ -80,29 +80,8 @@ define-command -hidden maybe-add-hbs-to-html %{ evaluate-commands %sh{ fi } } -define-command -hidden remove-hbs-from-html %{ - remove-highlighter shared/html/hbs - remove-highlighter shared/html/tag/hbs - set-option global hbs_highlighters_enabled false -} - -# The two hooks below are wrapped in this "-once" so that they only get enabled -# when atleast one .hbs file is opened. This way people who don't edit .hbs files -# aren't paying a performance penality of these hooks always executing. -hook -once global BufCreate .*\.(hbs) %{ - - hook -group hbs-highlight global WinDisplay .*\.(hbs) %{ evaluate-commands %sh{ - if [ "$kak_opt_filetype" = "hbs" ]; then - printf %s "maybe-add-hbs-to-html" - fi - } } - - hook -group hbs-highlight global WinDisplay .*\.(?!hbs).* %{ - remove-hbs-from-html - } -} - hook -group hbs-highlight global WinSetOption filetype=hbs %{ + maybe-add-hbs-to-html add-highlighter window/hbs-file ref hbs-file }