From d49555fc7568cff0db385d019a68cfdb0f28f8b0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 28 Oct 2017 11:00:51 +0800 Subject: [PATCH] Move highlighters into Scopes That means we can now have highlighters active at global, buffer, and window scope. The add-highlighter and remove-highlighter syntax changed to take the parent path (scope/group/...) as a mandatory argument, superseeding the previous -group switch. --- rc/base/clojure.kak | 10 +- rc/base/css.kak | 24 ++-- rc/base/d.kak | 40 +++--- rc/base/etc.kak | 62 ++++---- rc/base/fish.kak | 18 +-- rc/base/gas.kak | 28 ++-- rc/base/git.kak | 18 +-- rc/base/go.kak | 26 ++-- rc/base/haskell.kak | 42 +++--- rc/base/html.kak | 22 +-- rc/base/ini.kak | 12 +- rc/base/java.kak | 18 +-- rc/base/javascript.kak | 28 ++-- rc/base/json.kak | 10 +- rc/base/julia.kak | 16 +-- rc/base/lint.kak | 4 +- rc/base/lisp.kak | 18 +-- rc/base/lua.kak | 12 +- rc/base/mail.kak | 12 +- rc/base/markdown.kak | 116 +++++++-------- rc/base/mercurial.kak | 6 +- rc/base/ocaml.kak | 12 +- rc/base/perl.kak | 42 +++--- rc/base/ruby.kak | 40 +++--- rc/base/rust.kak | 24 ++-- rc/base/scala.kak | 24 ++-- rc/base/spell.kak | 2 +- rc/base/sql.kak | 26 ++-- rc/base/swift.kak | 30 ++-- rc/base/yaml.kak | 20 +-- rc/core/asciidoc.kak | 32 ++--- rc/core/c-family.kak | 60 ++++---- rc/core/diff.kak | 12 +- rc/core/grep.kak | 8 +- rc/core/kakrc.kak | 24 ++-- rc/core/make.kak | 12 +- rc/core/makefile.kak | 16 +-- rc/core/man.kak | 12 +- rc/core/python.kak | 24 ++-- rc/core/sh.kak | 26 ++-- rc/extra/cabal.kak | 14 +- rc/extra/clang.kak | 4 +- rc/extra/coffee.kak | 32 ++--- rc/extra/cucumber.kak | 14 +- rc/extra/dockerfile.kak | 20 +-- rc/extra/elixir.kak | 46 +++--- rc/extra/elm.kak | 18 +-- rc/extra/exherbo.kak | 106 +++++++------- rc/extra/git-tools.kak | 22 +-- rc/extra/haml.kak | 18 +-- rc/extra/hbs.kak | 20 +-- rc/extra/kickstart.kak | 34 ++--- rc/extra/latex.kak | 18 +-- rc/extra/moon.kak | 20 +-- rc/extra/php.kak | 24 ++-- rc/extra/pony.kak | 32 ++--- rc/extra/pug.kak | 30 ++-- rc/extra/ragel.kak | 18 +-- rc/extra/sass.kak | 22 +-- rc/extra/scss.kak | 12 +- rc/extra/taskpaper.kak | 16 +-- rc/extra/tupfile.kak | 22 +-- rc/extra/typescript.kak | 22 +-- src/commands.cc | 134 ++++++++---------- src/highlighter_group.cc | 15 ++ src/highlighter_group.hh | 18 ++- src/scope.hh | 23 +-- src/window.cc | 8 +- src/window.hh | 5 +- test/highlight/column/multi-columns/rc | 8 +- test/highlight/regions/rc | 8 +- test/highlight/wrap/avoid-odd-places/rc | 2 +- .../1195-infinite-loop-in-regex-matching/rc | 2 +- test/regression/1275-replaced-range-split/cmd | 2 +- .../rc | 2 +- .../1433-scrolloff-broken-with-soft-wrap/rc | 2 +- .../rc | 2 +- .../rc | 2 +- .../1459-assertion-on-wrapped-long-line/rc | 2 +- .../638-highlight-codepoint-with-bracket/rc | 2 +- 80 files changed, 908 insertions(+), 901 deletions(-) diff --git a/rc/base/clojure.kak b/rc/base/clojure.kak index 2172a21e..77f58681 100644 --- a/rc/base/clojure.kak +++ b/rc/base/clojure.kak @@ -13,11 +13,11 @@ hook global BufCreate .*[.](cljs?) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / group clojure +add-highlighter shared/ group clojure -add-highlighter -group /clojure ref lisp +add-highlighter shared/clojure ref lisp -add-highlighter -group /clojure regex \b(clojure.core/['/\w]+)\b 0:keyword +add-highlighter shared/clojure regex \b(clojure.core/['/\w]+)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ @@ -27,14 +27,14 @@ def -hidden clojure-indent-on-new-line lisp-indent-on-new-line # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group clojure-highlight global WinSetOption filetype=clojure %{ add-highlighter ref clojure } +hook -group clojure-highlight global WinSetOption filetype=clojure %{ add-highlighter window ref clojure } hook global WinSetOption filetype=clojure %[ hook window InsertEnd .* -group clojure-hooks clojure-filter-around-selections hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line ] -hook -group clojure-highlight global WinSetOption filetype=(?!clojure).* %{ remove-highlighter clojure } +hook -group clojure-highlight global WinSetOption filetype=(?!clojure).* %{ remove-highlighter window/clojure } hook global WinSetOption filetype=(?!clojure).* %{ remove-hooks window clojure-indent diff --git a/rc/base/css.kak b/rc/base/css.kak index 391400ca..c6a0d7e2 100644 --- a/rc/base/css.kak +++ b/rc/base/css.kak @@ -11,29 +11,29 @@ hook global BufCreate .*[.](css) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default selector css \ +add-highlighter shared/ regions -default selector css \ declaration [{] [}] '' \ comment /[*] [*]/ '' -add-highlighter -group /css/comment fill comment +add-highlighter shared/css/comment fill comment -add-highlighter -group /css/declaration regions content \ +add-highlighter shared/css/declaration regions content \ string '"' (? ~ -hook -group gas-highlight global WinSetOption filetype=gas %{ add-highlighter ref gas } +hook -group gas-highlight global WinSetOption filetype=gas %{ add-highlighter window ref 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 gas } +hook -group gas-highlight global WinSetOption filetype=(?!gas).* %{ remove-highlighter window/gas } hook global WinSetOption filetype=(?!gas).* %{ remove-hooks window gas-indent diff --git a/rc/base/git.kak b/rc/base/git.kak index e0dfe992..dbf956cf 100644 --- a/rc/base/git.kak +++ b/rc/base/git.kak @@ -3,22 +3,22 @@ hook global BufCreate .*(COMMIT_EDITMSG|MERGE_MSG) %{ } hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ - add-highlighter group git-commit-highlight - add-highlighter -group git-commit-highlight regex "^\h*#[^\n]*\n" 0:cyan,default - add-highlighter -group git-commit-highlight regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)\n" 1:yellow 2:red 3:green 4:blue 5:magenta - add-highlighter -group git-commit-highlight ref diff # highlight potential diffs from the -v option + add-highlighter window group git-commit-highlight + add-highlighter window/git-commit-highlight regex "^\h*#[^\n]*\n" 0:cyan,default + add-highlighter window/git-commit-highlight regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)\n" 1:yellow 2:red 3:green 4:blue 5:magenta + add-highlighter window/git-commit-highlight ref diff # highlight potential diffs from the -v option } -hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter git-commit-highlight } +hook -group git-commit-highlight global WinSetOption filetype=(?!git-commit).* %{ remove-highlighter window/git-commit-highlight } hook global BufCreate .*git-rebase-todo %{ set buffer filetype git-rebase } hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ - add-highlighter group git-rebase-highlight - add-highlighter -group git-rebase-highlight regex "#[^\n]*\n" 0:cyan,default - add-highlighter -group git-rebase-highlight regex "^(pick|edit|reword|squash|fixup|exec|[persfx]) (\w+)" 1:green 2:magenta + add-highlighter window group git-rebase-highlight + 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|[persfx]) (\w+)" 1:green 2:magenta } -hook -group git-rebase-highlight global WinSetOption filetype=(?!git-rebase).* %{ remove-highlighter git-rebase-highlight } +hook -group git-rebase-highlight global WinSetOption filetype=(?!git-rebase).* %{ remove-highlighter window/git-rebase-highlight } diff --git a/rc/base/go.kak b/rc/base/go.kak index a6089563..24060882 100644 --- a/rc/base/go.kak +++ b/rc/base/go.kak @@ -11,19 +11,19 @@ hook global BufCreate .*\.go %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code go \ +add-highlighter shared/ regions -default code go \ back_string '`' '`' '' \ double_string '"' (??@\\\^|~=]|$) $ '' -add-highlighter -group /haskell/string fill string -add-highlighter -group /haskell/comment fill comment -add-highlighter -group /haskell/pragma fill meta -add-highlighter -group /haskell/macro fill meta +add-highlighter shared/haskell/string fill string +add-highlighter shared/haskell/comment fill comment +add-highlighter shared/haskell/pragma fill meta +add-highlighter shared/haskell/macro fill meta -add-highlighter -group /haskell/code regex (?> # not operator keywords: M... M.-> -add-highlighter -group /haskell/code regex \b[A-Z]['\w]*\.[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator +add-highlighter shared/haskell/code regex \b[A-Z]['\w]*\.[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches dot: . # not possibly incomplete import: a. # not other operators: !. .! -add-highlighter -group /haskell/code regex (?|:!?/.@$*&#%+\^\-\\])\.(?![~<=>|:!?/.@$*&#%+\^\-\\]) 0:operator +add-highlighter shared/haskell/code regex (?|:!?/.@$*&#%+\^\-\\])\.(?![~<=>|:!?/.@$*&#%+\^\-\\]) 0:operator # matches other operators: ... > < <= ^ <*> <$> etc # not dot: . # not operator keywords: @ .. -> :: ~ -add-highlighter -group /haskell/code regex (?|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator +add-highlighter shared/haskell/code regex (?|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches operator keywords: @ -> -add-highlighter -group /haskell/code regex (?|:!?/.@$*&#%+\^\-\\])(@|~|<-|->|=>|::|=|:|[|])(?![~<=>|:!?/.@$*&#%+\^\-\\]) 1:keyword +add-highlighter shared/haskell/code regex (?|:!?/.@$*&#%+\^\-\\])(@|~|<-|->|=>|::|=|:|[|])(?![~<=>|:!?/.@$*&#%+\^\-\\]) 1:keyword # matches: forall [..variables..] . # not the variables -add-highlighter -group /haskell/code regex \b(forall)\b[^.\n]*?(\.) 1:keyword 2:keyword +add-highlighter shared/haskell/code regex \b(forall)\b[^.\n]*?(\.) 1:keyword 2:keyword # matches 'x' '\\' '\'' '\n' '\0' # not incomplete literals: '\' # not valid identifiers: w' _' -add-highlighter -group /haskell/code regex \B'([^\\]|[\\]['"\w\d\\])' 0:string +add-highlighter shared/haskell/code regex \B'([^\\]|[\\]['"\w\d\\])' 0:string # this has to come after operators so '-' etc is correct # Commands @@ -95,7 +95,7 @@ def -hidden haskell-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter ref haskell } +hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter window ref haskell } hook global WinSetOption filetype=haskell %{ set window extra_word_chars "'" @@ -103,7 +103,7 @@ hook global WinSetOption filetype=haskell %{ hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line } -hook -group haskell-highlight global WinSetOption filetype=(?!haskell).* %{ remove-highlighter haskell } +hook -group haskell-highlight global WinSetOption filetype=(?!haskell).* %{ remove-highlighter window/haskell } hook global WinSetOption filetype=(?!haskell).* %{ remove-hooks window haskell-indent diff --git a/rc/base/html.kak b/rc/base/html.kak index b1695535..ca7132f2 100644 --- a/rc/base/html.kak +++ b/rc/base/html.kak @@ -15,26 +15,26 @@ hook global BufCreate .*\.xml %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions html \ +add-highlighter shared/ regions html \ comment '' \ tag < > '' \ style \K (?=) '' \ script \K (?=) '' -add-highlighter -group /html/comment fill comment +add-highlighter shared/html/comment fill comment -add-highlighter -group /html/style ref css -add-highlighter -group /html/script ref javascript +add-highlighter shared/html/style ref css +add-highlighter shared/html/script ref javascript -add-highlighter -group /html/tag regex \b([a-zA-Z0-9_-]+)=? 1:attribute -add-highlighter -group /html/tag regex |<=|=|>=) 0:operator -add-highlighter -group /lisp/code regex \b(([':]\w+)|([*]\H+[*]))\b 0:variable -add-highlighter -group /lisp/code regex \b(def[a-z]+|if|do|let|lambda|catch|and|assert|while|def|do|fn|finally|let|loop|new|quote|recur|set!|throw|try|var|case|if-let|if-not|when|when-first|when-let|when-not|(cond(->|->>)?))\b 0:keyword +add-highlighter shared/lisp/code regex \b(nil|true|false)\b 0:value +add-highlighter shared/lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=) 0:operator +add-highlighter shared/lisp/code regex \b(([':]\w+)|([*]\H+[*]))\b 0:variable +add-highlighter shared/lisp/code regex \b(def[a-z]+|if|do|let|lambda|catch|and|assert|while|def|do|fn|finally|let|loop|new|quote|recur|set!|throw|try|var|case|if-let|if-not|when|when-first|when-let|when-not|(cond(->|->>)?))\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ @@ -43,14 +43,14 @@ def -hidden lisp-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter ref lisp } +hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter window ref lisp } hook global WinSetOption filetype=lisp %{ hook window InsertEnd .* -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 lisp } +hook -group lisp-highlight global WinSetOption filetype=(?!lisp).* %{ remove-highlighter window/lisp } hook global WinSetOption filetype=(?!lisp).* %{ remove-hooks window lisp-indent diff --git a/rc/base/lua.kak b/rc/base/lua.kak index 9b453dbf..46979484 100644 --- a/rc/base/lua.kak +++ b/rc/base/lua.kak @@ -11,17 +11,17 @@ hook global BufCreate .*[.](lua) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code lua \ +add-highlighter shared/ regions -default code lua \ string '"' (?]+@.*?> 0:string -add-highlighter -group /mail regex ^>.*?$ 0:comment +add-highlighter shared/ group mail +add-highlighter shared/mail regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute +add-highlighter shared/mail regex <[^@>]+@.*?> 0:string +add-highlighter shared/mail regex ^>.*?$ 0:comment -hook -group mail-highlight global WinSetOption filetype=mail %{ add-highlighter ref mail } -hook -group mail-highlight global WinSetOption filetype=(?!mail).* %{ remove-highlighter mail } +hook -group mail-highlight global WinSetOption filetype=mail %{ add-highlighter window ref mail } +hook -group mail-highlight global WinSetOption filetype=(?!mail).* %{ remove-highlighter window/mail } diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index bc7a24ec..d1cbec9b 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -11,7 +11,7 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default content markdown \ +add-highlighter shared/ regions -default content markdown \ c ```\h*c ``` '' \ cabal ```\h*cabal ``` '' \ clojure ```\h*clojure ``` '' \ @@ -58,67 +58,67 @@ add-highlighter -group / regions -default content markdown \ code `` `` '' \ code ` ` '' -add-highlighter -group /markdown/code fill meta +add-highlighter shared/markdown/code fill meta -add-highlighter -group /markdown/c ref c -add-highlighter -group /markdown/cabal ref cabal -add-highlighter -group /markdown/clojure ref clojure -add-highlighter -group /markdown/coffee ref coffee -add-highlighter -group /markdown/cpp ref cpp -add-highlighter -group /markdown/css ref css -add-highlighter -group /markdown/cucumber ref cucumber -add-highlighter -group /markdown/d ref d -add-highlighter -group /markdown/diff ref diff -add-highlighter -group /markdown/dockerfile ref dockerfile -add-highlighter -group /markdown/fish ref fish -add-highlighter -group /markdown/gas ref gas -add-highlighter -group /markdown/go ref go -add-highlighter -group /markdown/haml ref haml -add-highlighter -group /markdown/haskell ref haskell -add-highlighter -group /markdown/html ref html -add-highlighter -group /markdown/ini ref ini -add-highlighter -group /markdown/java ref java -add-highlighter -group /markdown/javascript ref javascript -add-highlighter -group /markdown/json ref json -add-highlighter -group /markdown/julia ref julia -add-highlighter -group /markdown/kak ref kakrc -add-highlighter -group /markdown/kickstart ref kickstart -add-highlighter -group /markdown/latex ref latex -add-highlighter -group /markdown/lisp ref lisp -add-highlighter -group /markdown/lua ref lua -add-highlighter -group /markdown/makefile ref makefile -add-highlighter -group /markdown/moon ref moon -add-highlighter -group /markdown/objc ref objc -add-highlighter -group /markdown/perl ref perl -add-highlighter -group /markdown/pug ref pug -add-highlighter -group /markdown/python ref python -add-highlighter -group /markdown/ragel ref ragel -add-highlighter -group /markdown/ruby ref ruby -add-highlighter -group /markdown/rust ref rust -add-highlighter -group /markdown/sass ref sass -add-highlighter -group /markdown/scala ref scala -add-highlighter -group /markdown/scss ref scss -add-highlighter -group /markdown/sh ref sh -add-highlighter -group /markdown/swift ref swift -add-highlighter -group /markdown/tupfile ref tupfile -add-highlighter -group /markdown/yaml ref yaml +add-highlighter shared/markdown/c ref c +add-highlighter shared/markdown/cabal ref cabal +add-highlighter shared/markdown/clojure ref clojure +add-highlighter shared/markdown/coffee ref coffee +add-highlighter shared/markdown/cpp ref cpp +add-highlighter shared/markdown/css ref css +add-highlighter shared/markdown/cucumber ref cucumber +add-highlighter shared/markdown/d ref d +add-highlighter shared/markdown/diff ref diff +add-highlighter shared/markdown/dockerfile ref dockerfile +add-highlighter shared/markdown/fish ref fish +add-highlighter shared/markdown/gas ref gas +add-highlighter shared/markdown/go ref go +add-highlighter shared/markdown/haml ref haml +add-highlighter shared/markdown/haskell ref haskell +add-highlighter shared/markdown/html ref html +add-highlighter shared/markdown/ini ref ini +add-highlighter shared/markdown/java ref java +add-highlighter shared/markdown/javascript ref javascript +add-highlighter shared/markdown/json ref json +add-highlighter shared/markdown/julia ref julia +add-highlighter shared/markdown/kak ref kakrc +add-highlighter shared/markdown/kickstart ref kickstart +add-highlighter shared/markdown/latex ref latex +add-highlighter shared/markdown/lisp ref lisp +add-highlighter shared/markdown/lua ref lua +add-highlighter shared/markdown/makefile ref makefile +add-highlighter shared/markdown/moon ref moon +add-highlighter shared/markdown/objc ref objc +add-highlighter shared/markdown/perl ref perl +add-highlighter shared/markdown/pug ref pug +add-highlighter shared/markdown/python ref python +add-highlighter shared/markdown/ragel ref ragel +add-highlighter shared/markdown/ruby ref ruby +add-highlighter shared/markdown/rust ref rust +add-highlighter shared/markdown/sass ref sass +add-highlighter shared/markdown/scala ref scala +add-highlighter shared/markdown/scss ref scss +add-highlighter shared/markdown/sh ref sh +add-highlighter shared/markdown/swift ref swift +add-highlighter shared/markdown/tupfile ref tupfile +add-highlighter shared/markdown/yaml ref yaml # Setext-style header -add-highlighter -group /markdown/content regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:title -add-highlighter -group /markdown/content regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:header +add-highlighter shared/markdown/content regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:title +add-highlighter shared/markdown/content regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:header # Atx-style header -add-highlighter -group /markdown/content regex ^(#+)(\h+)([^\n]+) 1:header +add-highlighter shared/markdown/content regex ^(#+)(\h+)([^\n]+) 1:header -add-highlighter -group /markdown/content regex ^\h?((?:[\s\t]+)?[-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*\n)*$ 0:list 1:bullet -add-highlighter -group /markdown/content regex \B\+[^\n]+?\+\B 0:mono -add-highlighter -group /markdown/content regex \B\*[^\n]+?\*\B 0:italic -add-highlighter -group /markdown/content regex \b_[^\n]+?_\b 0:italic -add-highlighter -group /markdown/content regex \B\*\*[^\n]+?\*\*\B 0:bold -add-highlighter -group /markdown/content regex \B__[^\n]+?__\B 0:bold -add-highlighter -group /markdown/content regex <(([a-z]+://.*?)|((mailto:)?[\w+-]+@[a-z]+[.][a-z]+))> 0:link -add-highlighter -group /markdown/content regex ^\h*(>\h*)+ 0:comment -add-highlighter -group /markdown/content regex \H\K\h\h$ 0:PrimarySelection +add-highlighter shared/markdown/content regex ^\h?((?:[\s\t]+)?[-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*\n)*$ 0:list 1:bullet +add-highlighter shared/markdown/content regex \B\+[^\n]+?\+\B 0:mono +add-highlighter shared/markdown/content regex \B\*[^\n]+?\*\B 0:italic +add-highlighter shared/markdown/content regex \b_[^\n]+?_\b 0:italic +add-highlighter shared/markdown/content regex \B\*\*[^\n]+?\*\*\B 0:bold +add-highlighter shared/markdown/content regex \B__[^\n]+?__\B 0:bold +add-highlighter shared/markdown/content regex <(([a-z]+://.*?)|((mailto:)?[\w+-]+@[a-z]+[.][a-z]+))> 0:link +add-highlighter shared/markdown/content regex ^\h*(>\h*)+ 0:comment +add-highlighter shared/markdown/content regex \H\K\h\h$ 0:PrimarySelection # Commands # ‾‾‾‾‾‾‾‾ @@ -137,13 +137,13 @@ def -hidden markdown-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group markdown-highlight global WinSetOption filetype=markdown %{ add-highlighter ref markdown } +hook -group markdown-highlight global WinSetOption filetype=markdown %{ add-highlighter window ref 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 markdown } +hook -group markdown-highlight global WinSetOption filetype=(?!markdown).* %{ remove-highlighter window/markdown } hook global WinSetOption filetype=(?!markdown).* %{ remove-hooks window markdown-indent diff --git a/rc/base/mercurial.kak b/rc/base/mercurial.kak index cd03b011..3e2a3eac 100644 --- a/rc/base/mercurial.kak +++ b/rc/base/mercurial.kak @@ -14,13 +14,13 @@ hook global BufCreate .*hg-editor-\w+\.txt$ %{ } hook -group hg-commit-highlight global WinSetOption filetype=(?!hg-commit).* %{ - remove-highlighter hg-commit-highlight + remove-highlighter window/hg-commit-highlight } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ - add-highlighter group hg-commit-highlight - add-highlighter -group hg-commit-highlight regex '^HG:[^\n]*' 0:MercurialCommitComment + add-highlighter window group hg-commit-highlight + add-highlighter window/hg-commit-highlight regex '^HG:[^\n]*' 0:MercurialCommitComment } diff --git a/rc/base/ocaml.kak b/rc/base/ocaml.kak index 8f298c6a..e6e29dc5 100644 --- a/rc/base/ocaml.kak +++ b/rc/base/ocaml.kak @@ -13,12 +13,12 @@ hook global BufCreate .*\.mli? %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code ocaml \ +add-highlighter shared/ regions -default code ocaml \ string '"' (?|\$\?|\$@|\$\[|\$\\|\$\]|\$\^|\$\||\$~|%!|@\+|@-|@_} 0:value -add-highlighter -group /perl/code regex (%ENV|%INC|%OVERLOAD|%SIG|@ARGV|@INC|@LAST_MATCH_START) 0:value -add-highlighter -group /perl/code regex %{%\^(H)\b} 0:value -add-highlighter -group /perl/code regex \$\^(S|T|V|W|X|A|C|D|E|F|H|I|L|M|N|O|P|R)\b 0:value -add-highlighter -group /perl/code regex \$\^(RE_TRIE_MAXBUF|TAINT|UNICODE|UTF8LOCALE|WARNING_BITS|WIDE_SYSTEM_CALLS|CHILD_ERROR_NATIVE|ENCODING|OPEN|RE_DEBUG_FLAGS)\b 0:value +add-highlighter shared/perl/code regex (?!\$)-?([0-9]*\.(?!0[xXbB]))?\b([0-9]+|0[xX][0-9a-fA-F]+|0[bb][01_]+)\.?([eE][+-]?[0-9]+)?i?\b 0:value +add-highlighter shared/perl/code regex %{\$!|\$"|\$#|\$\$|\$%|\$&|\$'|\$\(|\$\)|\$\*|\$\+|\$,|\$_|\$-|\$`|\$\.|\$/|\$:|\$;|\$<|\$=|\$>|\$\?|\$@|\$\[|\$\\|\$\]|\$\^|\$\||\$~|%!|@\+|@-|@_} 0:value +add-highlighter shared/perl/code regex (%ENV|%INC|%OVERLOAD|%SIG|@ARGV|@INC|@LAST_MATCH_START) 0:value +add-highlighter shared/perl/code regex %{%\^(H)\b} 0:value +add-highlighter shared/perl/code regex \$\^(S|T|V|W|X|A|C|D|E|F|H|I|L|M|N|O|P|R)\b 0:value +add-highlighter shared/perl/code regex \$\^(RE_TRIE_MAXBUF|TAINT|UNICODE|UTF8LOCALE|WARNING_BITS|WIDE_SYSTEM_CALLS|CHILD_ERROR_NATIVE|ENCODING|OPEN|RE_DEBUG_FLAGS)\b 0:value -add-highlighter -group /perl/code regex \$[0-9]+ 0:attribute -add-highlighter -group /perl/code regex \b-(B|b|C|c|d|e|f|g|k|l|M|O|o|p|r|R|S|s|T|t|u|w|W|X|x|z)\b 0:attribute +add-highlighter shared/perl/code regex \$[0-9]+ 0:attribute +add-highlighter shared/perl/code regex \b-(B|b|C|c|d|e|f|g|k|l|M|O|o|p|r|R|S|s|T|t|u|w|W|X|x|z)\b 0:attribute -add-highlighter -group /perl/code regex \$[a-zA-Z_][a-zA-Z0-9_]* 0:variable +add-highlighter shared/perl/code regex \$[a-zA-Z_][a-zA-Z0-9_]* 0:variable -add-highlighter -group /perl/code regex \$(a|b|LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR)\b 0:value -add-highlighter -group /perl/code regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR|PERL_VERSION|ACCUMULATOR|PERLDB|ARG|PID|ARGV|POSTMATCH|PREMATCH|BASETIME|PROCESS_ID|CHILD_ERROR|PROGRAM_NAME|COMPILING|REAL_GROUP_ID|DEBUGGING|REAL_USER_ID|EFFECTIVE_GROUP_ID|RS|EFFECTIVE_USER_ID|SUBSCRIPT_SEPARATOR|EGID|SUBSEP|ERRNO|SYSTEM_FD_MAX|EUID|UID|EVAL_ERROR|WARNING|EXCEPTIONS_BEING_CAUGHT|EXECUTABLE_NAME|EXTENDED_OS_ERROR|FORMAT_FORMFEED|FORMAT_LINE_BREAK_CHARACTERS|FORMAT_LINES_LEFT|FORMAT_LINES_PER_PAGE|FORMAT_NAME|FORMAT_PAGE_NUMBER|FORMAT_TOP_NAME|GID|INPLACE_EDIT|INPUT_LINE_NUMBER|INPUT_RECORD_SEPARATOR|LAST_MATCH_END|LAST_PAREN_MATCH)\b 0:value +add-highlighter shared/perl/code regex \$(a|b|LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR)\b 0:value +add-highlighter shared/perl/code regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR|PERL_VERSION|ACCUMULATOR|PERLDB|ARG|PID|ARGV|POSTMATCH|PREMATCH|BASETIME|PROCESS_ID|CHILD_ERROR|PROGRAM_NAME|COMPILING|REAL_GROUP_ID|DEBUGGING|REAL_USER_ID|EFFECTIVE_GROUP_ID|RS|EFFECTIVE_USER_ID|SUBSCRIPT_SEPARATOR|EGID|SUBSEP|ERRNO|SYSTEM_FD_MAX|EUID|UID|EVAL_ERROR|WARNING|EXCEPTIONS_BEING_CAUGHT|EXECUTABLE_NAME|EXTENDED_OS_ERROR|FORMAT_FORMFEED|FORMAT_LINE_BREAK_CHARACTERS|FORMAT_LINES_LEFT|FORMAT_LINES_PER_PAGE|FORMAT_NAME|FORMAT_PAGE_NUMBER|FORMAT_TOP_NAME|GID|INPLACE_EDIT|INPUT_LINE_NUMBER|INPUT_RECORD_SEPARATOR|LAST_MATCH_END|LAST_PAREN_MATCH)\b 0:value # Commands # ‾‾‾‾‾‾‾‾ @@ -102,7 +102,7 @@ def -hidden perl-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter ref perl } +hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter window ref perl } hook global WinSetOption filetype=perl %{ # cleanup trailing whitespaces when exiting insert mode @@ -112,7 +112,7 @@ hook global WinSetOption filetype=perl %{ hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace } -hook -group perl-highlight global WinSetOption filetype=(?!perl).* %{ remove-highlighter perl } +hook -group perl-highlight global WinSetOption filetype=(?!perl).* %{ remove-highlighter window/perl } hook global WinSetOption filetype=(?!perl).* %{ remove-hooks window perl-hooks diff --git a/rc/base/ruby.kak b/rc/base/ruby.kak index 0c15c5c5..eb8bf01a 100644 --- a/rc/base/ruby.kak +++ b/rc/base/ruby.kak @@ -11,7 +11,7 @@ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Capfile|[.]cap)|(Gemfile)|(G # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code ruby \ +add-highlighter shared/ regions -default code ruby \ double_string '"' (?|<:|:>|=:=|::|&&|\|\|)\b 0:operator -add-highlighter -group /scala/code regex "'[_A-Za-z0-9$]+" 0:variable +add-highlighter shared/scala/code regex \b(import|package)\b 0:meta +add-highlighter shared/scala/code regex \b(this|true|false|null)\b 0:value +add-highlighter shared/scala/code regex \b(become|case|catch|class|def|do|else|extends|final|finally|for|forSome|goto|if|initialize|macro|match|new|object|onTransition|return|startWith|stay|throw|trait|try|unbecome|using|val|var|when|while|with|yield)\b 0:keyword +add-highlighter shared/scala/code regex \b(abstract|final|implicit|implicitly|lazy|override|private|protected|require|sealed|super)\b 0:attribute +add-highlighter shared/scala/code regex \b(⇒|=>|<:|:>|=:=|::|&&|\|\|)\b 0:operator +add-highlighter shared/scala/code regex "'[_A-Za-z0-9$]+" 0:variable # Commands # ‾‾‾‾‾‾‾‾ @@ -62,7 +62,7 @@ def -hidden scala-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group scala-highlight global WinSetOption filetype=scala %{ add-highlighter ref scala } +hook -group scala-highlight global WinSetOption filetype=scala %{ add-highlighter window ref scala } hook global WinSetOption filetype=scala %[ hook window InsertEnd .* -group scala-hooks scala-filter-around-selections @@ -70,7 +70,7 @@ hook global WinSetOption filetype=scala %[ hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace ] -hook -group scala-highlight global WinSetOption filetype=(?!scala).* %{ remove-highlighter scala } +hook -group scala-highlight global WinSetOption filetype=(?!scala).* %{ remove-highlighter window/scala } hook global WinSetOption filetype=(?!scala).* %{ remove-hooks window scala-indent diff --git a/rc/base/spell.kak b/rc/base/spell.kak index e1b7915e..5fbe56c0 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -9,7 +9,7 @@ Formats of language supported: - ISO language code, e.g. 'en' - language code above followed by a dash or underscore with an ISO country code, e.g. 'en-US'} \ spell %{ - try %{ add-highlighter ranges 'spell_regions' } + try %{ add-highlighter window ranges 'spell_regions' } %sh{ file=$(mktemp -d "${TMPDIR:-/tmp}"/kak-spell.XXXXXXXX)/buffer printf 'eval -no-hooks write %s\n' "${file}" diff --git a/rc/base/sql.kak b/rc/base/sql.kak index 7af62fef..ab92e28e 100644 --- a/rc/base/sql.kak +++ b/rc/base/sql.kak @@ -11,7 +11,7 @@ hook global BufCreate .*/?(?i)sql %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code sql \ +add-highlighter shared/ regions -default code sql \ string '"' (?|<|>=|<=|<>|\+=|-=|\*=|/=|%=|&=|^-=|\|\*=' 0:operator -add-highlighter -group /sql/code regex \bNULL\b 0:value -add-highlighter -group /sql/code regex \b\d+(?:\.\d+)?\b 0:value -add-highlighter -group /sql/string fill string -add-highlighter -group /sql/comment fill comment +add-highlighter shared/sql/code regex '\+|-|\*|/|%|&|\||^|=|>|<|>=|<=|<>|\+=|-=|\*=|/=|%=|&=|^-=|\|\*=' 0:operator +add-highlighter shared/sql/code regex \bNULL\b 0:value +add-highlighter shared/sql/code regex \b\d+(?:\.\d+)?\b 0:value +add-highlighter shared/sql/string fill string +add-highlighter shared/sql/comment fill comment # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group sql-highlight global WinSetOption filetype=sql %{ - add-highlighter ref sql + add-highlighter window ref sql } hook -group sql-highlight global WinSetOption filetype=(?!sql).* %{ - remove-highlighter sql + remove-highlighter window/sql } diff --git a/rc/base/swift.kak b/rc/base/swift.kak index 91028e61..ca768bb2 100644 --- a/rc/base/swift.kak +++ b/rc/base/swift.kak @@ -2,26 +2,26 @@ hook global BufCreate .*\.(swift) %{ set buffer filetype swift } -add-highlighter -group / regions -default code swift \ +add-highlighter shared/ regions -default code swift \ string %{(? grep-jump } -hook -group grep-highlight global WinSetOption filetype=(?!grep).* %{ remove-highlighter grep } +hook -group grep-highlight global WinSetOption filetype=(?!grep).* %{ remove-highlighter window/grep } hook global WinSetOption filetype=(?!grep).* %{ remove-hooks buffer grep-hooks diff --git a/rc/core/kakrc.kak b/rc/core/kakrc.kak index 1d33d8a2..eb92788c 100644 --- a/rc/core/kakrc.kak +++ b/rc/core/kakrc.kak @@ -11,7 +11,7 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code kakrc \ +add-highlighter shared/ regions -default code kakrc \ comment (^|\h)\K# $ '' \ double_string %{(^|\h)\K"} %{(? s ^\h+$ d } } } -hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ remove-highlighter kakrc } +hook -group kak-highlight global WinSetOption filetype=(?!kak).* %{ remove-highlighter window/kakrc } hook global WinSetOption filetype=(?!kak).* %{ remove-hooks window kak-indent } diff --git a/rc/core/make.kak b/rc/core/make.kak index 6da7f143..9aba90ba 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -26,18 +26,18 @@ All the optional arguments are forwarded to the make utility} \ }" }} -add-highlighter -group / group make -add-highlighter -group /make regex "^((?:\w:)?[^:\n]+):(\d+):(?:(\d+):)?\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow -add-highlighter -group /make regex "^\h*(~*(?:(\^)~*)?)$" 1:green 2:cyan+b -add-highlighter -group /make line '%opt{make_current_error_line}' default+b +add-highlighter shared/ group make +add-highlighter shared/make regex "^((?:\w:)?[^:\n]+):(\d+):(?:(\d+):)?\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow +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 ref make } +hook -group make-highlight global WinSetOption filetype=make %{ add-highlighter window ref make } hook global WinSetOption filetype=make %{ hook buffer -group make-hooks NormalKey make-jump } -hook -group make-highlight global WinSetOption filetype=(?!make).* %{ remove-highlighter make } +hook -group make-highlight global WinSetOption filetype=(?!make).* %{ remove-highlighter window/make } hook global WinSetOption filetype=(?!make).* %{ remove-hooks buffer make-hooks diff --git a/rc/core/makefile.kak b/rc/core/makefile.kak index 3e610408..06e93402 100644 --- a/rc/core/makefile.kak +++ b/rc/core/makefile.kak @@ -8,15 +8,15 @@ hook global BufCreate .*/?[mM]akefile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default content makefile \ +add-highlighter shared/ regions -default content makefile \ comment '#' '$' '' \ eval '\$\(' '\)' '\(' -add-highlighter -group /makefile/comment fill comment -add-highlighter -group /makefile/eval fill value +add-highlighter shared/makefile/comment fill comment +add-highlighter shared/makefile/eval fill value -add-highlighter -group /makefile/content regex ^[\w.%-]+\h*:\s 0:variable -add-highlighter -group /makefile/content regex [+?:]= 0:operator +add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable +add-highlighter shared/makefile/content regex [+?:]= 0:operator %sh{ # Grammar @@ -28,7 +28,7 @@ add-highlighter -group /makefile/content regex [+?:]= 0:operator }" | sed 's,|,:,g' # Highlight keywords - printf %s "add-highlighter -group /makefile/content regex \b(${keywords})\b 0:keyword" + printf %s "add-highlighter shared/makefile/content regex \b(${keywords})\b 0:keyword" } # Commands @@ -50,13 +50,13 @@ def -hidden makefile-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter ref makefile } +hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window ref 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 makefile } +hook -group makefile-highlight global WinSetOption filetype=(?!makefile).* %{ remove-highlighter window/makefile } hook global WinSetOption filetype=(?!makefile).* %{ remove-hooks window makefile-indent diff --git a/rc/core/man.kak b/rc/core/man.kak index 40388bff..fc0064be 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -4,15 +4,15 @@ decl -docstring "name of the client in which documentation is to be displayed" \ decl -hidden str manpage hook -group man-highlight global WinSetOption filetype=man %{ - add-highlighter group man-highlight + add-highlighter window group man-highlight # Sections - add-highlighter -group man-highlight regex ^\S.*?$ 0:blue + add-highlighter window/man-highlight regex ^\S.*?$ 0:blue # Subsections - add-highlighter -group man-highlight regex '^ {3}\S.*?$' 0:default+b + add-highlighter window/man-highlight regex '^ {3}\S.*?$' 0:default+b # Command line options - add-highlighter -group man-highlight regex '^ {7}-[^\s,]+(,\s+-[^\s,]+)*' 0:yellow + add-highlighter window/man-highlight regex '^ {7}-[^\s,]+(,\s+-[^\s,]+)*' 0:yellow # References to other manpages - add-highlighter -group man-highlight regex [-a-zA-Z0-9_.]+\([a-z0-9]+\) 0:green + add-highlighter window/man-highlight regex [-a-zA-Z0-9_.]+\([a-z0-9]+\) 0:green } hook global WinSetOption filetype=man %{ @@ -21,7 +21,7 @@ hook global WinSetOption filetype=man %{ } } -hook -group man-highlight global WinSetOption filetype=(?!man).* %{ remove-highlighter man-highlight } +hook -group man-highlight global WinSetOption filetype=(?!man).* %{ remove-highlighter window/man-highlight } hook global WinSetOption filetype=(?!man).* %{ remove-hooks window man-hooks diff --git a/rc/core/python.kak b/rc/core/python.kak index fcd749d5..15e94806 100644 --- a/rc/core/python.kak +++ b/rc/core/python.kak @@ -11,16 +11,16 @@ hook global BufCreate .*[.](py) %{ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code python \ +add-highlighter shared/ regions -default code python \ double_string '"""' '"""' '' \ single_string "'''" "'''" '' \ double_string '"' (? s ^\h+$ d } } } -hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter python } +hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python } hook global WinSetOption filetype=(?!python).* %{ remove-hooks window python-indent diff --git a/rc/core/sh.kak b/rc/core/sh.kak index 7c74cafa..bd840b5f 100644 --- a/rc/core/sh.kak +++ b/rc/core/sh.kak @@ -2,16 +2,16 @@ hook global BufCreate .*\.(z|ba|c|k)?sh(rc|_profile)? %{ set buffer filetype sh } -add-highlighter -group / regions -default code -match-capture sh \ +add-highlighter shared/ regions -default code -match-capture sh \ double_string %{(?]?=?)?\d+(\.\d+)+) 0:value -add-highlighter -group /cabal/code regex \b(if|else)\b 0:keyword -add-highlighter -group /cabal/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:variable +add-highlighter shared/cabal/code regex \b(true|false)\b|(([<>]?=?)?\d+(\.\d+)+) 0:value +add-highlighter shared/cabal/code regex \b(if|else)\b 0:keyword +add-highlighter shared/cabal/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:variable # Commands # ‾‾‾‾‾‾‾‾ @@ -59,7 +59,7 @@ def -hidden cabal-indent-on-closing-curly-brace %[ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group cabal-highlight global WinSetOption filetype=cabal %{ add-highlighter ref cabal } +hook -group cabal-highlight global WinSetOption filetype=cabal %{ add-highlighter window ref cabal } hook global WinSetOption filetype=cabal %[ hook window InsertEnd .* -group cabal-hooks cabal-filter-around-selections @@ -68,7 +68,7 @@ hook global WinSetOption filetype=cabal %[ hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace ] -hook -group cabal-highlight global WinSetOption filetype=(?!cabal).* %{ remove-highlighter cabal } +hook -group cabal-highlight global WinSetOption filetype=(?!cabal).* %{ remove-highlighter window/cabal } hook global WinSetOption filetype=(?!cabal).* %{ remove-hooks window cabal-indent diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index ba618b47..6396a6a0 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -147,13 +147,13 @@ def -hidden clang-show-error-info %{ def clang-enable-diagnostics -docstring %{Activate automatic error reporting and diagnostics Information about the analysis are showned after the buffer has been parsed with the clang-parse function} \ %{ - add-highlighter flag_lines default clang_flags + add-highlighter window flag_lines default clang_flags hook window -group clang-diagnostics NormalIdle .* %{ clang-show-error-info } hook window -group clang-diagnostics WinSetOption ^clang_errors=.* %{ info; clang-show-error-info } } def clang-disable-diagnostics -docstring "Disable automatic error reporting and diagnostics" %{ - remove-highlighter hlflags_clang_flags + remove-highlighter window/hlflags_clang_flags remove-hooks window clang-diagnostics } diff --git a/rc/extra/coffee.kak b/rc/extra/coffee.kak index 69654440..25d9428c 100644 --- a/rc/extra/coffee.kak +++ b/rc/extra/coffee.kak @@ -11,7 +11,7 @@ hook global BufCreate .*[.](coffee) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code coffee \ +add-highlighter shared/ regions -default code coffee \ double_string '"""' '"""' '' \ single_string "'''" "'''" '' \ comment '###' '###' '' \ @@ -24,23 +24,23 @@ add-highlighter -group / regions -default code coffee \ # Regular expression flags are: g → global match, i → ignore case, m → multi-lines, y → sticky # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp -add-highlighter -group /coffee/double_string fill string -add-highlighter -group /coffee/double_string regions regions interpolation \Q#{ \} \{ -add-highlighter -group /coffee/double_string/regions/interpolation fill meta -add-highlighter -group /coffee/single_string fill string -add-highlighter -group /coffee/regex fill meta -add-highlighter -group /coffee/regex regions regions interpolation \Q#{ \} \{ -add-highlighter -group /coffee/regex/regions/interpolation fill meta -add-highlighter -group /coffee/comment fill comment +add-highlighter shared/coffee/double_string fill string +add-highlighter shared/coffee/double_string regions regions interpolation \Q#{ \} \{ +add-highlighter shared/coffee/double_string/regions/interpolation fill meta +add-highlighter shared/coffee/single_string fill string +add-highlighter shared/coffee/regex fill meta +add-highlighter shared/coffee/regex regions regions interpolation \Q#{ \} \{ +add-highlighter shared/coffee/regex/regions/interpolation fill meta +add-highlighter shared/coffee/comment fill comment # Keywords are collected at # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords # http://coffeescript.org/documentation/docs/lexer.html#section-63 -add-highlighter -group /coffee/code regex [$@]\w* 0:variable -add-highlighter -group /coffee/code regex \b(Array|Boolean|Date|Function|Number|Object|RegExp|String)\b 0:type -add-highlighter -group /coffee/code regex \b(document|false|no|null|off|on|parent|self|this|true|undefined|window|yes)\b 0:value -add-highlighter -group /coffee/code regex \b(and|is|isnt|not|or)\b 0:operator -add-highlighter -group /coffee/code regex \b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|function|if|implements|import|in|instanceof|interface|let|native|new|package|private|protected|public|return|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword +add-highlighter shared/coffee/code regex [$@]\w* 0:variable +add-highlighter shared/coffee/code regex \b(Array|Boolean|Date|Function|Number|Object|RegExp|String)\b 0:type +add-highlighter shared/coffee/code regex \b(document|false|no|null|off|on|parent|self|this|true|undefined|window|yes)\b 0:value +add-highlighter shared/coffee/code regex \b(and|is|isnt|not|or)\b 0:operator +add-highlighter shared/coffee/code regex \b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|function|if|implements|import|in|instanceof|interface|let|native|new|package|private|protected|public|return|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ @@ -69,14 +69,14 @@ def -hidden coffee-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group coffee-highlight global WinSetOption filetype=coffee %{ add-highlighter ref coffee } +hook -group coffee-highlight global WinSetOption filetype=coffee %{ add-highlighter window ref coffee } hook global WinSetOption filetype=coffee %{ hook window InsertEnd .* -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 coffee } +hook -group coffee-highlight global WinSetOption filetype=(?!coffee).* %{ remove-highlighter window/coffee } hook global WinSetOption filetype=(?!coffee).* %{ remove-hooks window coffee-indent diff --git a/rc/extra/cucumber.kak b/rc/extra/cucumber.kak index 84f58519..b8dee97d 100644 --- a/rc/extra/cucumber.kak +++ b/rc/extra/cucumber.kak @@ -11,14 +11,14 @@ hook global BufCreate .*[.](feature|story) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code cucumber \ +add-highlighter shared/ regions -default code cucumber \ language ^\h*#\h*language: $ '' \ comment ^\h*# $ '' -add-highlighter -group /cucumber/language fill meta -add-highlighter -group /cucumber/comment fill comment +add-highlighter shared/cucumber/language fill meta +add-highlighter shared/cucumber/comment fill comment -add-highlighter -group /cucumber/language regex \S+$ 0:value +add-highlighter shared/cucumber/language regex \S+$ 0:value # Spoken languages # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -51,7 +51,7 @@ add-highlighter -group /cucumber/language regex \S+$ 0:value # … # } -add-highlighter -group /cucumber/code regex \b(Feature|Business\h+Need|Ability|Background|Scenario|Scenario\h+Outline|Scenario\h+Template|Examples|Scenarios|Given|When|Then|And|But)\b 0:keyword +add-highlighter shared/cucumber/code regex \b(Feature|Business\h+Need|Ability|Background|Scenario|Scenario\h+Outline|Scenario\h+Template|Examples|Scenarios|Given|When|Then|And|But)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ @@ -77,14 +77,14 @@ def -hidden cucumber-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ add-highlighter ref cucumber } +hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ add-highlighter window ref cucumber } hook global WinSetOption filetype=cucumber %{ hook window InsertEnd .* -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 cucumber } +hook -group cucumber-highlight global WinSetOption filetype=(?!cucumber).* %{ remove-highlighter window/cucumber } hook global WinSetOption filetype=(?!cucumber).* %{ remove-hooks window cucumber-indent diff --git a/rc/extra/dockerfile.kak b/rc/extra/dockerfile.kak index 253f8383..11d0ed98 100644 --- a/rc/extra/dockerfile.kak +++ b/rc/extra/dockerfile.kak @@ -13,30 +13,30 @@ hook global BufCreate .*Dockerfile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions dockerfile \ +add-highlighter shared/ regions dockerfile \ instruction '^(?i)(ONBUILD\h+)?(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR)' '$' '' \ comment '#' '$' '' -add-highlighter -group /dockerfile/instruction regex '^(?i)(ONBUILD\h+)?(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR)' 0:keyword +add-highlighter shared/dockerfile/instruction regex '^(?i)(ONBUILD\h+)?(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR)' 0:keyword -add-highlighter -group /dockerfile/instruction regions regions \ +add-highlighter shared/dockerfile/instruction regions regions \ plain '^(?i)(ONBUILD\h+)?(LABEL|ENV)' '$' '' \ json '^(?i)(ONBUILD\h+)?(RUN|CMD|ADD|COPY|ENTRYPOINT|VOLUME)\h+\[' \] \[ \ sh '^(?i)(ONBUILD\h+)?(RUN|CMD|ENTRYPOINT)\h+([A-Z/a-z])+' '$' '' -add-highlighter -group /dockerfile/instruction/regions/plain regions regions \ +add-highlighter shared/dockerfile/instruction/regions/plain regions regions \ string '"' '(?|<-|<<|>>|=>) 0:builtin -add-highlighter -group /elixir/code regex \b(require|alias|use|import)\b 0:keyword -add-highlighter -group /elixir/code regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:value -add-highlighter -group /elixir/code regex \b(def|defp|defmacro|defmacrop|defstruct|defmodule|defimpl|defprotocol|defoverridable)\b 0:keyword -add-highlighter -group /elixir/code regex \b(fn|do|end|when|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword -add-highlighter -group /elixir/code regex '@[\w_]+\b' 0:attribute -add-highlighter -group /elixir/code regex '\b\d+[\d_]*\b' 0:value +add-highlighter shared/elixir/comment fill comment +add-highlighter shared/elixir/double_string fill string +add-highlighter shared/elixir/double_string regions regions interpolation \Q#{ \} \{ +add-highlighter shared/elixir/double_string/regions/interpolation fill builtin +add-highlighter shared/elixir/single_string fill string +add-highlighter shared/elixir/code regex ':[\w_]+\b' 0:type +add-highlighter shared/elixir/code regex '[\w_]+:' 0:type +add-highlighter shared/elixir/code regex '[A-Z][\w_]+\b' 0:module +add-highlighter shared/elixir/code regex '(:[\w_]+)(\.)' 1:module +add-highlighter shared/elixir/code regex '\b_\b' 0:default +add-highlighter shared/elixir/code regex '\b_[\w_]+\b' 0:default +add-highlighter shared/elixir/code regex '~[a-zA-Z]\(.*\)' 0:string +add-highlighter shared/elixir/code regex \b(true|false|nil)\b 0:value +add-highlighter shared/elixir/code regex (->|<-|<<|>>|=>) 0:builtin +add-highlighter shared/elixir/code regex \b(require|alias|use|import)\b 0:keyword +add-highlighter shared/elixir/code regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:value +add-highlighter shared/elixir/code regex \b(def|defp|defmacro|defmacrop|defstruct|defmodule|defimpl|defprotocol|defoverridable)\b 0:keyword +add-highlighter shared/elixir/code regex \b(fn|do|end|when|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword +add-highlighter shared/elixir/code regex '@[\w_]+\b' 0:attribute +add-highlighter shared/elixir/code regex '\b\d+[\d_]*\b' 0:value # Commands # ‾‾‾‾‾‾‾‾ @@ -65,12 +65,12 @@ def -hidden elixir-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group elixir-highlight global WinSetOption filetype=elixir %{ add-highlighter ref elixir } +hook -group elixir-highlight global WinSetOption filetype=elixir %{ add-highlighter window ref elixir } hook global WinSetOption filetype=elixir %{ hook window InsertEnd .* -group elixir-hooks elixir-filter-around-selections hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line } -hook -group elixir-highlight global WinSetOption filetype=(?!elixir).* %{ remove-highlighter 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 15913197..4764a9a6 100644 --- a/rc/extra/elm.kak +++ b/rc/extra/elm.kak @@ -11,18 +11,18 @@ hook global BufCreate .*[.](elm) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code elm \ +add-highlighter shared/ regions -default code elm \ string '"' (?]+@.*?> 0:string -add-highlighter -group /glep42 regex ^>.*?$ 0:comment +add-highlighter shared/ group glep42 +add-highlighter shared/glep42 regex ^(Title|Author|Translator|Content-Type|Posted|Revision|News-Item-Format|Display-If-Installed|Display-If-Keyword|Display-If-Profile):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute +add-highlighter shared/glep42 regex <[^@>]+@.*?> 0:string +add-highlighter shared/glep42 regex ^>.*?$ 0:comment -hook -group glep42-highlight global WinSetOption filetype=glep42 %{ add-highlighter ref glep42 } -hook -group glep42-highlight global WinSetOption filetype=(?!glep42).* %{ remove-highlighter glep42 } +hook -group glep42-highlight global WinSetOption filetype=glep42 %{ add-highlighter window ref glep42 } +hook -group glep42-highlight global WinSetOption filetype=(?!glep42).* %{ remove-highlighter window/glep42 } diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index 7b2381ac..ad01b212 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -2,20 +2,20 @@ decl -docstring "name of the client in which documentation is to be displayed" \ str docsclient hook -group git-log-highlight global WinSetOption filetype=git-log %{ - add-highlighter group git-log-highlight - add-highlighter -group git-log-highlight regex '^(commit) ([0-9a-f]+)$' 1:yellow 2:red - add-highlighter -group git-log-highlight regex '^([a-zA-Z_-]+:) (.*?)$' 1:green 2:magenta - add-highlighter -group git-log-highlight ref diff # highlight potential diffs from the -p option + add-highlighter window group git-log-highlight + add-highlighter window/git-log-highlight regex '^(commit) ([0-9a-f]+)$' 1:yellow 2:red + add-highlighter window/git-log-highlight regex '^([a-zA-Z_-]+:) (.*?)$' 1:green 2:magenta + add-highlighter window/git-log-highlight ref diff # highlight potential diffs from the -p option } -hook -group git-log-highlight global WinSetOption filetype=(?!git-log).* %{ remove-highlighter git-log-highlight } +hook -group git-log-highlight global WinSetOption filetype=(?!git-log).* %{ remove-highlighter window/git-log-highlight } hook -group git-status-highlight global WinSetOption filetype=git-status %{ - add-highlighter group git-status-highlight - add-highlighter -group git-status-highlight regex '^\h+(?:((?:both )?modified:)|(added:|new file:)|(deleted(?: by \w+)?:)|(renamed:)|(copied:))(?:.*?)$' 1:yellow 2:green 3:red 4:cyan 5:blue 6:magenta + add-highlighter window group git-status-highlight + add-highlighter window/git-status-highlight 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 -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter git-status-highlight } +hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter window/git-status-highlight } decl -hidden line-specs git_blame_flags decl -hidden line-specs git_diff_flags @@ -56,7 +56,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n run_git_blame() { ( printf %s "eval -client '$kak_client' %{ - try %{ add-highlighter flag_lines GitBlame git_blame_flags } + try %{ add-highlighter window flag_lines GitBlame git_blame_flags } set buffer=$kak_bufname git_blame_flags '$kak_timestamp' }" | kak -p ${kak_session} git blame "$@" --incremental ${kak_buffile} | awk ' @@ -143,11 +143,11 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n hide-blame) printf %s "try %{ set buffer=$kak_bufname git_blame_flags '' - remove-highlighter hlflags_git_blame_flags + remove-highlighter window/hlflags_git_blame_flags }" ;; show-diff) - echo 'try %{ add-highlighter flag_lines GitDiffFlags git_diff_flags }' + echo 'try %{ add-highlighter window flag_lines GitDiffFlags git_diff_flags }' update_diff ;; update-diff) update_diff ;; diff --git a/rc/extra/haml.kak b/rc/extra/haml.kak index 11e525b0..d9806112 100644 --- a/rc/extra/haml.kak +++ b/rc/extra/haml.kak @@ -11,7 +11,7 @@ hook global BufCreate .*[.](haml) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code haml \ +add-highlighter shared/ regions -default code haml \ comment ^\h*/ $ '' \ eval ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) \{ \ eval ^\h*[=-]\K (?' 0:type - addhl -group /pony/code regex '\b(${keywords})\b' 0:keyword - addhl -group /pony/code regex ';' 0:keyword - addhl -group /pony/code regex '^\s*|' 0:keyword - addhl -group /pony/code regex '\b(${struct})\b' 0:variable - addhl -group /pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin + addhl shared/pony/code regex '\b(${values})\b' 0:value + addhl shared/pony/code regex '\b(${meta})\b' 0:meta + addhl shared/pony/code regex '\b(${func_decl})(\s+(${capabilities}))?(\s+\w+)\(' 1:type 3:builtin 4:builtin + addhl shared/pony/code regex '\b(${func_decl})\b' 0:type + addhl shared/pony/code regex '=>' 0:type + addhl shared/pony/code regex '\b(${keywords})\b' 0:keyword + addhl shared/pony/code regex ';' 0:keyword + addhl shared/pony/code regex '^\s*|' 0:keyword + addhl shared/pony/code regex '\b(${struct})\b' 0:variable + addhl shared/pony/code regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin " # Highlight types and attributes printf %s " - addhl -group /pony/code regex '@[\w_]+\b' 0:attribute + addhl shared/pony/code regex '@[\w_]+\b' 0:attribute " } @@ -82,7 +82,7 @@ def -hidden pony-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group pony-highlight global WinSetOption filetype=pony %{ addhl ref pony } +hook -group pony-highlight global WinSetOption filetype=pony %{ addhl window ref pony } hook global WinSetOption filetype=pony %{ hook window InsertChar \n -group pony-indent pony-indent-on-new-line diff --git a/rc/extra/pug.kak b/rc/extra/pug.kak index 6afd8382..fd2778a8 100644 --- a/rc/extra/pug.kak +++ b/rc/extra/pug.kak @@ -15,7 +15,7 @@ hook global BufCreate .*[.](pug|jade) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code pug \ +add-highlighter shared/ regions -default code pug \ text ^\h*\|\s $ '' \ text '^\h*([A-Za-z][A-Za-z0-9_-]*)?(#[A-Za-z][A-Za-z0-9_-]*)?((?:\.[A-Za-z][A-Za-z0-9_-]*)*)?(?' 0:variable -add-highlighter -group /ragel/code regex :=|=>|->|:>|:>>|<: 0:operator -add-highlighter -group /ragel/code regex \b(action|alnum|alpha|any|ascii|case|cntrl|contained|context|data|digit|empty|eof|err|error|exec|export|exports|extend|fblen|fbreak|fbuf|fc|fcall|fcurs|fentry|fexec|fgoto|fhold|first_final|fnext|fpc|fret|from|fstack|ftargs|graph|import|include|init|inwhen|lerr|lower|machine|nocs|noend|noerror|nofinal|noprefix|outwhen|postpop|prepush|print|punct|range|space|start|to|upper|when|write|xdigit|zlen)\b 0:keyword +add-highlighter shared/ragel/code regex \b(true|false)\b 0:value +add-highlighter shared/ragel/code regex '%%\{|\}%%|<\w+>' 0:variable +add-highlighter shared/ragel/code regex :=|=>|->|:>|:>>|<: 0:operator +add-highlighter shared/ragel/code regex \b(action|alnum|alpha|any|ascii|case|cntrl|contained|context|data|digit|empty|eof|err|error|exec|export|exports|extend|fblen|fbreak|fbuf|fc|fcall|fcurs|fentry|fexec|fgoto|fhold|first_final|fnext|fpc|fret|from|fstack|ftargs|graph|import|include|init|inwhen|lerr|lower|machine|nocs|noend|noerror|nofinal|noprefix|outwhen|postpop|prepush|print|punct|range|space|start|to|upper|when|write|xdigit|zlen)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ @@ -58,7 +58,7 @@ def -hidden ragel-indent-on-new-line %< # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group ragel-highlight global WinSetOption filetype=ragel %{ add-highlighter ref ragel } +hook -group ragel-highlight global WinSetOption filetype=ragel %{ add-highlighter window ref ragel } hook global WinSetOption filetype=ragel %{ hook window InsertEnd .* -group ragel-hooks ragel-filter-around-selections @@ -66,7 +66,7 @@ hook global WinSetOption filetype=ragel %{ hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line } -hook -group ragel-highlight global WinSetOption filetype=(?!ragel).* %{ remove-highlighter ragel } +hook -group ragel-highlight global WinSetOption filetype=(?!ragel).* %{ remove-highlighter window/ragel } hook global WinSetOption filetype=(?!ragel).* %{ remove-hooks window ragel-indent diff --git a/rc/extra/sass.kak b/rc/extra/sass.kak index 0910ee68..7c901797 100644 --- a/rc/extra/sass.kak +++ b/rc/extra/sass.kak @@ -11,20 +11,20 @@ hook global BufCreate .*[.](sass) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter -group / regions -default code sass \ +add-highlighter shared/ regions -default code sass \ string '"' (? +Completions highlighter_cmd_completer( + const Context& context, CompletionFlags flags, CommandParameters params, + size_t token_to_complete, ByteCount pos_in_token) { - const bool shared = not arg.empty() and arg[0_byte] == '/'; - if (shared) + if (token_to_complete == 0) { - auto& group = DefinedHighlighters::instance(); - return offset_pos(group.complete_child(arg.substr(1_byte), pos_in_token-1, only_group), 1); + + StringView path = params[0]; + auto sep_it = find(path, '/'); + if (sep_it == path.end()) + return { 0_byte, pos_in_token, complete(path, pos_in_token, highlighter_scopes) }; + + StringView scope{path.begin(), sep_it}; + HighlighterGroup* root = nullptr; + if (scope == "shared") + root = &DefinedHighlighters::instance(); + else if (auto* s = get_scope_ifp(scope, context)) + root = &s->highlighters(); + else + return {}; + + auto offset = scope.length() + 1; + return offset_pos(root->complete_child(StringView{sep_it+1, path.end()}, pos_in_token - offset, add), offset); + } + else if (add and token_to_complete == 1) + { + StringView name = params[1]; + return { 0_byte, name.length(), complete(name, pos_in_token, HighlighterRegistry::instance() | transform(std::mem_fn(&HighlighterRegistry::Item::key))) }; } else - { - auto& group = context.window().highlighters(); - return group.complete_child(arg, pos_in_token, only_group); - } -} - -Completions remove_highlighter_completer( - const Context& context, CompletionFlags flags, CommandParameters params, - size_t token_to_complete, ByteCount pos_in_token) -{ - const String& arg = params[token_to_complete]; - if (token_to_complete == 0 and not arg.empty() and arg.front() == '/') - { - auto& group = DefinedHighlighters::instance(); - return offset_pos(group.complete_child(arg.substr(1_byte), pos_in_token-1, false), 1); - } - else if (token_to_complete == 0) - return context.window().highlighters().complete_child(arg, pos_in_token, false); - return {}; -} - -Completions add_highlighter_completer( - const Context& context, CompletionFlags flags, CommandParameters params, - size_t token_to_complete, ByteCount pos_in_token) -{ - StringView arg = params[token_to_complete]; - if (token_to_complete == 1 and params[0] == "-group") - return complete_highlighter(context, params[1], pos_in_token, true); - else if (token_to_complete == 0 or (token_to_complete == 2 and params[0] == "-group")) - return { 0_byte, arg.length(), complete(arg, pos_in_token, HighlighterRegistry::instance() | transform(std::mem_fn(&HighlighterRegistry::Item::key))) }; - return Completions{}; + return {}; } Highlighter& get_highlighter(const Context& context, StringView path) { - if (path.empty()) - throw runtime_error("group path should not be empty"); - - Highlighter* root = nullptr; - if (path[0_byte] == '/') - { - root = &DefinedHighlighters::instance(); - path = path.substr(1_byte); - } - else - root = &context.window().highlighters(); - - if (path.back() == '/') + if (not path.empty() and path.back() == '/') path = path.substr(0_byte, path.length() - 1); - if (not path.empty()) - return root->get_child(path); + auto sep_it = find(path, '/'); + StringView scope{path.begin(), sep_it}; + auto* root = (scope == "shared") ? (HighlighterGroup*)&DefinedHighlighters::instance() + : (HighlighterGroup*)&get_scope(scope, context).highlighters(); + if (sep_it != path.end()) + return root->get_child(StringView{sep_it+1, path.end()}); return *root; } const CommandDesc add_highlighter_cmd = { "add-highlighter", "addhl", - "add-highlighter ...: add an highlighter", - ParameterDesc{ - { { "group", { true, "Set the group in which to put the highlighter. " - "If starting with /, search in shared highlighters, " - "else search in the current window" } } }, - ParameterDesc::Flags::SwitchesOnlyAtStart, 1 - }, + "add-highlighter ...: add an highlighter to the group identified by \n" + " is a '/' delimited path of highlighters, starting with either\n" + " 'global', 'buffer', 'window' or 'shared'", + ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, 2 }, CommandFlags::None, [](const Context& context, CommandParameters params) -> String { - if (params.size() > 0) + if (params.size() > 1) { HighlighterRegistry& registry = HighlighterRegistry::instance(); - auto it = registry.find(params[0]); + auto it = registry.find(params[1]); if (it != registry.end()) - return format("{}:\n{}", params[0], indent(it->value.docstring)); + return format("{}:\n{}", params[1], indent(it->value.docstring)); } return ""; }, - add_highlighter_completer, + highlighter_cmd_completer, [](const ParametersParser& parser, Context& context, const ShellContext&) { HighlighterRegistry& registry = HighlighterRegistry::instance(); auto begin = parser.begin(); - const String& name = *begin++; + StringView path = *begin++; + StringView name = *begin++; Vector highlighter_params; for (; begin != parser.end(); ++begin) highlighter_params.push_back(*begin); - auto group_name = parser.get_switch("group"); - auto& group = group_name ? get_highlighter(context, *group_name) - : context.window().highlighters(); auto it = registry.find(name); if (it == registry.end()) throw runtime_error(format("No such highlighter factory '{}'", name)); - group.add_child(it->value.factory(highlighter_params)); + get_highlighter(context, path).add_child(it->value.factory(highlighter_params)); + // TODO: better, this will fail if we touch scopes highlighters that impact multiple windows if (context.has_window()) context.window().force_redraw(); } @@ -747,20 +728,19 @@ const CommandDesc add_highlighter_cmd = { const CommandDesc remove_highlighter_cmd = { "remove-highlighter", "rmhl", - "remove-highlighter : remove highlighter ", - single_param, + "remove-highlighter : remove highlighter identified by ", + { {}, ParameterDesc::Flags::None, 1, 1 }, CommandFlags::None, CommandHelper{}, - remove_highlighter_completer, + highlighter_cmd_completer, [](const ParametersParser& parser, Context& context, const ShellContext&) { StringView path = parser[0]; - auto sep_it = find(path | reverse(), '/'); - auto& group = sep_it != path.rend() ? - get_highlighter(context, {path.begin(), sep_it.base()}) - : context.window().highlighters(); - - group.remove_child({sep_it.base(), path.end()}); + auto rev_path = path | reverse(); + auto sep_it = find(rev_path, '/'); + if (sep_it == rev_path.end()) + return; + get_highlighter(context, {path.begin(), sep_it.base()}).remove_child({sep_it.base(), path.end()}); if (context.has_window()) context.window().force_redraw(); diff --git a/src/highlighter_group.cc b/src/highlighter_group.cc index 33723d66..39130159 100644 --- a/src/highlighter_group.cc +++ b/src/highlighter_group.cc @@ -69,4 +69,19 @@ Completions HighlighterGroup::complete_child(StringView path, ByteCount cursor_p return { 0, 0, std::move(candidates) }; } +void Highlighters::do_highlight(const Context& context, HighlightPass pass, + DisplayBuffer& display_buffer, BufferRange range) +{ + if (m_parent) + m_parent->do_highlight(context, pass, display_buffer, range); + HighlighterGroup::do_highlight(context, pass, display_buffer, range); +} + +void Highlighters::do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) +{ + if (m_parent) + m_parent->do_compute_display_setup(context, pass, setup); + HighlighterGroup::do_compute_display_setup(context, pass, setup); +} + } diff --git a/src/highlighter_group.hh b/src/highlighter_group.hh index 12fc07d3..95a88a6b 100644 --- a/src/highlighter_group.hh +++ b/src/highlighter_group.hh @@ -5,6 +5,7 @@ #include "hash_map.hh" #include "highlighter.hh" #include "utils.hh" +#include "safe_ptr.hh" namespace Kakoune { @@ -27,7 +28,7 @@ public: Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const override; -private: +protected: void do_highlight(const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range) override; void do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) override; @@ -35,6 +36,21 @@ private: HighlighterMap m_highlighters; }; +class Highlighters : public HighlighterGroup, public SafeCountable +{ +public: + Highlighters(Highlighters& parent) : HighlighterGroup{HighlightPass::All}, SafeCountable{}, m_parent(&parent) {} + +private: + void do_highlight(const Context& context, HighlightPass pass, DisplayBuffer& display_buffer, BufferRange range) override; + void do_compute_display_setup(const Context& context, HighlightPass pass, DisplaySetup& setup) override; + + friend class Scope; + Highlighters() : HighlighterGroup{HighlightPass::All} {} + + SafePtr m_parent; +}; + struct DefinedHighlighters : public HighlighterGroup, public Singleton { diff --git a/src/scope.hh b/src/scope.hh index a27d5fce..58cc9477 100644 --- a/src/scope.hh +++ b/src/scope.hh @@ -5,6 +5,7 @@ #include "hook_manager.hh" #include "keymap_manager.hh" #include "option_manager.hh" +#include "highlighter_group.hh" #include "utils.hh" namespace Kakoune @@ -17,16 +18,19 @@ public: : m_options(parent.options()), m_hooks(parent.hooks()), m_keymaps(parent.keymaps()), - m_aliases(parent.aliases()) {} + m_aliases(parent.aliases()), + m_highlighters(parent.highlighters()) {} - OptionManager& options() { return m_options; } - const OptionManager& options() const { return m_options; } - HookManager& hooks() { return m_hooks; } - const HookManager& hooks() const { return m_hooks; } - KeymapManager& keymaps() { return m_keymaps; } - const KeymapManager& keymaps() const { return m_keymaps; } - AliasRegistry& aliases() { return m_aliases; } - const AliasRegistry& aliases() const { return m_aliases; } + OptionManager& options() { return m_options; } + const OptionManager& options() const { return m_options; } + HookManager& hooks() { return m_hooks; } + const HookManager& hooks() const { return m_hooks; } + KeymapManager& keymaps() { return m_keymaps; } + const KeymapManager& keymaps() const { return m_keymaps; } + AliasRegistry& aliases() { return m_aliases; } + const AliasRegistry& aliases() const { return m_aliases; } + Highlighters& highlighters() { return m_highlighters; } + const Highlighters& highlighters() const { return m_highlighters; } private: friend class GlobalScope; @@ -36,6 +40,7 @@ private: HookManager m_hooks; KeymapManager m_keymaps; AliasRegistry m_aliases; + Highlighters m_highlighters; }; class GlobalScope : public Scope, public Singleton diff --git a/src/window.cc b/src/window.cc index 09652a9b..e1bd3ee5 100644 --- a/src/window.cc +++ b/src/window.cc @@ -22,8 +22,7 @@ void setup_builtin_highlighters(HighlighterGroup& group); Window::Window(Buffer& buffer) : Scope(buffer), m_buffer(&buffer), - m_highlighters{HighlightPass::All}, - m_builtin_highlighters{HighlightPass::All} + m_builtin_highlighters{highlighters()} { run_hook_in_own_context("WinCreate", buffer.name()); @@ -144,10 +143,7 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) m_display_buffer.compute_range(); BufferRange range{{0,0}, buffer().end_coord()}; for (auto pass : { HighlightPass::Wrap, HighlightPass::Move, HighlightPass::Colorize }) - { - m_highlighters.highlight(context, pass, m_display_buffer, range); m_builtin_highlighters.highlight(context, pass, m_display_buffer, range); - } m_display_buffer.optimize(); @@ -203,8 +199,6 @@ DisplaySetup Window::compute_display_setup(const Context& context) offset, false }; - for (auto pass : { HighlightPass::Move, HighlightPass::Wrap }) - m_highlighters.compute_display_setup(context, pass, setup); for (auto pass : { HighlightPass::Move, HighlightPass::Wrap }) m_builtin_highlighters.compute_display_setup(context, pass, setup); diff --git a/src/window.hh b/src/window.hh index 6aeaa0c0..28971bcb 100644 --- a/src/window.hh +++ b/src/window.hh @@ -40,8 +40,6 @@ public: Optional display_position(BufferCoord coord) const; BufferCoord buffer_coord(DisplayCoord coord) const; - Highlighter& highlighters() { return m_highlighters; } - Buffer& buffer() const { return *m_buffer; } bool needs_redraw(const Context& context) const; @@ -67,8 +65,7 @@ private: DisplayCoord m_dimensions; DisplayBuffer m_display_buffer; - HighlighterGroup m_highlighters; - HighlighterGroup m_builtin_highlighters; + Highlighters m_builtin_highlighters; struct Setup { diff --git a/test/highlight/column/multi-columns/rc b/test/highlight/column/multi-columns/rc index 01eb14f6..79ac5c4b 100644 --- a/test/highlight/column/multi-columns/rc +++ b/test/highlight/column/multi-columns/rc @@ -1,5 +1,5 @@ -add-highlighter number_lines +add-highlighter window number_lines set window tabstop 4 -add-highlighter column 3 default,red -add-highlighter column 7 default,green -add-highlighter column 5 default,blue +add-highlighter window column 3 default,red +add-highlighter window column 7 default,green +add-highlighter window column 5 default,blue diff --git a/test/highlight/regions/rc b/test/highlight/regions/rc index b8c41521..580a5ae1 100644 --- a/test/highlight/regions/rc +++ b/test/highlight/regions/rc @@ -1,7 +1,7 @@ -add-highlighter regions -default code regions_test \ +add-highlighter window regions -default code regions_test \ string %{"} %{(?i:addhl column 1 redA +:addhl window show_whitespacesi:addhl window column 1 redA diff --git a/test/regression/1382-column-highlighter-broken-on-horizontal-scroll/rc b/test/regression/1382-column-highlighter-broken-on-horizontal-scroll/rc index 2a51f4a2..6e50cc1c 100644 --- a/test/regression/1382-column-highlighter-broken-on-horizontal-scroll/rc +++ b/test/regression/1382-column-highlighter-broken-on-horizontal-scroll/rc @@ -1 +1 @@ -add-highlighter column 20 default,blue +add-highlighter window column 20 default,blue diff --git a/test/regression/1433-scrolloff-broken-with-soft-wrap/rc b/test/regression/1433-scrolloff-broken-with-soft-wrap/rc index 09fa1857..f241e60c 100644 --- a/test/regression/1433-scrolloff-broken-with-soft-wrap/rc +++ b/test/regression/1433-scrolloff-broken-with-soft-wrap/rc @@ -1,2 +1,2 @@ -add-highlighter wrap +add-highlighter window wrap set global scrolloff 1,0 diff --git a/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc b/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc index a0c5ad74..c70ba1f7 100644 --- a/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc +++ b/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc @@ -1 +1 @@ -add-highlighter show_whitespaces +add-highlighter window show_whitespaces diff --git a/test/regression/1453-show_whitespaces-highlighter-breaks-tab-alignment/rc b/test/regression/1453-show_whitespaces-highlighter-breaks-tab-alignment/rc index a0c5ad74..c70ba1f7 100644 --- a/test/regression/1453-show_whitespaces-highlighter-breaks-tab-alignment/rc +++ b/test/regression/1453-show_whitespaces-highlighter-breaks-tab-alignment/rc @@ -1 +1 @@ -add-highlighter show_whitespaces +add-highlighter window show_whitespaces diff --git a/test/regression/1459-assertion-on-wrapped-long-line/rc b/test/regression/1459-assertion-on-wrapped-long-line/rc index 030fe170..373ec148 100644 --- a/test/regression/1459-assertion-on-wrapped-long-line/rc +++ b/test/regression/1459-assertion-on-wrapped-long-line/rc @@ -1 +1 @@ -add-highlighter wrap +add-highlighter window wrap diff --git a/test/regression/638-highlight-codepoint-with-bracket/rc b/test/regression/638-highlight-codepoint-with-bracket/rc index 2be17895..470a44e1 100644 --- a/test/regression/638-highlight-codepoint-with-bracket/rc +++ b/test/regression/638-highlight-codepoint-with-bracket/rc @@ -1 +1 @@ -add-highlighter regex '[“”]' 0:red +add-highlighter window regex '[“”]' 0:red