Change cleanup of base/ languages to use a simpler hook -once

This commit is contained in:
Olivier Perret 2018-11-28 10:39:15 +01:00
parent 6765723c68
commit 898d45f5d5
30 changed files with 179 additions and 177 deletions

View File

@ -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-.+
}

View File

@ -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-.+
}

View File

@ -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-.+ }
}

View File

@ -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 }
}

View File

@ -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-.+ }
}

View File

@ -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 '"' (?<!\\)(\\\\)*" fill string
@ -81,14 +80,12 @@ define-command -hidden gas-indent-on-new-line %~
>
~
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-.+ }
}

View File

@ -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 }
}

View File

@ -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-.+ }
}

View File

@ -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-.+ }
}

View File

@ -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}-.+""
"
}

View File

@ -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 }
}

View File

@ -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 <a-x>s^\h+$<ret>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 }

View File

@ -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" (?<!\\)(\\\\)*" fill string
@ -93,19 +92,18 @@ define-command -hidden init-javascript-filetype -params 1 %~
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group "%arg{1}-highlight" global WinSetOption "filetype=%arg{1}" "add-highlighter window/%arg{1} ref %arg{1}"
hook -group "%arg{1}-highlight" global WinSetOption "filetype=%arg{1}" "
add-highlighter window/%arg{1} ref %arg{1}
hook global WinSetOption "filetype=%arg{1}" "
hook window ModeChange insert:.* -group %arg{1}-hooks javascript-filter-around-selections
hook window InsertChar .* -group %arg{1}-indent javascript-indent-on-char
hook window InsertChar \n -group %arg{1}-indent javascript-indent-on-new-line
hook -once -always window WinSetOption filetype=(?!%arg{1}).* %%{ remove-highlighter window/%arg{1} }
"
hook -group "%arg{1}-highlight" global WinSetOption "filetype=(?!%arg{1}).*" "remove-highlighter window/%arg{1}"
hook global WinSetOption "filetype=%arg{1}" "
hook window ModeChange insert:.* -group %arg{1}-hooks javascript-filter-around-selections
hook window InsertChar .* -group %arg{1}-indent javascript-indent-on-char
hook window InsertChar \n -group %arg{1}-indent javascript-indent-on-new-line
hook global WinSetOption "filetype=(?!%arg{1}).*" "
remove-hooks window %arg{1}-indent
remove-hooks window %arg{1}-hooks
hook -once -always window WinSetOption filetype=(?!%arg{1}).* %%{ remove-hooks window %arg{1}-.+ }
"
~

View File

@ -46,16 +46,15 @@ define-command -hidden json-indent-on-new-line %<
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group json-highlight global WinSetOption filetype=json %{ add-highlighter window/json ref json }
hook -group json-highlight global WinSetOption filetype=json %{
add-highlighter window/json ref json
hook -once -always window WinSetOption filetype=(?!json).* %{ remove-highlighter window/json }
}
hook global WinSetOption filetype=json %{
hook window ModeChange insert:.* -group json-hooks json-filter-around-selections
hook window InsertChar .* -group json-indent json-indent-on-char
hook window InsertChar \n -group json-indent json-indent-on-new-line
}
hook -group json-highlight global WinSetOption filetype=(?!json).* %{ remove-highlighter window/json }
hook global WinSetOption filetype=(?!json).* %{
remove-hooks window json-.+
hook -once -always window WinSetOption filetype=(?!json).* %{ remove-hooks window json-.+ }
}

View File

@ -24,5 +24,7 @@ add-highlighter shared/julia/code/ regex \b(Number|Real|BigInt|Integer|UInt|UInt
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group julia-highlight global WinSetOption filetype=julia %{ add-highlighter window/julia ref julia }
hook -group julia-highlight global WinSetOption filetype=(?!julia).* %{ remove-highlighter window/julia }
hook -group julia-highlight global WinSetOption filetype=julia %{
add-highlighter window/julia ref julia
hook -once -always window WinSetOption filetype=(?!julia).* %{ remove-highlighter window/julia }
}

View File

@ -57,15 +57,14 @@ define-command -hidden lisp-indent-on-new-line %{
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter window/lisp ref lisp }
hook -group lisp-highlight global WinSetOption filetype=lisp %{
add-highlighter window/lisp ref lisp
hook -once -always window WinSetOption filetype=(?!lisp).* %{ remove-highlighter window/lisp }
}
hook global WinSetOption filetype=lisp %{
hook window ModeChange insert:.* -group lisp-hooks lisp-filter-around-selections
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
}
hook -group lisp-highlight global WinSetOption filetype=(?!lisp).* %{ remove-highlighter window/lisp }
hook global WinSetOption filetype=(?!lisp).* %{
remove-hooks window lisp-.+
hook -once -always window WinSetOption filetype=(?!lisp).* %{ remove-hooks window lisp-.+ }
}

View File

@ -84,7 +84,10 @@ define-command -hidden lua-insert-on-new-line %[
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group lua-highlight global WinSetOption filetype=lua %{ add-highlighter window/lua ref lua }
hook -group lua-highlight global WinSetOption filetype=lua %{
add-highlighter window/lua ref lua
hook -once -always window WinSetOption filetype=(?!lua).* %{ remove-highlighter window/lua }
}
hook global WinSetOption filetype=lua %{
hook window InsertChar .* -group lua-indent lua-indent-on-char
@ -92,12 +95,9 @@ hook global WinSetOption filetype=lua %{
hook window InsertChar \n -group lua-insert lua-insert-on-new-line
alias window alt lua-alternative-file
}
hook -group lua-highlight global WinSetOption filetype=(?!lua).* %{ remove-highlighter window/lua }
hook global WinSetOption filetype=(?!lua).* %{
remove-hooks window lua-.+
unalias window alt lua-alternative-file
hook -once -always window WinSetOption filetype=(?!lua).* %{
remove-hooks window lua-.+
unalias window alt lua-alternative-file
}
}

View File

@ -7,5 +7,7 @@ add-highlighter shared/mail/ regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To
add-highlighter shared/mail/ regex <[^@>]+@.*?> 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 }
}

View File

@ -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-.+ }
}

View File

@ -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 }
}

View File

@ -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
# ‾‾‾‾‾

View File

@ -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-.+ }
}

View File

@ -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 }
}

View File

@ -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
}
}

View File

@ -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-.+
}

View File

@ -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-.+
}

View File

@ -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)"

View File

@ -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 }
}

View File

@ -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 }
}

View File

@ -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-.+ }
}