diff --git a/rc/filetype/etc.kak b/rc/filetype/etc.kak index 29c6296d..b04b7b47 100644 --- a/rc/filetype/etc.kak +++ b/rc/filetype/etc.kak @@ -12,27 +12,40 @@ hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer fil hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh } -hook -once global BufSetOption filetype=etc-hosts %{ - require-module etc-hosts +hook global WinSetOption filetype=etc-(hosts|resolv-conf|shadow|passwd|gshadow|group|fstab) %{ + require-module "etc-%val{hook_param_capture_1}" } -hook -once global BufSetOption filetype=etc-resolv-conf %{ - require-module 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 } } -hook -once global BufSetOption filetype=etc-shadow %{ - require-module etc-shadow +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 } } -hook -once global BufSetOption filetype=etc-passwd %{ - require-module etc-passwd +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 } } -hook -once global BufSetOption filetype=etc-gshadow %{ - require-module etc-gshadow +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 } } -hook -once global BufSetOption filetype=etc-group %{ - require-module etc-group +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 } } -hook -once global BufSetOption filetype=etc-fstab %{ - require-module etc-fstab +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 } } +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 } +} + # Highlighters @@ -41,70 +54,42 @@ provide-module etc-resolv-conf %{ 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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } -}} +} provide-module etc-hosts %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } -}} +} provide-module etc-fstab %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } -}} +} provide-module etc-group %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } -}} +} provide-module etc-gshadow %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } -}} +} provide-module etc-shadow %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } -}} +} provide-module etc-passwd %{ ## /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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } -}} +} diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index db62a354..49d0c9f8 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](fish) %{ set-option buffer filetype fish } -hook -once global BufSetOption filetype=fish %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=fish %{ require-module fish + + hook window InsertChar .* -group fish-indent fish-indent-on-char + hook window InsertChar \n -group fish-indent fish-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window 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 } +} + + provide-module fish %{ # Highlighters @@ -63,19 +77,4 @@ define-command -hidden fish-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -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-indent fish-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } -} - } diff --git a/rc/filetype/git.kak b/rc/filetype/git.kak index 155d666c..3a39ab37 100644 --- a/rc/filetype/git.kak +++ b/rc/filetype/git.kak @@ -14,40 +14,40 @@ hook global BufCreate .*git-rebase-todo %{ set-option buffer filetype git-rebase } -hook -once global BufSetOption filetype=git-commit %{ - require-module git-commit +hook global WinSetOption filetype=git-(commit|notes|rebase) %{ + require-module "git-%val{hook_param_capture_1}" } -hook -once global BufSetOption filetype=git-notes %{ - require-module git-notes + +hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ + add-highlighter window/git-commit ref git-commit + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit } } -hook -once global BufSetOption filetype=git-rebase %{ - require-module git-rebase + +hook -group git-notes-highlight global WinSetOption filetype=git-notes %{ + add-highlighter window/git-notes ref git-notes + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes } } +hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ + add-highlighter window/git-rebase ref git-rebase + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase } +} + + provide-module git-commit %{ -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/ fill comment - 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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit-highlight } -}} +add-highlighter shared/git-commit regions +add-highlighter shared/git-commit/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option +add-highlighter shared/git-commit/comments region '^\h*#' '$' group +add-highlighter shared/git-commit/comments/ fill comment +add-highlighter shared/git-commit/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta +} provide-module git-notes %{ -hook -group git-commit-highlight global WinSetOption filetype=git-notes %{ - add-highlighter window/git-notes-highlight regex '^\h*#[^\n]*$' 0:comment - - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes-highlight } -}} - +add-highlighter shared/git-notes regex '^\h*#[^\n]*$' 0:comment +} provide-module git-rebase %{ -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:comment - add-highlighter window/git-rebase-highlight/ regex "^(pick|edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[persfxbdltm]) (\w+)" 1:keyword 2:meta - - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase-highlight } -}} +add-highlighter shared/git-rebase group +add-highlighter shared/git-rebase/ regex "#[^\n]*\n" 0:comment +add-highlighter shared/git-rebase/ regex "^(pick|edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[persfxbdltm]) (\w+)" 1:keyword 2:meta +} diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index d45cf3b1..3f794506 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -9,10 +9,6 @@ hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } -hook -once global BufSetOption filetype=(java|type)script %{ - require-module javascript -} - # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index 9af3d6b9..094c3652 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -8,9 +8,6 @@ hook global BufCreate .*[.](json) %{ set-option buffer filetype json } -hook -once global BufSetOption filetype=json %{ -} - # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ diff --git a/rc/filetype/mail.kak b/rc/filetype/mail.kak index 73998d90..95b7d88a 100644 --- a/rc/filetype/mail.kak +++ b/rc/filetype/mail.kak @@ -2,10 +2,16 @@ hook global BufCreate .+\.eml %{ set-option buffer filetype mail } -hook -once global BufSetOption filetype=mail %{ +hook global WinSetOption filetype=mail %{ require-module 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 } +} + + provide-module mail %{ add-highlighter shared/mail group @@ -13,9 +19,4 @@ 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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mail } -} - } diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index 46145f7c..c5872253 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -8,10 +8,25 @@ hook global BufCreate .*[.](sass) %{ set-option buffer filetype sass } -hook -once global BufSetOption filetype=sass %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=sass %{ require-module sass + + hook window ModeChange insert:.* -group sass-trim-indent sass-trim-indent + hook window InsertChar \n -group sass-indent sass-indent-on-new-line + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window 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 } +} + + provide-module sass %{ # Highlighters @@ -51,20 +66,4 @@ define-command -hidden sass-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -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-trim-indent sass-trim-indent - hook window InsertChar \n -group sass-indent sass-indent-on-new-line - set-option buffer extra_word_chars '_' '-' - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } -} - } diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak index ce890058..73f086b5 100644 --- a/rc/filetype/scala.kak +++ b/rc/filetype/scala.kak @@ -8,11 +8,26 @@ hook global BufCreate .*[.](scala) %{ set-option buffer filetype scala } -hook -once global BufSetOption filetype=scala %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=scala %[ require-module scala + + hook window ModeChange insert:.* -group scala-trim-indent scala-trim-indent + 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 %{ + add-highlighter window/scala ref scala + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } } -provide-module scala %{ + +provide-module scala %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -64,20 +79,4 @@ 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 -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } -} - -hook global WinSetOption filetype=scala %[ - hook window ModeChange insert:.* -group scala-trim-indent scala-trim-indent - 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-.+ } ] - -}