diff --git a/rc/base/clojure.kak b/rc/base/clojure.kak index cde4fc95..ae618470 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=.* %{ 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=.* %{ 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..a56aef5b 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=.* %{ 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=.* %{ 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..b0b709f0 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=.* %{ 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 WinSetOption filetype=.* %{ remove-hooks window d-.+ } } diff --git a/rc/base/etc.kak b/rc/base/etc.kak index 9087382f..1e2067fe 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=.* %{ 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=.* %{ 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=.* %{ 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=.* %{ 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=.* %{ 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=.* %{ 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=.* %{ remove-highlighter window/etc-passwd } +} diff --git a/rc/base/fish.kak b/rc/base/fish.kak index 06b55efc..3cc02652 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=.* %{ 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=.* %{ remove-hooks window fish-.+ } } diff --git a/rc/base/gas.kak b/rc/base/gas.kak index ae71c95a..8c332872 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=.* %{ 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=.* %{ remove-hooks window gas-.+ } } diff --git a/rc/base/git.kak b/rc/base/git.kak index 129c15a7..aba69509 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=.* %{ 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|break|drop|label|reset|merge|[persfxbdltm]) (\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=.* %{ remove-highlighter window/git-rebase-highlight } +} diff --git a/rc/base/go.kak b/rc/base/go.kak index d03aa80c..17cc9cf0 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=.* %{ 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=.* %{ remove-hooks window go-.+ } } diff --git a/rc/base/haskell.kak b/rc/base/haskell.kak index d3ad2215..f97b6261 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=.* %{ 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=.* %{ remove-hooks window haskell-.+ } } diff --git a/rc/base/html.kak b/rc/base/html.kak index ecf330f1..e1a2a6d9 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=.*" " + 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=.*" " + remove-hooks window ""%val{hook_param_capture_1}-.+"" + " } diff --git a/rc/base/ini.kak b/rc/base/ini.kak index 383bf70e..c03cae4e 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=.* %{ remove-highlighter window/ini } +} diff --git a/rc/base/java.kak b/rc/base/java.kak index b71f57cd..75d73c96 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=.* %{ 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=.* %{ 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..25eef44f 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=.* %{ remove-highlighter window/mail } +} diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index 9ffca281..1b8e1acd 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=.* %{ 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=.* %{ remove-hooks window markdown-.+ } } diff --git a/rc/base/mercurial.kak b/rc/base/mercurial.kak index 3480428a..b1f8a806 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=.* %{ remove-highlighter window/hg-commit-highlight } } diff --git a/rc/base/ocaml.kak b/rc/base/ocaml.kak index 026bac7b..0a3d49bf 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=.* %{ remove-highlighter window/ocaml } +} # Macro # ‾‾‾‾‾ diff --git a/rc/base/perl.kak b/rc/base/perl.kak index 54f147aa..ff242827 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=.* %{ 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=.* %{ remove-hooks window perl-.+ } } diff --git a/rc/base/restructuredtext.kak b/rc/base/restructuredtext.kak index 4c072c7f..1eaf4bfc 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=.* %{ remove-highlighter window/restructuredtext } +} diff --git a/rc/base/ruby.kak b/rc/base/ruby.kak index 6c9c653a..1d3cd3e4 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=.* %{ 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=.* %{ + remove-hooks window ruby-.+ + unalias window alt ruby-alternative-file + } } diff --git a/rc/base/rust.kak b/rc/base/rust.kak index cf9eb83e..1b0bc3ed 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=.* %{ 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=.* %{ 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..bdda2498 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=.* %{ 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=.* %{ 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..dbecea9c 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=.* %{ remove-highlighter window/sql } } diff --git a/rc/base/swift.kak b/rc/base/swift.kak index bbd8d34d..1526cadb 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=.* %{ remove-highlighter window/swift } +} diff --git a/rc/base/yaml.kak b/rc/base/yaml.kak index 18192533..cff9ab74 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=.* %{ 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=.* %{ remove-hooks window yaml-.+ } } diff --git a/rc/core/asciidoc.kak b/rc/core/asciidoc.kak index ffc7471c..8bdcce07 100644 --- a/rc/core/asciidoc.kak +++ b/rc/core/asciidoc.kak @@ -36,6 +36,8 @@ add-highlighter shared/asciidoc/ regex ^:[-\w]+: 0:meta # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -# -hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ add-highlighter window/asciidoc ref asciidoc } -hook -group asciidoc-highlight global WinSetOption filetype=(?!asciidoc).* %{ remove-highlighter window/asciidoc } + +hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ + add-highlighter window/asciidoc ref asciidoc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc } +} diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index e485568e..fe592f19 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -3,7 +3,7 @@ hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{ } hook global BufSetOption filetype=c\+\+ %{ - set-option buffer filetype cpp + hook -once buffer NormalIdle '' "set-option buffer filetype cpp" } hook global BufCreate .*\.c$ %{ @@ -318,34 +318,35 @@ evaluate-commands %sh{ } hook global WinSetOption filetype=(c|cpp|objc) %[ - try %{ # we might be switching from one c-family language to another - remove-hooks window c-family-.+ - } + hook -group "%val{hook_param_capture_1}-family-indent" window ModeChange insert:.* c-family-trim-autoindent + hook -group "%val{hook_param_capture_1}-family-insert" window InsertChar \n c-family-insert-on-newline + hook -group "%val{hook_param_capture_1}-family-indent" window InsertChar \n c-family-indent-on-newline + hook -group "%val{hook_param_capture_1}-family-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace + hook -group "%val{hook_param_capture_1}-family-indent" window InsertChar \} c-family-indent-on-closing-curly-brace + hook -group "%val{hook_param_capture_1}-family-insert" window InsertChar \} c-family-insert-on-closing-curly-brace - hook -group c-family-indent window ModeChange insert:.* c-family-trim-autoindent - hook -group c-family-insert window InsertChar \n c-family-insert-on-newline - hook -group c-family-indent window InsertChar \n c-family-indent-on-newline - hook -group c-family-indent window InsertChar \{ c-family-indent-on-opening-curly-brace - hook -group c-family-indent window InsertChar \} c-family-indent-on-closing-curly-brace - hook -group c-family-insert window InsertChar \} c-family-insert-on-closing-curly-brace + alias window alt "%val{hook_param_capture_1}-alternative-file" - alias window alt c-family-alternative-file + hook -once -always window WinSetOption filetype=.* " + remove-hooks window %val{hook_param_capture_1}-family-.+ + unalias window alt %val{hook_param_capture_1}-alternative-file + " ] -hook global WinSetOption filetype=(?!c)(?!cpp)(?!objc).* %[ - remove-hooks window c-family-.+ +hook -group c-highlight global WinSetOption filetype=c %{ + add-highlighter window/c ref c + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c } +} - unalias window alt c-family-alternative-file -] +hook -group cpp-highlight global WinSetOption filetype=cpp %{ + add-highlighter window/cpp ref cpp + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp } +} -hook -group c-highlight global WinSetOption filetype=c %[ add-highlighter window/c ref c ] -hook -group c-highlight global WinSetOption filetype=(?!c).* %[ remove-highlighter window/c ] - -hook -group cpp-highlight global WinSetOption filetype=cpp %[ add-highlighter window/cpp ref cpp ] -hook -group cpp-highlight global WinSetOption filetype=(?!cpp).* %[ remove-highlighter window/cpp ] - -hook -group objc-highlight global WinSetOption filetype=objc %[ add-highlighter window/objc ref objc ] -hook -group objc-highlight global WinSetOption filetype=(?!objc).* %[ remove-highlighter window/objc ] +hook -group objc-highlight global WinSetOption filetype=objc %{ + add-highlighter window/objc ref objc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc } +} declare-option -docstring %{control the type of include guard to be inserted in empty headers Can be one of the following: @@ -372,41 +373,53 @@ hook -group c-family-insert global BufNewFile .*\.(h|hh|hpp|hxx|H) c-family-inse declare-option -docstring "colon separated list of path in which header files will be looked for" \ str-list alt_dirs '.' '..' -define-command c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ evaluate-commands %sh{ - file="${kak_buffile##*/}" - file_noext="${file%.*}" - dir=$(dirname "${kak_buffile}") +define-command -hidden c-family-alternative-file %{ + evaluate-commands %sh{ + file="${kak_buffile##*/}" + file_noext="${file%.*}" + dir=$(dirname "${kak_buffile}") - # Set $@ to alt_dirs - eval "set -- ${kak_opt_alt_dirs}" + # Set $@ to alt_dirs + eval "set -- ${kak_opt_alt_dirs}" - case ${file} in - *.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m) - for alt_dir in "$@"; do - for ext in h hh hpp hxx H; do - altname="${dir}/${alt_dir}/${file_noext}.${ext}" - if [ -f ${altname} ]; then - printf 'edit %%{%s}\n' "${altname}" - exit - fi + case ${file} in + *.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m) + for alt_dir in "$@"; do + for ext in h hh hpp hxx H; do + altname="${dir}/${alt_dir}/${file_noext}.${ext}" + if [ -f ${altname} ]; then + printf 'edit %%{%s}\n' "${altname}" + exit + fi + done done - done - ;; - *.h|*.hh|*.hpp|*.hxx|*.H) - for alt_dir in "$@"; do - for ext in c cc cpp cxx C m; do - altname="${dir}/${alt_dir}/${file_noext}.${ext}" - if [ -f ${altname} ]; then - printf 'edit %%{%s}\n' "${altname}" - exit - fi + ;; + *.h|*.hh|*.hpp|*.hxx|*.H) + for alt_dir in "$@"; do + for ext in c cc cpp cxx C m; do + altname="${dir}/${alt_dir}/${file_noext}.${ext}" + if [ -f ${altname} ]; then + printf 'edit %%{%s}\n' "${altname}" + exit + fi + done done - done - ;; - *) - echo "echo -markup '{Error}extension not recognized'" - exit - ;; - esac - echo "echo -markup '{Error}alternative file not found'" -}} + ;; + *) + echo "echo -markup '{Error}extension not recognized'" + exit + ;; + esac + echo "echo -markup '{Error}alternative file not found'" + } +} + +define-command c-alternative-file -docstring "Jump to the alternate c file (header/implementation)" %{ + c-family-alternative-file +} +define-command cpp-alternative-file -docstring "Jump to the alternate cpp file (header/implementation)" %{ + c-family-alternative-file +} +define-command objc-alternative-file -docstring "Jump to the alternate objc file (header/implementation)" %{ + c-family-alternative-file +} diff --git a/rc/core/diff.kak b/rc/core/diff.kak index e8b7c25a..5b4e065b 100644 --- a/rc/core/diff.kak +++ b/rc/core/diff.kak @@ -7,5 +7,7 @@ add-highlighter shared/diff/ regex "^\+[^\n]*\n" 0:green,default add-highlighter shared/diff/ regex "^-[^\n]*\n" 0:red,default add-highlighter shared/diff/ regex "^@@[^\n]*@@" 0:cyan,default -hook -group diff-highlight global WinSetOption filetype=diff %{ add-highlighter window/diff ref diff } -hook -group diff-highlight global WinSetOption filetype=(?!diff).* %{ remove-highlighter window/diff } +hook -group diff-highlight global WinSetOption filetype=diff %{ + add-highlighter window/diff ref diff + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff } +} diff --git a/rc/core/grep.kak b/rc/core/grep.kak index b36ca618..9e6ed5ab 100644 --- a/rc/core/grep.kak +++ b/rc/core/grep.kak @@ -28,16 +28,12 @@ hook -group grep-highlight global WinSetOption filetype=grep %{ add-highlighter window/grep group add-highlighter window/grep/ regex "^((?:\w:)?[^:\n]+):(\d+):(\d+)?" 1:cyan 2:green 3:green add-highlighter window/grep/ line %{%opt{grep_current_line}} default+b + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/grep } } hook global WinSetOption filetype=grep %{ hook buffer -group grep-hooks NormalKey grep-jump -} - -hook -group grep-highlight global WinSetOption filetype=(?!grep).* %{ remove-highlighter window/grep } - -hook global WinSetOption filetype=(?!grep).* %{ - remove-hooks buffer grep-hooks + hook -once -always window WinSetOption filetype=.* %{ remove-hooks buffer grep-hooks } } declare-option -docstring "name of the client in which all source code jumps will be executed" \ diff --git a/rc/core/kakrc.kak b/rc/core/kakrc.kak index 5115a9e9..b487d74d 100644 --- a/rc/core/kakrc.kak +++ b/rc/core/kakrc.kak @@ -92,7 +92,10 @@ define-command -hidden kak-indent-on-closing-char %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group kak-highlight global WinSetOption filetype=kak %{ add-highlighter window/kakrc ref kakrc } +hook -group kak-highlight global WinSetOption filetype=kak %{ + add-highlighter window/kakrc ref kakrc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc } +} hook global WinSetOption filetype=kak %~ hook window InsertChar \n -group kak-indent kak-indent-on-new-line @@ -101,7 +104,6 @@ hook global WinSetOption filetype=kak %~ # cleanup trailing whitespaces on current line insert end hook window ModeChange insert:.* -group kak-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } set-option buffer extra_word_chars '_' '-' -~ -hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ remove-highlighter window/kakrc } -hook global WinSetOption filetype=(?!kak).* %{ remove-hooks window kak-indent } + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } +~ diff --git a/rc/core/make.kak b/rc/core/make.kak index d47083bb..89533a59 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -28,16 +28,14 @@ add-highlighter shared/make/ regex "^((?:\w:)?[^:\n]+):(\d+):(?:(\d+):)?\h+(?:(( add-highlighter shared/make/ regex "^\h*(~*(?:(\^)~*)?)$" 1:green 2:cyan+b add-highlighter shared/make/ line '%opt{make_current_error_line}' default+b -hook -group make-highlight global WinSetOption filetype=make %{ add-highlighter window/make ref make } +hook -group make-highlight global WinSetOption filetype=make %{ + add-highlighter window/make ref make + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/make } +} hook global WinSetOption filetype=make %{ hook buffer -group make-hooks NormalKey make-jump -} - -hook -group make-highlight global WinSetOption filetype=(?!make).* %{ remove-highlighter window/make } - -hook global WinSetOption filetype=(?!make).* %{ - remove-hooks buffer make-hooks + hook -once -always window WinSetOption filetype=.* %{ remove-hooks buffer make-hooks } } declare-option -docstring "name of the client in which all source code jumps will be executed" \ diff --git a/rc/core/makefile.kak b/rc/core/makefile.kak index 564231ff..0e1b85b3 100644 --- a/rc/core/makefile.kak +++ b/rc/core/makefile.kak @@ -49,14 +49,12 @@ define-command -hidden makefile-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window/makefile ref makefile } +hook -group makefile-highlight global WinSetOption filetype=makefile %{ + add-highlighter window/makefile ref makefile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile } +} hook global WinSetOption filetype=makefile %{ hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line -} - -hook -group makefile-highlight global WinSetOption filetype=(?!makefile).* %{ remove-highlighter window/makefile } - -hook global WinSetOption filetype=(?!makefile).* %{ - remove-hooks window makefile-indent + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } } diff --git a/rc/core/man.kak b/rc/core/man.kak index 660f184c..b1eca7e3 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -13,18 +13,13 @@ hook -group man-highlight global WinSetOption filetype=man %{ add-highlighter window/man-highlight/ regex '^ {7}-[^\s,]+(,\s+-[^\s,]+)*' 0:yellow # References to other manpages add-highlighter window/man-highlight/ regex [-a-zA-Z0-9_.]+\([a-z0-9]+\) 0:green + + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/man-highlight } } hook global WinSetOption filetype=man %{ - hook -group man-hooks window WinResize .* %{ - man-impl %val{bufname} %opt{manpage} - } -} - -hook -group man-highlight global WinSetOption filetype=(?!man).* %{ remove-highlighter window/man-highlight } - -hook global WinSetOption filetype=(?!man).* %{ - remove-hooks window man-hooks + hook -group man-hooks window WinResize .* %{ man-impl %val{bufname} %opt{manpage} } + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window man-hooks } } define-command -hidden -params 2..3 man-impl %{ evaluate-commands %sh{ diff --git a/rc/core/python.kak b/rc/core/python.kak index a91f0364..fac94ae1 100644 --- a/rc/core/python.kak +++ b/rc/core/python.kak @@ -135,16 +135,14 @@ define-command -hidden python-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter window/python ref python } +hook -group python-highlight global WinSetOption filetype=python %{ + add-highlighter window/python ref python + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python } +} hook global WinSetOption filetype=python %{ hook window InsertChar \n -group python-indent python-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange insert:.* -group python-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } -} - -hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python } - -hook global WinSetOption filetype=(?!python).* %{ - remove-hooks window python-indent + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } } diff --git a/rc/core/sh.kak b/rc/core/sh.kak index 0840c4f0..1c38393c 100644 --- a/rc/core/sh.kak +++ b/rc/core/sh.kak @@ -37,5 +37,7 @@ add-highlighter shared/sh/code/function regex ^\h*(\w+)\h*\(\) 1:function add-highlighter shared/sh/code/expansion regex \$(\w+|\{.+?\}|#|@|\?|\$|!|-|\*) 0:value add-highlighter shared/sh/double_string/expansion regex \$(\w+|\{.+?\}) 0:value -hook -group sh-highlight global WinSetOption filetype=sh %{ add-highlighter window/sh ref sh } -hook -group sh-highlight global WinSetOption filetype=(?!sh).* %{ remove-highlighter window/sh } +hook -group sh-highlight global WinSetOption filetype=sh %{ + add-highlighter window/sh ref sh + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sh } +} diff --git a/rc/extra/cabal.kak b/rc/extra/cabal.kak index 058f9d17..ea15bcc0 100644 --- a/rc/extra/cabal.kak +++ b/rc/extra/cabal.kak @@ -58,17 +58,17 @@ define-command -hidden cabal-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group cabal-highlight global WinSetOption filetype=cabal %{ add-highlighter window/cabal ref cabal } +hook -group cabal-highlight global WinSetOption filetype=cabal %{ + add-highlighter window/cabal ref cabal + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cabal } + +} hook global WinSetOption filetype=cabal %[ hook window ModeChange insert:.* -group cabal-hooks cabal-filter-around-selections hook window InsertChar \n -group cabal-indent cabal-indent-on-new-line hook window InsertChar \{ -group cabal-indent cabal-indent-on-opening-curly-brace hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cabal-.+ } ] - -hook -group cabal-highlight global WinSetOption filetype=(?!cabal).* %{ remove-highlighter window/cabal } - -hook global WinSetOption filetype=(?!cabal).* %{ - remove-hooks window cabal-.+ -} diff --git a/rc/extra/cmake.kak b/rc/extra/cmake.kak index 7c43cbdc..77ec18c5 100644 --- a/rc/extra/cmake.kak +++ b/rc/extra/cmake.kak @@ -21,5 +21,7 @@ add-highlighter shared/cmake/argument/quoted/ fill string add-highlighter shared/cmake/argument/quoted/ regex '\$\{\w+\}' 0:variable add-highlighter shared/cmake/argument/quoted/ regex '\w+\h*(?=\()' 0:function -hook -group cmake-highlight global WinSetOption filetype=cmake %{ add-highlighter window/cmake ref cmake } -hook -group cmake-highlight global WinSetOption filetype=(?!cmake).* %{ remove-highlighter window/cmake } +hook -group cmake-highlight global WinSetOption filetype=cmake %{ + add-highlighter window/cmake ref cmake + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmake } +} diff --git a/rc/extra/coffee.kak b/rc/extra/coffee.kak index 351f91f1..f3447f3d 100644 --- a/rc/extra/coffee.kak +++ b/rc/extra/coffee.kak @@ -66,15 +66,14 @@ define-command -hidden coffee-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group coffee-highlight global WinSetOption filetype=coffee %{ add-highlighter window/coffee ref coffee } +hook -group coffee-highlight global WinSetOption filetype=coffee %{ + add-highlighter window/coffee ref coffee + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/coffee } +} hook global WinSetOption filetype=coffee %{ hook window ModeChange insert:.* -group coffee-hooks coffee-filter-around-selections hook window InsertChar \n -group coffee-indent coffee-indent-on-new-line -} -hook -group coffee-highlight global WinSetOption filetype=(?!coffee).* %{ remove-highlighter window/coffee } - -hook global WinSetOption filetype=(?!coffee).* %{ - remove-hooks window coffee-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ } } diff --git a/rc/extra/cucumber.kak b/rc/extra/cucumber.kak index aa2081c3..563b3590 100644 --- a/rc/extra/cucumber.kak +++ b/rc/extra/cucumber.kak @@ -76,15 +76,14 @@ define-command -hidden cucumber-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ add-highlighter window/cucumber ref cucumber } +hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ + add-highlighter window/cucumber ref cucumber + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cucumber } +} hook global WinSetOption filetype=cucumber %{ hook window ModeChange insert:.* -group cucumber-hooks cucumber-filter-around-selections hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line -} -hook -group cucumber-highlight global WinSetOption filetype=(?!cucumber).* %{ remove-highlighter window/cucumber } - -hook global WinSetOption filetype=(?!cucumber).* %{ - remove-hooks window cucumber-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ } } diff --git a/rc/extra/dart.kak b/rc/extra/dart.kak index 0dba128c..7618bff4 100644 --- a/rc/extra/dart.kak +++ b/rc/extra/dart.kak @@ -90,7 +90,10 @@ define-command -hidden dart-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group dart-highlight global WinSetOption filetype=dart %{ add-highlighter window/dart ref dart } +hook -group dart-highlight global WinSetOption filetype=dart %{ + add-highlighter window/dart ref dart + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart } +} hook global WinSetOption filetype=dart %{ # cleanup trailing whitespaces when exiting insert mode @@ -98,10 +101,6 @@ hook global WinSetOption filetype=dart %{ hook window InsertChar \n -group dart-indent dart-indent-on-new-line hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace -} -hook -group dart-highlight global WinSetOption filetype=(?!dart).* %{ remove-highlighter window/dart } - -hook global WinSetOption filetype=(?!dart).* %{ - remove-hooks window dart-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ } } diff --git a/rc/extra/dockerfile.kak b/rc/extra/dockerfile.kak index fcc4c5c3..07da2347 100644 --- a/rc/extra/dockerfile.kak +++ b/rc/extra/dockerfile.kak @@ -42,5 +42,7 @@ add-highlighter shared/dockerfile/code/ regex '\$[\w_]+' 0:value # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ add-highlighter window/dockerfile ref dockerfile } -hook -group dockerfile-highlight global WinSetOption filetype=(?!dockerfile).* %{ remove-highlighter window/dockerfile } +hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ + add-highlighter window/dockerfile ref dockerfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile } +} diff --git a/rc/extra/elixir.kak b/rc/extra/elixir.kak index 86799213..33290194 100644 --- a/rc/extra/elixir.kak +++ b/rc/extra/elixir.kak @@ -64,12 +64,14 @@ define-command -hidden elixir-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group elixir-highlight global WinSetOption filetype=elixir %{ add-highlighter window/elixir ref elixir } +hook -group elixir-highlight global WinSetOption filetype=elixir %{ + add-highlighter window/elixir ref elixir + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir } +} hook global WinSetOption filetype=elixir %{ hook window ModeChange insert:.* -group elixir-hooks elixir-filter-around-selections hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ } } - -hook -group elixir-highlight global WinSetOption filetype=(?!elixir).* %{ remove-highlighter window/elixir } - diff --git a/rc/extra/elm.kak b/rc/extra/elm.kak index 0817fb5a..8b904d6f 100644 --- a/rc/extra/elm.kak +++ b/rc/extra/elm.kak @@ -54,15 +54,14 @@ define-command -hidden elm-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group elm-highlight global WinSetOption filetype=elm %{ add-highlighter window/elm ref elm } +hook -group elm-highlight global WinSetOption filetype=elm %{ + add-highlighter window/elm ref elm + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } +} hook global WinSetOption filetype=elm %{ hook window ModeChange insert:.* -group elm-hooks elm-filter-around-selections hook window InsertChar \n -group elm-indent elm-indent-on-new-line -} -hook -group elm-highlight global WinSetOption filetype=(?!elm).* %{ remove-highlighter window/elm } - -hook global WinSetOption filetype=(?!elm).* %{ - remove-hooks window elm-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ } } diff --git a/rc/extra/exherbo.kak b/rc/extra/exherbo.kak index a383c426..42cc618c 100644 --- a/rc/extra/exherbo.kak +++ b/rc/extra/exherbo.kak @@ -34,8 +34,10 @@ add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?[\S]+[\s\t]+=[\s\t add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?\]\]$ 0:type -hook -group exheres-0-metadata-highlight global WinSetOption filetype=exheres-0-metadata %{ add-highlighter window/exheres-0-metadata ref exheres-0-metadata } -hook -group exheres-0-metadata-highlight global WinSetOption filetype=(?!exheres-0-metadata).* %{ remove-highlighter window/exheres-0-metadata } +hook -group exheres-0-metadata-highlight global WinSetOption filetype=exheres-0-metadata %{ + add-highlighter window/exheres-0-metadata ref exheres-0-metadata + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-metadata } +} ## exheres-0 options descriptions add-highlighter shared/exheres-0-options-descriptions group @@ -44,8 +46,10 @@ add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?[\S]+[ add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?\]\]$ 0:type -hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=exheres-0-options-descriptions %{ add-highlighter window/exheres-0-options-descriptions ref exheres-0-options-descriptions } -hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=(?!exheres-0-options-descriptions).* %{ remove-highlighter window/exheres-0-options-descriptions } +hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=exheres-0-options-descriptions %{ + add-highlighter window/exheres-0-options-descriptions ref exheres-0-options-descriptions + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-options-descriptions } +} ## metadata/licence_groups.conf add-highlighter shared/exheres-0-licence-groups group @@ -53,8 +57,10 @@ add-highlighter shared/exheres-0-licence-groups/ regex [\s\t]+(\S+(?:[\s\t]+))*$ add-highlighter shared/exheres-0-licence-groups/ regex ^(\S+) 0:type add-highlighter shared/exheres-0-licence-groups/ regex ^#.*?$ 0:comment -hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exheres-0-licence-groups %{ add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups } -hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=(?!exheres-0-licence-groups).* %{ remove-highlighter window/exheres-0-licence-groups } +hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exheres-0-licence-groups %{ + add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-licence-groups } +} ## Paludis configurations ### options.conf @@ -67,24 +73,30 @@ add-highlighter shared/paludis-options-conf/ regex [\s\t](-\S+)(.*?) 1:red add-highlighter shared/paludis-options-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-options-conf/ regex ^#.*?$ 0:comment -hook -group paludis-options-conf-highlight global WinSetOption filetype=paludis-options-conf %{ add-highlighter window/paludis-options-conf ref paludis-options-conf } -hook -group paludis-options-conf-highlight global WinSetOption filetype=(?!paludis-options-conf).* %{ remove-highlighter window/paludis-options-conf } +hook -group paludis-options-conf-highlight global WinSetOption filetype=paludis-options-conf %{ + add-highlighter window/paludis-options-conf ref paludis-options-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-options-conf } +} ## general.conf, repository.template add-highlighter shared/paludis-key-value-conf group add-highlighter shared/paludis-key-value-conf/ regex ^[\s\t]?(\S+)[\s\t+]=[\s\t+](.*?)$ 1:attribute 2:value add-highlighter shared/paludis-key-value-conf/ regex ^#.*?$ 0:comment -hook -group paludis-key-value-conf-highlight global WinSetOption filetype=paludis-key-value-conf %{ add-highlighter window/paludis-key-value-conf ref paludis-key-value-conf } -hook -group paludis-key-value-conf-highlight global WinSetOption filetype=(?!paludis-key-value-conf).* %{ remove-highlighter window/paludis-key-value-conf } +hook -group paludis-key-value-conf-highlight global WinSetOption filetype=paludis-key-value-conf %{ + add-highlighter window/paludis-key-value-conf ref paludis-key-value-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-key-value-conf } +} ## mirrors.conf add-highlighter shared/paludis-mirrors-conf group add-highlighter shared/paludis-mirrors-conf/ regex ^[\s\t+]?(\S+)[\s\t+](.*?)$ 1:type 2:value add-highlighter shared/paludis-mirrors-conf/ regex ^#.*?$ 0:comment -hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=paludis-mirrors-conf %{ add-highlighter window/paludis-mirrors-conf ref paludis-mirrors-conf } -hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=(?!paludis-mirrors-conf).* %{ remove-highlighter window/paludis-mirrors-conf } +hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=paludis-mirrors-conf %{ + add-highlighter window/paludis-mirrors-conf ref paludis-mirrors-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-mirrors-conf } +} ## package_(unmask|mask).conf, platforms.conf add-highlighter shared/paludis-specs-conf group @@ -92,8 +104,10 @@ add-highlighter shared/paludis-specs-conf/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:att add-highlighter shared/paludis-specs-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-specs-conf/ regex ^#.*?$ 0:comment -hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-specs-conf %{ add-highlighter window/paludis-specs-conf ref paludis-specs-conf } -hook -group paludis-specs-conf-highlight global WinSetOption filetype=(?!paludis-specs-conf).* %{ remove-highlighter window/paludis-specs-conf } +hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-specs-conf %{ + add-highlighter window/paludis-specs-conf ref paludis-specs-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-specs-conf } +} ## News items (GLEP42) add-highlighter shared/glep42 group @@ -101,5 +115,7 @@ add-highlighter shared/glep42/ regex ^(Title|Author|Translator|Content-Type|Post add-highlighter shared/glep42/ regex <[^@>]+@.*?> 0:string add-highlighter shared/glep42/ regex ^>.*?$ 0:comment -hook -group glep42-highlight global WinSetOption filetype=glep42 %{ add-highlighter window/glep42 ref glep42 } -hook -group glep42-highlight global WinSetOption filetype=(?!glep42).* %{ remove-highlighter window/glep42 } +hook -group glep42-highlight global WinSetOption filetype=glep42 %{ + add-highlighter window/glep42 ref glep42 + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/glep42 } +} diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index 55d5cf53..8fbda7f1 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -6,16 +6,18 @@ hook -group git-log-highlight global WinSetOption filetype=git-log %{ add-highlighter window/git-log/ regex '^(commit) ([0-9a-f]+)$' 1:yellow 2:red add-highlighter window/git-log/ regex '^([a-zA-Z_-]+:) (.*?)$' 1:green 2:magenta add-highlighter window/git-log/ ref diff # highlight potential diffs from the -p option + + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-log } } -hook -group git-log-highlight global WinSetOption filetype=(?!git-log).* %{ remove-highlighter window/git-log } hook -group git-status-highlight global WinSetOption filetype=git-status %{ add-highlighter window/git-status group add-highlighter window/git-status/ regex '^\h+(?:((?:both )?modified:)|(added:|new file:)|(deleted(?: by \w+)?:)|(renamed:)|(copied:))(?:.*?)$' 1:yellow 2:green 3:red 4:cyan 5:blue 6:magenta + + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-status } } -hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter window/git-status } declare-option -hidden line-specs git_blame_flags declare-option -hidden line-specs git_diff_flags diff --git a/rc/extra/haml.kak b/rc/extra/haml.kak index 7bf309f6..33889505 100644 --- a/rc/extra/haml.kak +++ b/rc/extra/haml.kak @@ -49,15 +49,14 @@ define-command -hidden haml-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter window/haml ref haml } +hook -group haml-highlight global WinSetOption filetype=haml %{ + add-highlighter window/haml ref haml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml } +} hook global WinSetOption filetype=haml %{ hook window ModeChange insert:.* -group haml-hooks haml-filter-around-selections hook window InsertChar \n -group haml-indent haml-indent-on-new-line -} -hook -group haml-highlight global WinSetOption filetype=(?!haml).* %{ remove-highlighter window/haml } - -hook global WinSetOption filetype=(?!haml).* %{ - remove-hooks window haml-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } } diff --git a/rc/extra/hbs.kak b/rc/extra/hbs.kak index 6f02ca32..22b219bb 100644 --- a/rc/extra/hbs.kak +++ b/rc/extra/hbs.kak @@ -83,6 +83,7 @@ define-command -hidden maybe-add-hbs-to-html %{ evaluate-commands %sh{ hook -group hbs-highlight global WinSetOption filetype=hbs %{ maybe-add-hbs-to-html add-highlighter window/hbs-file ref hbs-file + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hbs-file } } hook global WinSetOption filetype=hbs %{ @@ -92,12 +93,6 @@ hook global WinSetOption filetype=hbs %{ hook window ModeChange insert:.* -group hbs-hooks html-filter-around-selections hook window InsertChar '>' -group hbs-indent html-indent-on-greater-than hook window InsertChar \n -group hbs-indent html-indent-on-new-line -} -hook -group hbs-highlight global WinSetOption filetype=(?!hbs).* %{ - remove-highlighter window/hbs-file -} - -hook global WinSetOption filetype=(?!hbs).* %{ - remove-hooks window hbs-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hbs-.+ } } diff --git a/rc/extra/i3.kak b/rc/extra/i3.kak index 7e35ace3..4ec1c565 100644 --- a/rc/extra/i3.kak +++ b/rc/extra/i3.kak @@ -66,17 +66,16 @@ define-command -hidden i3-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group i3-highlight global WinSetOption filetype=i3 %{ add-highlighter window/i3 ref i3 } +hook -group i3-highlight global WinSetOption filetype=i3 %{ + add-highlighter window/i3 ref i3 + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/i3 } +} hook global WinSetOption filetype=i3 %[ # cleanup trailing whitespaces when exiting insert mode hook window ModeChange insert:.* -group i3-hooks %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group i3-indent i3-indent-on-new-line hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window i3-.+ } ] - -hook -group i3-highlight global WinSetOption filetype=(?!i3).* %{ remove-highlighter window/i3 } - -hook global WinSetOption filetype=(?!i3).* %{ - remove-hooks window i3-.+ -} diff --git a/rc/extra/just.kak b/rc/extra/just.kak index e8dc19b6..201bfc3d 100644 --- a/rc/extra/just.kak +++ b/rc/extra/just.kak @@ -28,25 +28,21 @@ add-highlighter shared/justfile/comment region '#' '$' fill comment add-highlighter shared/justfile/double_string region '"' (? s ^\h+$ d } } -} -hook -group nim-highlight global WinSetOption filetype=(?!nim).* %{ remove-highlighter window/nim } - -hook global WinSetOption filetype=(?!nim).* %{ - remove-hooks window nim-indent + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } } diff --git a/rc/extra/php.kak b/rc/extra/php.kak index 1a2b4228..0186b7bb 100644 --- a/rc/extra/php.kak +++ b/rc/extra/php.kak @@ -76,16 +76,15 @@ define-command -hidden php-indent-on-new-line %< # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group php-highlight global WinSetOption filetype=php %{ add-highlighter window/php-file ref php-file } +hook -group php-highlight global WinSetOption filetype=php %{ + add-highlighter window/php-file ref php-file + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file } +} hook global WinSetOption filetype=php %{ hook window ModeChange insert:.* -group php-hooks php-filter-around-selections hook window InsertChar .* -group php-indent php-indent-on-char hook window InsertChar \n -group php-indent php-indent-on-new-line -} -hook -group php-highlight global WinSetOption filetype=(?!php).* %{ remove-highlighter window/php-file } - -hook global WinSetOption filetype=(?!php).* %{ - remove-hooks window php-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ } } diff --git a/rc/extra/pony.kak b/rc/extra/pony.kak index 3c8d105d..0266b194 100644 --- a/rc/extra/pony.kak +++ b/rc/extra/pony.kak @@ -78,16 +78,15 @@ define-command -hidden pony-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group pony-highlight global WinSetOption filetype=pony %{ add-highlighter window/pony ref pony } +hook -group pony-highlight global WinSetOption filetype=pony %{ + add-highlighter window/pony ref pony + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony } +} hook global WinSetOption filetype=pony %{ hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange insert:.* -group pony-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } -} -hook -group pony-highlight global WinSetOption filetype=(?!pony).* %{ remove-highlighter pony } - -hook global WinSetOption filetype=(?!pony).* %{ - remove-hooks window pony-indent + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } diff --git a/rc/extra/protobuf.kak b/rc/extra/protobuf.kak index c18e6dc7..2ef10480 100644 --- a/rc/extra/protobuf.kak +++ b/rc/extra/protobuf.kak @@ -71,16 +71,15 @@ define-command -hidden protobuf-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group protobuf-highlight global WinSetOption filetype=protobuf %{ add-highlighter window/protobuf ref protobuf } +hook -group protobuf-highlight global WinSetOption filetype=protobuf %{ + add-highlighter window/protobuf ref protobuf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf } +} hook global WinSetOption filetype=protobuf %[ hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ } ] - -hook -group protobuf-highlight global WinSetOption filetype=(?!protobuf).* %{ remove-highlighter window/protobuf } - -hook global WinSetOption filetype=(?!protobuf).* %{ - remove-hooks window protobuf-.+ -} diff --git a/rc/extra/pug.kak b/rc/extra/pug.kak index e279d96b..a5921a62 100644 --- a/rc/extra/pug.kak +++ b/rc/extra/pug.kak @@ -61,15 +61,14 @@ define-command -hidden pug-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group pug-highlight global WinSetOption filetype=pug %{ add-highlighter window/pug ref pug } +hook -group pug-highlight global WinSetOption filetype=pug %{ + add-highlighter window/pug ref pug + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug } +} hook global WinSetOption filetype=pug %{ hook window ModeChange insert:.* -group pug-hooks pug-filter-around-selections hook window InsertChar \n -group pug-indent pug-indent-on-new-line -} -hook -group pug-highlight global WinSetOption filetype=(?!pug).* %{ remove-highlighter window/pug } - -hook global WinSetOption filetype=(?!pug).* %{ - remove-hooks window pug-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ } } diff --git a/rc/extra/ragel.kak b/rc/extra/ragel.kak index b6f1fd68..0768d878 100644 --- a/rc/extra/ragel.kak +++ b/rc/extra/ragel.kak @@ -56,16 +56,15 @@ define-command -hidden ragel-indent-on-new-line %< # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group ragel-highlight global WinSetOption filetype=ragel %{ add-highlighter window/ragel ref ragel } +hook -group ragel-highlight global WinSetOption filetype=ragel %{ + add-highlighter window/ragel ref ragel + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel } +} hook global WinSetOption filetype=ragel %{ hook window ModeChange insert:.* -group ragel-hooks ragel-filter-around-selections hook window InsertChar .* -group ragel-indent ragel-indent-on-char hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line -} -hook -group ragel-highlight global WinSetOption filetype=(?!ragel).* %{ remove-highlighter window/ragel } - -hook global WinSetOption filetype=(?!ragel).* %{ - remove-hooks window ragel-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ } } diff --git a/rc/extra/sass.kak b/rc/extra/sass.kak index df4929fa..5490078f 100644 --- a/rc/extra/sass.kak +++ b/rc/extra/sass.kak @@ -48,16 +48,15 @@ define-command -hidden sass-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group sass-highlight global WinSetOption filetype=sass %{ add-highlighter window/sass ref sass } +hook -group sass-highlight global WinSetOption filetype=sass %{ + add-highlighter window/sass ref sass + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sass } +} hook global WinSetOption filetype=sass %{ hook window ModeChange insert:.* -group sass-hooks sass-filter-around-selections hook window InsertChar \n -group sass-indent sass-indent-on-new-line set-option buffer extra_word_chars '_' '-' -} -hook -group sass-highlight global WinSetOption filetype=(?!sass).* %{ remove-highlighter window/sass } - -hook global WinSetOption filetype=(?!sass).* %{ - remove-hooks window sass-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } } diff --git a/rc/extra/scheme.kak b/rc/extra/scheme.kak index 4c38f8a5..b0debf93 100644 --- a/rc/extra/scheme.kak +++ b/rc/extra/scheme.kak @@ -114,18 +114,14 @@ evaluate-commands %sh{ hook -group scheme-highlight global WinSetOption filetype=scheme %{ add-highlighter window/scheme ref scheme + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme } } -hook -group scheme-highlight global WinSetOption filetype=(?!scheme).* %{ - remove-highlighter window/scheme -} hook global WinSetOption filetype=scheme %{ set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '=' hook window InsertEnd .* -group scheme-hooks lisp-filter-around-selections hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line -} -hook global WinSetOption filetype=(?!scheme).* %{ - remove-hooks window scheme-.+ + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ } } diff --git a/rc/extra/scss.kak b/rc/extra/scss.kak index 9dbd1fe3..7fc34abb 100644 --- a/rc/extra/scss.kak +++ b/rc/extra/scss.kak @@ -30,17 +30,16 @@ define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing- # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group scss-highlight global WinSetOption filetype=scss %{ add-highlighter window/scss ref scss } +hook -group scss-highlight global WinSetOption filetype=scss %{ + add-highlighter window/scss ref scss + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scss } +} hook global WinSetOption filetype=scss %[ hook window ModeChange insert:.* -group scss-hooks scss-filter-around-selections hook window InsertChar \n -group scss-indent scss-indent-on-new-line hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ } ] - -hook -group scss-highlight global WinSetOption filetype=(?!scss).* %{ remove-highlighter window/scss } - -hook global WinSetOption filetype=(?!scss).* %{ - remove-hooks window scss-.+ -} diff --git a/rc/extra/taskpaper.kak b/rc/extra/taskpaper.kak index 4b3c860e..dca5de1e 100644 --- a/rc/extra/taskpaper.kak +++ b/rc/extra/taskpaper.kak @@ -38,9 +38,10 @@ define-command -hidden taskpaper-indent-on-new-line %{ hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{ add-highlighter window/taskpaper ref taskpaper + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/taskpaper } +} + +hook global WinSetOption filetype=taskpaper %{ hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line -} -hook -group taskpaper-highlight global WinSetOption filetype=(?!taskpaper).* %{ - remove-highlighter window/taskpaper - remove-hooks window taskpaper-indent + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ } } diff --git a/rc/extra/toml.kak b/rc/extra/toml.kak index 5f5a217a..e68b1f4d 100644 --- a/rc/extra/toml.kak +++ b/rc/extra/toml.kak @@ -52,18 +52,12 @@ define-command -hidden toml-indent-on-new-line %{ hook -group toml-highlight global WinSetOption filetype=toml %{ add-highlighter window/toml ref toml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/toml } } hook global WinSetOption filetype=toml %{ hook window ModeChange insert:.* -group toml-hooks toml-filter-around-selections hook window InsertChar \n -group toml-indent toml-indent-on-new-line -} -hook -group toml-highlight global WinSetOption filetype=(?!toml).* %{ - remove-highlighter window/toml + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window toml-.+ } } - -hook global WinSetOption filetype=(?!toml).* %{ - remove-hooks window toml-.+ -} - diff --git a/rc/extra/troff.kak b/rc/extra/troff.kak index 91755643..072cc3d1 100644 --- a/rc/extra/troff.kak +++ b/rc/extra/troff.kak @@ -24,6 +24,7 @@ add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group troff-highlight global WinSetOption filetype=troff %{ add-highlighter window/troff ref troff } - -hook -group troff-highlight global WinSetOption filetype=(?!troff).* %{ remove-highlighter window/troff } +hook -group troff-highlight global WinSetOption filetype=troff %{ + add-highlighter window/troff ref troff + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff } +} diff --git a/rc/extra/tupfile.kak b/rc/extra/tupfile.kak index 0f38180a..e7ba0d52 100644 --- a/rc/extra/tupfile.kak +++ b/rc/extra/tupfile.kak @@ -27,5 +27,7 @@ add-highlighter shared/tupfile/code/ regex '`[^`\n]+`' 0:meta # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ add-highlighter window/tupfile ref tupfile } -hook -group tupfile-highlight global WinSetOption filetype=(?!tupfile).* %{ remove-highlighter window/tupfile } +hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ + add-highlighter window/tupfile ref tupfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile } +}