From 898d45f5d5e946c7613bcfd22c383ef1052f8741 Mon Sep 17 00:00:00 2001 From: Olivier Perret Date: Wed, 28 Nov 2018 10:39:15 +0100 Subject: [PATCH] Change cleanup of base/ languages to use a simpler hook -once --- rc/base/clojure.kak | 13 ++++++----- rc/base/css.kak | 13 ++++++----- rc/base/d.kak | 11 +++++----- rc/base/etc.kak | 42 ++++++++++++++++++++++++------------ rc/base/fish.kak | 11 +++++----- rc/base/gas.kak | 13 +++++------ rc/base/git.kak | 10 ++++----- rc/base/go.kak | 11 +++++----- rc/base/haskell.kak | 11 +++++----- rc/base/html.kak | 21 ++++++++++-------- rc/base/ini.kak | 6 ++++-- rc/base/java.kak | 12 ++++++----- rc/base/javascript.kak | 18 +++++++--------- rc/base/json.kak | 11 +++++----- rc/base/julia.kak | 6 ++++-- rc/base/lisp.kak | 11 +++++----- rc/base/lua.kak | 18 ++++++++-------- rc/base/mail.kak | 6 ++++-- rc/base/markdown.kak | 12 +++++------ rc/base/mercurial.kak | 5 +---- rc/base/ocaml.kak | 7 +++--- rc/base/perl.kak | 11 +++++----- rc/base/restructuredtext.kak | 8 ++++--- rc/base/ruby.kak | 18 ++++++++-------- rc/base/rust.kak | 12 +++++------ rc/base/scala.kak | 13 ++++++----- rc/base/screen.kak | 3 +-- rc/base/sql.kak | 5 +---- rc/base/swift.kak | 6 ++++-- rc/base/yaml.kak | 12 +++++------ 30 files changed, 179 insertions(+), 177 deletions(-) diff --git a/rc/base/clojure.kak b/rc/base/clojure.kak index cde4fc95..d4c88c59 100644 --- a/rc/base/clojure.kak +++ b/rc/base/clojure.kak @@ -187,15 +187,14 @@ define-command -hidden clojure-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group clojure-highlight global WinSetOption filetype=clojure %{ add-highlighter window/clojure ref clojure } +hook -group clojure-highlight global WinSetOption filetype=clojure %{ + add-highlighter window/clojure ref clojure + hook -once -always window WinSetOption filetype=(?!clojure).* %{ remove-highlighter window/clojure } +} hook global WinSetOption filetype=clojure %[ hook window ModeChange insert:.* -group clojure-hooks clojure-filter-around-selections hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line + + hook -once -always window WinSetOption filetype=(?!clojure).* %{ remove-hooks window clojure-.+ } ] - -hook -group clojure-highlight global WinSetOption filetype=(?!clojure).* %{ remove-highlighter window/clojure } - -hook global WinSetOption filetype=(?!clojure).* %{ - remove-hooks window clojure-.+ -} diff --git a/rc/base/css.kak b/rc/base/css.kak index d557d2cd..776bba37 100644 --- a/rc/base/css.kak +++ b/rc/base/css.kak @@ -61,17 +61,16 @@ define-command -hidden css-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group css-highlight global WinSetOption filetype=css %{ add-highlighter window/css ref css } +hook -group css-highlight global WinSetOption filetype=css %{ + add-highlighter window/css ref css + hook -once -always window WinSetOption filetype=(?!css).* %{ remove-highlighter window/css } +} hook global WinSetOption filetype=css %[ hook window ModeChange insert:.* -group css-hooks css-filter-around-selections hook window InsertChar \n -group css-indent css-indent-on-new-line hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=(?!css).* %{ remove-hooks window css-.+ } ] - -hook -group css-highlight global WinSetOption filetype=(?!css).* %{ remove-highlighter window/css } - -hook global WinSetOption filetype=(?!css).* %{ - remove-hooks window css-.+ -} diff --git a/rc/base/d.kak b/rc/base/d.kak index 6c8d9a10..a611d1ef 100644 --- a/rc/base/d.kak +++ b/rc/base/d.kak @@ -116,7 +116,10 @@ define-command -hidden d-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group d-highlight global WinSetOption filetype=d %{ add-highlighter window/d ref d } +hook -group d-highlight global WinSetOption filetype=d %{ + add-highlighter window/d ref d + hook -once -always window WinSetOption filetype=(?!d).* %{ remove-highlighter window/d } +} hook global WinSetOption filetype=d %{ # cleanup trailing whitespaces when exiting insert mode @@ -124,10 +127,6 @@ hook global WinSetOption filetype=d %{ hook window InsertChar \n -group d-indent d-indent-on-new-line hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace -} -hook -group d-highlight global WinSetOption filetype=(?!d).* %{ remove-highlighter window/d } - -hook global WinSetOption filetype=(?!d).* %{ - remove-hooks window d-.+ + hook -once -always window WinSetOptionfiletype=(?!d).* %{ remove-hooks window d-.+ } } diff --git a/rc/base/etc.kak b/rc/base/etc.kak index 9087382f..22e28d62 100644 --- a/rc/base/etc.kak +++ b/rc/base/etc.kak @@ -17,49 +17,63 @@ add-highlighter shared/etc-resolv-conf group add-highlighter shared/etc-resolv-conf/ regex ^#.*?$ 0:comment add-highlighter shared/etc-resolv-conf/ regex ^(nameserver|server|domain|sortlist|options)[\s\t]+(.*?)$ 1:type 2:attribute -hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ add-highlighter window/etc-resolv-conf ref etc-resolv-conf } -hook -group etc-resolv-conf-highlight global WinSetOption filetype=(?!etc-resolv-conf).* %{ remove-highlighter window/etc-resolv-conf } +hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ + add-highlighter window/etc-resolv-conf ref etc-resolv-conf + hook -once -always window WinSetOption filetype=(?!etc-resolv-conf).* %{ remove-highlighter window/etc-resolv-conf } +} ## /etc/hosts add-highlighter shared/etc-hosts group add-highlighter shared/etc-hosts/ regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute add-highlighter shared/etc-hosts/ regex '#.*?$' 0:comment -hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ add-highlighter window/etc-hosts ref etc-hosts } -hook -group etc-hosts-highlight global WinSetOption filetype=(?!etc-hosts).* %{ remove-highlighter window/etc-hosts } +hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ + add-highlighter window/etc-hosts ref etc-hosts + hook -once -always window WinSetOption filetype=(?!etc-hosts).* %{ remove-highlighter window/etc-hosts } +} ## /etc/fstab add-highlighter shared/etc-fstab group add-highlighter shared/etc-fstab/ regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute add-highlighter shared/etc-fstab/ regex '#.*?$' 0:comment -hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ add-highlighter window/etc-fstab ref etc-fstab } -hook -group etc-fstab-highlight global WinSetOption filetype=(?!etc-fstab).* %{ remove-highlighter window/etc-fstab } +hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ + add-highlighter window/etc-fstab ref etc-fstab + hook -once -always window WinSetOption filetype=(?!etc-fstab).* %{ remove-highlighter window/etc-fstab } +} ## /etc/group add-highlighter shared/etc-group group add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string -hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ add-highlighter window/etc-group ref etc-group } -hook -group etc-group-highlight global WinSetOption filetype=(?!etc-group).* %{ remove-highlighter window/etc-group } +hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ + add-highlighter window/etc-group ref etc-group + hook -once -always window WinSetOption filetype=(?!etc-group).* %{ remove-highlighter window/etc-group } +} ## /etc/gshadow add-highlighter shared/etc-gshadow group add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string -hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ add-highlighter window/etc-gshadow ref etc-gshadow } -hook -group etc-gshadow-highlight global WinSetOption filetype=(?!etc-gshadow).* %{ remove-highlighter window/etc-gshadow } +hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ + add-highlighter window/etc-gshadow ref etc-gshadow + hook -once -always window WinSetOption filetype=(?!etc-gshadow).* %{ remove-highlighter window/etc-gshadow } +} ## /etc/shadow add-highlighter shared/etc-shadow group add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:(.*?)?$ 1:keyword 2:type 3:value 4:value 5:value 6:value 7:value 8:value -hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ add-highlighter window/etc-shadow ref etc-shadow } -hook -group etc-shadow-highlight global WinSetOption filetype=(?!etc-shadow).* %{ remove-highlighter window/etc-shadow } +hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ + add-highlighter window/etc-shadow ref etc-shadow + hook -once -always window WinSetOption filetype=(?!etc-shadow).* %{ remove-highlighter window/etc-shadow } +} ## /etc/passwd add-highlighter shared/etc-passwd group add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*?)?:(.+?):(.+?)$ 1:keyword 2:type 3:value 4:value 5:string 6:attribute 7:attribute -hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ add-highlighter window/etc-passwd ref etc-passwd } -hook -group etc-passwd-highlight global WinSetOption filetype=(?!etc-passwd).* %{ remove-highlighter window/etc-passwd } +hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ + add-highlighter window/etc-passwd ref etc-passwd + hook -once -always window WinSetOption filetype=(?!etc-passwd).* %{ remove-highlighter window/etc-passwd } +} diff --git a/rc/base/fish.kak b/rc/base/fish.kak index 06b55efc..fb3b4393 100644 --- a/rc/base/fish.kak +++ b/rc/base/fish.kak @@ -70,16 +70,15 @@ define-command -hidden fish-insert-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group fish-highlight global WinSetOption filetype=fish %{ add-highlighter window/fish ref fish } +hook -group fish-highlight global WinSetOption filetype=fish %{ + add-highlighter window/fish ref fish + hook -once -always window WinSetOption filetype=(?!fish).* %{ remove-highlighter window/fish } +} hook global WinSetOption filetype=fish %{ hook window InsertChar .* -group fish-indent fish-indent-on-char hook window InsertChar \n -group fish-insert fish-insert-on-new-line hook window InsertChar \n -group fish-indent fish-indent-on-new-line -} -hook -group fish-highlight global WinSetOption filetype=(?!fish).* %{ remove-highlighter window/fish } - -hook global WinSetOption filetype=(?!fish).* %{ - remove-hooks window fish-.+ + hook -once -always window WinSetOption filetype=(?!fish).* %{ remove-hooks window fish-.+ } } diff --git a/rc/base/gas.kak b/rc/base/gas.kak index ae71c95a..be9b3c42 100644 --- a/rc/base/gas.kak +++ b/rc/base/gas.kak @@ -4,7 +4,6 @@ hook global BufCreate .*\.(s|S|asm)$ %{ set-option buffer filetype gas } - add-highlighter shared/gas regions add-highlighter shared/gas/code default-region group add-highlighter shared/gas/string region '"' (? ~ -hook -group gas-highlight global WinSetOption filetype=gas %{ add-highlighter window/gas ref gas } +hook -group gas-highlight global WinSetOption filetype=gas %{ + add-highlighter window/gas ref gas + hook -once -always window WinSetOption filetype=(?!gas).* %{ remove-highlighter window/gas } +} hook global WinSetOption filetype=gas %{ hook window InsertChar \n -group gas-indent gas-indent-on-new-line -} - -hook -group gas-highlight global WinSetOption filetype=(?!gas).* %{ remove-highlighter window/gas } - -hook global WinSetOption filetype=(?!gas).* %{ - remove-hooks window gas-indent + hook -once -always window WinSetOption filetype=(?!gas).* %{ remove-hooks window gas-.+ } } diff --git a/rc/base/git.kak b/rc/base/git.kak index 1e5b4297..0256e761 100644 --- a/rc/base/git.kak +++ b/rc/base/git.kak @@ -9,12 +9,12 @@ hook global BufCreate .*(\.gitconfig|git/config) %{ hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ add-highlighter window/git-commit-highlight regions add-highlighter window/git-commit-highlight/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option - add-highlighter window/git-commit-highlight/comments region '^\h*#' '$' group + add-highlighter window/git-commit-highlight/comments region '^\h*#' '$' group add-highlighter window/git-commit-highlight/comments/ fill cyan,default add-highlighter window/git-commit-highlight/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta -} -hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight } + hook -once -always window WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight } +} hook global BufCreate .*git-rebase-todo %{ set-option buffer filetype git-rebase @@ -24,6 +24,6 @@ hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ add-highlighter window/git-rebase-highlight group add-highlighter window/git-rebase-highlight/ regex "#[^\n]*\n" 0:cyan,default add-highlighter window/git-rebase-highlight/ regex "^(pick|edit|reword|squash|fixup|exec|drop|label|reset|merge|[persfxdltm]) (\w+)" 1:green 2:magenta -} -hook -group git-rebase-highlight global WinSetOption filetype=(?!git-rebase).* %{ remove-highlighter window/git-rebase-highlight } + hook -once -always window WinSetOption filetype=(?!git-rebase).* %{ remove-highlighter window/git-rebase-highlight } +} diff --git a/rc/base/go.kak b/rc/base/go.kak index d03aa80c..aa62d113 100644 --- a/rc/base/go.kak +++ b/rc/base/go.kak @@ -81,7 +81,10 @@ define-command -hidden go-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group go-highlight global WinSetOption filetype=go %{ add-highlighter window/go ref go } +hook -group go-highlight global WinSetOption filetype=go %{ + add-highlighter window/go ref go + hook -once -always window WinSetOption filetype=(?!go).* %{ remove-highlighter window/go } +} hook global WinSetOption filetype=go %{ # cleanup trailing whitespaces when exiting insert mode @@ -89,10 +92,6 @@ hook global WinSetOption filetype=go %{ hook window InsertChar \n -group go-indent go-indent-on-new-line hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace -} -hook -group go-highlight global WinSetOption filetype=(?!go).* %{ remove-highlighter window/go } - -hook global WinSetOption filetype=(?!go).* %{ - remove-hooks window go-.+ + hook -once -always window WinSetOption filetype=(?!go).* %{ remove-hooks window go-.+ } } diff --git a/rc/base/haskell.kak b/rc/base/haskell.kak index d3ad2215..b72c2561 100644 --- a/rc/base/haskell.kak +++ b/rc/base/haskell.kak @@ -91,16 +91,15 @@ define-command -hidden haskell-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter window/haskell ref haskell } +hook -group haskell-highlight global WinSetOption filetype=haskell %{ + add-highlighter window/haskell ref haskell + hook -once -always window WinSetOption filetype=(?!haskell).* %{ remove-highlighter window/haskell } +} hook global WinSetOption filetype=haskell %{ set-option window extra_word_chars '_' "'" hook window ModeChange insert:.* -group haskell-hooks haskell-filter-around-selections hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line -} -hook -group haskell-highlight global WinSetOption filetype=(?!haskell).* %{ remove-highlighter window/haskell } - -hook global WinSetOption filetype=(?!haskell).* %{ - remove-hooks window haskell-.+ + hook -once -always window WinSetOption filetype=(?!haskell).* %{ remove-hooks window haskell-.+ } } diff --git a/rc/base/html.kak b/rc/base/html.kak index ecf330f1..a91808f1 100644 --- a/rc/base/html.kak +++ b/rc/base/html.kak @@ -57,16 +57,19 @@ define-command -hidden html-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group html-highlight global WinSetOption filetype=(?:html|xml) %{ add-highlighter window/html ref html } - -hook global WinSetOption filetype=(?:html|xml) %{ - hook window ModeChange insert:.* -group html-hooks html-filter-around-selections - hook window InsertChar '>' -group html-indent html-indent-on-greater-than - hook window InsertChar \n -group html-indent html-indent-on-new-line +hook -group html-highlight global WinSetOption filetype=(html|xml) %{ + add-highlighter "window/%val{hook_param_capture_1}" ref html + hook -once -always window WinSetOption "filetype=(?!%val{hook_param_capture_1}).*" " + remove-highlighter ""window/%val{hook_param_capture_1}"" + " } -hook -group html-highlight global WinSetOption filetype=(?!html)(?!xml).* %{ remove-highlighter window/html } +hook global WinSetOption filetype=(html|xml) %{ + hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-hooks" html-filter-around-selections + hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than + hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line -hook global WinSetOption filetype=(?!html)(?!xml).* %{ - remove-hooks window html-.+ + hook -once -always window WinSetOption "filetype=(?!%val{hook_param_capture_1}).*" " + remove-hooks window ""%val{hook_param_capture_1}-.+"" + " } diff --git a/rc/base/ini.kak b/rc/base/ini.kak index 383bf70e..1bfca3c2 100644 --- a/rc/base/ini.kak +++ b/rc/base/ini.kak @@ -9,5 +9,7 @@ add-highlighter shared/ini/comment region '(^|\h)\K[#;]' $ fill comment add-highlighter shared/ini/code/ regex "^\h*\[[^\]]*\]" 0:title add-highlighter shared/ini/code/ regex "^\h*([^\[][^=\n]*)=([^\n]*)" 1:variable 2:value -hook -group ini-highlight global WinSetOption filetype=ini %{ add-highlighter window/ini ref ini } -hook -group ini-highlight global WinSetOption filetype=(?!ini).* %{ remove-highlighter window/ini } +hook -group ini-highlight global WinSetOption filetype=ini %{ + add-highlighter window/ini ref ini + hook -once -always window WinSetOption filetype=(?!ini).* %{ remove-highlighter window/ini } +} diff --git a/rc/base/java.kak b/rc/base/java.kak index b71f57cd..418abe03 100644 --- a/rc/base/java.kak +++ b/rc/base/java.kak @@ -48,16 +48,18 @@ define-command -hidden java-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group java-highlight global WinSetOption filetype=java %{ + add-highlighter window/java ref java + hook -once -always window WinSetOption filetype=(?!java).* %{ remove-highlighter window/java } +} + hook global WinSetOption filetype=java %{ # cleanup trailing whitespaces when exiting insert mode hook window ModeChange insert:.* -group java-hooks %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group java-indent java-indent-on-new-line hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace -} -hook global WinSetOption filetype=(?!java).* %{ - remove-hooks window java-.+ + hook -once -always window WinSetOption filetype=(?!java).* %{ remove-hooks window java-.+ } } -hook -group java-highlight global WinSetOption filetype=java %{ add-highlighter window/java ref java } -hook -group java-highlight global WinSetOption filetype=(?!java).* %{ remove-highlighter window/java } diff --git a/rc/base/javascript.kak b/rc/base/javascript.kak index 4b700a5d..b2d48480 100644 --- a/rc/base/javascript.kak +++ b/rc/base/javascript.kak @@ -72,7 +72,6 @@ define-command -hidden init-javascript-filetype -params 1 %~ add-highlighter "shared/%arg{1}/jsx/tag" region -recurse < <(?=[/a-zA-Z]) (? regions add-highlighter "shared/%arg{1}/jsx/expr" region -recurse \{ \{ \} ref %arg{1} - add-highlighter "shared/%arg{1}/jsx/tag/base" default-region group add-highlighter "shared/%arg{1}/jsx/tag/double_string" region =\K" (?]+@.*?> 0:string add-highlighter shared/mail/ regex ^>.*?$ 0:comment -hook -group mail-highlight global WinSetOption filetype=mail %{ add-highlighter window/mail ref mail } -hook -group mail-highlight global WinSetOption filetype=(?!mail).* %{ remove-highlighter window/mail } +hook -group mail-highlight global WinSetOption filetype=mail %{ + add-highlighter window/mail ref mail + hook -once -always window WinSetOption filetype=(?!mail).* %{ remove-highlighter window/mail } +} diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index 9ffca281..85c0a307 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -75,14 +75,12 @@ define-command -hidden markdown-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group markdown-highlight global WinSetOption filetype=markdown %{ add-highlighter window/markdown ref markdown } +hook -group markdown-highlight global WinSetOption filetype=markdown %{ + add-highlighter window/markdown ref markdown + hook -once -always window WinSetOption filetype=(?!markdown).* %{ remove-highlighter window/markdown } +} hook global WinSetOption filetype=markdown %{ hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line -} - -hook -group markdown-highlight global WinSetOption filetype=(?!markdown).* %{ remove-highlighter window/markdown } - -hook global WinSetOption filetype=(?!markdown).* %{ - remove-hooks window markdown-indent + hook -once -always window WinSetOption filetype=(?!markdown).* %{ remove-hooks window markdown-.+ } } diff --git a/rc/base/mercurial.kak b/rc/base/mercurial.kak index 3480428a..920fe541 100644 --- a/rc/base/mercurial.kak +++ b/rc/base/mercurial.kak @@ -13,14 +13,11 @@ hook global BufCreate .*hg-editor-\w+\.txt$ %{ set-option buffer filetype hg-commit } -hook -group hg-commit-highlight global WinSetOption filetype=(?!hg-commit).* %{ - remove-highlighter window/hg-commit-highlight -} - # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ add-highlighter window/ group hg-commit-highlight add-highlighter window/hg-commit-highlight regex '^HG:[^\n]*' 0:MercurialCommitComment + hook -once -always window WinSetOption filetype=(?!hg-commit).* %{ remove-highlighter window/hg-commit-highlight } } diff --git a/rc/base/ocaml.kak b/rc/base/ocaml.kak index 026bac7b..6a514f9f 100644 --- a/rc/base/ocaml.kak +++ b/rc/base/ocaml.kak @@ -19,9 +19,10 @@ add-highlighter shared/ocaml/comment region \Q(* \Q*) fill comment # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter window/ocaml ref ocaml } - -hook -group ocaml-highlight global WinSetOption filetype=(?!ocaml).* %{ remove-highlighter window/ocaml } +hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ + add-highlighter window/ocaml ref ocaml + hook -once -always window WinSetOption filetype=(?!ocaml).* %{ remove-highlighter window/ocaml } +} # Macro # ‾‾‾‾‾ diff --git a/rc/base/perl.kak b/rc/base/perl.kak index 54f147aa..7ef3346a 100644 --- a/rc/base/perl.kak +++ b/rc/base/perl.kak @@ -98,7 +98,10 @@ define-command -hidden perl-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter window/perl ref perl } +hook -group perl-highlight global WinSetOption filetype=perl %{ + add-highlighter window/perl ref perl + hook -once -always window WinSetOption filetype=(?!perl).* %{ remove-highlighter window/perl } +} hook global WinSetOption filetype=perl %{ # cleanup trailing whitespaces when exiting insert mode @@ -106,10 +109,6 @@ hook global WinSetOption filetype=perl %{ hook window InsertChar \n -group perl-indent perl-indent-on-new-line hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace -} -hook -group perl-highlight global WinSetOption filetype=(?!perl).* %{ remove-highlighter window/perl } - -hook global WinSetOption filetype=(?!perl).* %{ - remove-hooks window perl-.+ + hook -once -always window WinSetOption filetype=(?!perl).* %{ remove-hooks window perl-.+ } } diff --git a/rc/base/restructuredtext.kak b/rc/base/restructuredtext.kak index 4c072c7f..f11fe560 100644 --- a/rc/base/restructuredtext.kak +++ b/rc/base/restructuredtext.kak @@ -67,6 +67,8 @@ add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^` # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -# -hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{ add-highlighter window/restructuredtext ref restructuredtext } -hook -group restructuredtext-highlight global WinSetOption filetype=(?!restructuredtext).* %{ remove-highlighter window/restructuredtext } + +hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{ + add-highlighter window/restructuredtext ref restructuredtext + hook -once -always window WinSetOption filetype=(?!restructuredtext).* %{ remove-highlighter window/restructuredtext } +} diff --git a/rc/base/ruby.kak b/rc/base/ruby.kak index 6c9c653a..7d4680f5 100644 --- a/rc/base/ruby.kak +++ b/rc/base/ruby.kak @@ -144,7 +144,10 @@ define-command -hidden ruby-insert-on-new-line %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group ruby-highlight global WinSetOption filetype=ruby %{ add-highlighter window/ruby ref ruby } +hook -group ruby-highlight global WinSetOption filetype=ruby %{ + add-highlighter window/ruby ref ruby + hook -once -always window WinSetOption filetype=(?!ruby).* %{ remove-highlighter window/ruby } +} hook global WinSetOption filetype=ruby %{ hook window InsertChar .* -group ruby-indent ruby-indent-on-char @@ -152,12 +155,9 @@ hook global WinSetOption filetype=ruby %{ hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line alias window alt ruby-alternative-file -} - -hook -group ruby-highlight global WinSetOption filetype=(?!ruby).* %{ remove-highlighter window/ruby } - -hook global WinSetOption filetype=(?!ruby).* %{ - remove-hooks window ruby-.+ - - unalias window alt ruby-alternative-file + + hook -once -always window WinSetOption filetype=(?!ruby).* %{ + remove-hooks window ruby-.+ + unalias window alt ruby-alternative-file + } } diff --git a/rc/base/rust.kak b/rc/base/rust.kak index cf9eb83e..dbe38eae 100644 --- a/rc/base/rust.kak +++ b/rc/base/rust.kak @@ -74,17 +74,15 @@ define-command -hidden rust-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group rust-highlight global WinSetOption filetype=rust %{ add-highlighter window/rust ref rust } +hook -group rust-highlight global WinSetOption filetype=rust %{ + add-highlighter window/rust ref rust + hook -once -always window WinSetOption filetype=(?!rust).* %{ remove-highlighter window/rust } +} hook global WinSetOption filetype=rust %[ hook window ModeChange insert:.* -group rust-hooks rust-filter-around-selections hook window InsertChar \n -group rust-indent rust-indent-on-new-line hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace hook window InsertChar \} -group rust-indent rust-indent-on-closing-curly-brace + hook -once -always window WinSetOption filetype=(?!rust).* %{ remove-hooks window rust-.+ } ] - -hook -group rust-highlight global WinSetOption filetype=(?!rust).* %{ remove-highlighter window/rust } - -hook global WinSetOption filetype=(?!rust).* %{ - remove-hooks window rust-.+ -} diff --git a/rc/base/scala.kak b/rc/base/scala.kak index 1b853879..d85058fc 100644 --- a/rc/base/scala.kak +++ b/rc/base/scala.kak @@ -61,16 +61,15 @@ define-command -hidden scala-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group scala-highlight global WinSetOption filetype=scala %{ add-highlighter window/scala ref scala } +hook -group scala-highlight global WinSetOption filetype=scala %{ + add-highlighter window/scala ref scala + hook -once -always window WinSetOption filetype=(?!scala).* %{ remove-highlighter window/scala } +} hook global WinSetOption filetype=scala %[ hook window ModeChange insert:.* -group scala-hooks scala-filter-around-selections hook window InsertChar \n -group scala-indent scala-indent-on-new-line hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=(?!scala).* %{ remove-hooks window scala-.+ } ] - -hook -group scala-highlight global WinSetOption filetype=(?!scala).* %{ remove-highlighter window/scala } - -hook global WinSetOption filetype=(?!scala).* %{ - remove-hooks window scala-.+ -} diff --git a/rc/base/screen.kak b/rc/base/screen.kak index 9df694ba..66a8db5d 100644 --- a/rc/base/screen.kak +++ b/rc/base/screen.kak @@ -1,6 +1,6 @@ # http://gnu.org/software/screen/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - + hook -group GNUscreen global KakBegin .* %sh{ [ -z "${STY}" ] && exit echo " @@ -9,7 +9,6 @@ hook -group GNUscreen global KakBegin .* %sh{ " } - define-command screen-new-vertical -params .. -command-completion -docstring "Split the current pane into two, left and right" %{ nop %sh{ tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" diff --git a/rc/base/sql.kak b/rc/base/sql.kak index b5069225..0e0534e3 100644 --- a/rc/base/sql.kak +++ b/rc/base/sql.kak @@ -103,8 +103,5 @@ add-highlighter shared/sql/code/ regex \b\d+(?:\.\d+)?\b 0:value hook -group sql-highlight global WinSetOption filetype=sql %{ add-highlighter window/sql ref sql -} - -hook -group sql-highlight global WinSetOption filetype=(?!sql).* %{ - remove-highlighter window/sql + hook -once -always window WinSetOption filetype=(?!sql).* %{ remove-highlighter window/sql } } diff --git a/rc/base/swift.kak b/rc/base/swift.kak index bbd8d34d..97ef5e9a 100644 --- a/rc/base/swift.kak +++ b/rc/base/swift.kak @@ -22,5 +22,7 @@ add-highlighter shared/swift/code/ regex "\b(Bool|String|UInt|UInt16|UInt32|UInt add-highlighter shared/swift/code/ regex "\b(IBAction|IBOutlet)\b" 0:attribute add-highlighter shared/swift/code/ regex "@\w+\b" 0:attribute -hook -group swift-highlight global WinSetOption filetype=swift %{ add-highlighter window/swift ref swift } -hook -group swift-highlight global WinSetOption filetype=(?!swift).* %{ remove-highlighter window/swift } +hook -group swift-highlight global WinSetOption filetype=swift %{ + add-highlighter window/swift ref swift + hook -once -always window WinSetOption filetype=(?!swift).* %{ remove-highlighter window/swift } +} diff --git a/rc/base/yaml.kak b/rc/base/yaml.kak index 18192533..82b0c7ba 100644 --- a/rc/base/yaml.kak +++ b/rc/base/yaml.kak @@ -46,15 +46,13 @@ define-command -hidden yaml-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group yaml-highlight global WinSetOption filetype=yaml %{ add-highlighter window/yaml ref yaml } +hook -group yaml-highlight global WinSetOption filetype=yaml %{ + add-highlighter window/yaml ref yaml + hook -once -always window WinSetOption filetype=(?!yaml).* %{ remove-highlighter window/yaml } +} hook global WinSetOption filetype=yaml %{ hook window ModeChange insert:.* -group yaml-hooks yaml-filter-around-selections hook window InsertChar \n -group yaml-indent yaml-indent-on-new-line -} - -hook -group yaml-highlight global WinSetOption filetype=(?!yaml).* %{ remove-highlighter window/yaml } - -hook global WinSetOption filetype=(?!yaml).* %{ - remove-hooks window yaml-.+ + hook -once -always window WinSetOption filetype=(?!yaml).* %{ remove-hooks window yaml-.+ } }