From e486a97ad8fb07d6d19e9db9e4a7184f168ec3c4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 28 Jun 2018 21:08:58 +1000 Subject: [PATCH] Fix highlighters in rc/core post syntax refactoring --- rc/core/asciidoc.kak | 34 +++++++++++------------ rc/core/c-family.kak | 24 ++++++++-------- rc/core/diff.kak | 8 +++--- rc/core/doc.kak | 6 ++-- rc/core/grep.kak | 6 ++-- rc/core/make.kak | 10 +++---- rc/core/makefile.kak | 15 +++++----- rc/core/python.kak | 65 ++++++++++++++++++++------------------------ rc/core/sh.kak | 2 +- 9 files changed, 81 insertions(+), 89 deletions(-) diff --git a/rc/core/asciidoc.kak b/rc/core/asciidoc.kak index adb79f56..ffc7471c 100644 --- a/rc/core/asciidoc.kak +++ b/rc/core/asciidoc.kak @@ -11,25 +11,25 @@ hook global BufCreate .+\.(a(scii)?doc|asc) %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter shared/ group asciidoc +add-highlighter shared/asciidoc group -add-highlighter shared/asciidoc regex (\A|\n\n)[^\n]+\n={2,}\h*$ 0:title -add-highlighter shared/asciidoc regex (\A|\n\n)[^\n]+\n-{2,}\h*$ 0:header -add-highlighter shared/asciidoc regex (\A|\n\n)[^\n]+\n~{2,}\h*$ 0:header -add-highlighter shared/asciidoc regex (\A|\n\n)[^\n]+\n\^{2,}\h*$ 0:header +add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n={2,}\h*$ 0:title +add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n-{2,}\h*$ 0:header +add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n~{2,}\h*$ 0:header +add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n\^{2,}\h*$ 0:header -add-highlighter shared/asciidoc regex (\A|\n\n)=\h+[^\n]+$ 0:title -add-highlighter shared/asciidoc regex (\A|\n\n)={2,}\h+[^\n]+$ 0:header +add-highlighter shared/asciidoc/ regex (\A|\n\n)=\h+[^\n]+$ 0:title +add-highlighter shared/asciidoc/ regex (\A|\n\n)={2,}\h+[^\n]+$ 0:header -add-highlighter shared/asciidoc regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:list 1:bullet -add-highlighter shared/asciidoc regex ^(-{3,})\n[^\n\h].*?\n(-{3,})$ 0:block -add-highlighter shared/asciidoc regex ^(={3,})\n[^\n\h].*?\n(={3,})$ 0:block -add-highlighter shared/asciidoc regex ^(~{3,})\n[^\n\h].*?\n(~{3,})$ 0:block -add-highlighter shared/asciidoc regex ^(\*{3,})\n[^\n\h].*?\n(\*{3,})$ 0:block -add-highlighter shared/asciidoc regex \B(?:\+[^\n]+?\+|`[^\n]+?`)\B 0:mono -add-highlighter shared/asciidoc regex \b_[^\n]+?_\b 0:italic -add-highlighter shared/asciidoc regex \B\*[^\n]+?\*\B 0:bold -add-highlighter shared/asciidoc regex ^:[-\w]+: 0:meta +add-highlighter shared/asciidoc/ regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:list 1:bullet +add-highlighter shared/asciidoc/ regex ^(-{3,})\n[^\n\h].*?\n(-{3,})$ 0:block +add-highlighter shared/asciidoc/ regex ^(={3,})\n[^\n\h].*?\n(={3,})$ 0:block +add-highlighter shared/asciidoc/ regex ^(~{3,})\n[^\n\h].*?\n(~{3,})$ 0:block +add-highlighter shared/asciidoc/ regex ^(\*{3,})\n[^\n\h].*?\n(\*{3,})$ 0:block +add-highlighter shared/asciidoc/ regex \B(?:\+[^\n]+?\+|`[^\n]+?`)\B 0:mono +add-highlighter shared/asciidoc/ regex \b_[^\n]+?_\b 0:italic +add-highlighter shared/asciidoc/ regex \B\*[^\n]+?\*\B 0:bold +add-highlighter shared/asciidoc/ regex ^:[-\w]+: 0:meta # Commands # ‾‾‾‾‾‾‾‾ @@ -37,5 +37,5 @@ add-highlighter shared/asciidoc regex ^:[-\w]+: 0:meta # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # -hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ add-highlighter window ref asciidoc } +hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ add-highlighter window/asciidoc ref asciidoc } hook -group asciidoc-highlight global WinSetOption filetype=(?!asciidoc).* %{ remove-highlighter window/asciidoc } diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index 242d1cc9..b2edeb5d 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -145,8 +145,8 @@ evaluate-commands %sh{ add-highlighter shared/FT/disabled region ^\h*?#\h*if\h+(?:0|FALSE)\b "#\h*(?:else|elif|endif)" "#\h*if(?:def)?" fill rgb:666666 add-highlighter shared/FT/macro region %{^\h*?\K#} %{(? d } set-option buffer readonly true - add-highlighter buffer ranges doc_render_ranges - add-highlighter buffer ranges doc_render_links - add-highlighter buffer wrap -word -indent + add-highlighter buffer/ ranges doc_render_ranges + add-highlighter buffer/ ranges doc_render_links + add-highlighter buffer/ wrap -word -indent map buffer normal :doc-follow-link } diff --git a/rc/core/grep.kak b/rc/core/grep.kak index c634abee..644d2e7e 100644 --- a/rc/core/grep.kak +++ b/rc/core/grep.kak @@ -28,9 +28,9 @@ All the optional arguments are forwarded to the grep utility} \ }} hook -group grep-highlight global WinSetOption filetype=grep %{ - add-highlighter window group grep - add-highlighter window/grep regex "^((?:\w:)?[^:\n]+):(\d+):(\d+)?" 1:cyan 2:green 3:green - add-highlighter window/grep line %{%opt{grep_current_line}} default+b + add-highlighter window/grep group + add-highlighter window/grep/ regex "^((?:\w:)?[^:\n]+):(\d+):(\d+)?" 1:cyan 2:green 3:green + add-highlighter window/grep/ line %{%opt{grep_current_line}} default+b } hook global WinSetOption filetype=grep %{ diff --git a/rc/core/make.kak b/rc/core/make.kak index e171300e..e5037675 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -26,12 +26,12 @@ All the optional arguments are forwarded to the make utility} \ }" }} -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 +add-highlighter shared/make group +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 window ref make } +hook -group make-highlight global WinSetOption filetype=make %{ add-highlighter window/make ref make } hook global WinSetOption filetype=make %{ hook buffer -group make-hooks NormalKey make-jump diff --git a/rc/core/makefile.kak b/rc/core/makefile.kak index 0a4a802f..fe8a4267 100644 --- a/rc/core/makefile.kak +++ b/rc/core/makefile.kak @@ -8,15 +8,14 @@ hook global BufCreate .*/?[mM]akefile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter shared/ regions -default content makefile \ - comment '#' '$' '' \ - evaluate-commands '\$\(' '\)' '\(' +add-highlighter shared/makefile regions -add-highlighter shared/makefile/comment fill comment -add-highlighter shared/makefile/evaluate-commands fill value +add-highlighter shared/makefile/content default-region group +add-highlighter shared/makefile/comment region '#' '$' '' fill comment +add-highlighter shared/makefile/evaluate-commands region '\$\(' '\)' '\(' fill value -add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable -add-highlighter shared/makefile/content regex [+?:]= 0:operator +add-highlighter shared/makefile/content/ regex ^[\w.%-]+\h*:\s 0:variable +add-highlighter shared/makefile/content/ regex [+?:]= 0:operator evaluate-commands %sh{ # Grammar @@ -50,7 +49,7 @@ define-command -hidden makefile-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window ref makefile } +hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window/makefile ref makefile } hook global WinSetOption filetype=makefile %{ hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line diff --git a/rc/core/python.kak b/rc/core/python.kak index 9551ba85..1dbf7c69 100644 --- a/rc/core/python.kak +++ b/rc/core/python.kak @@ -11,35 +11,28 @@ hook global BufCreate .*[.](py) %{ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter shared/ regions -default code python \ - docstring '"""' '"""' '' \ - docstring "'''" "'''" '' \ - double_string '"' (?>> \K' '\z' '' \ - python '\.\.\. \K' '\z' '' -add-highlighter shared/python/docstring/py-docstring/python ref python -add-highlighter shared/python/docstring/py-docstring/docstring fill string - -add-highlighter shared/python/comment fill comment +add-highlighter shared/python/docstring/ default-region fill string +add-highlighter shared/python/docstring/ region '>>> \K' '\z' '' ref python +add-highlighter shared/python/docstring/ region '\.\.\. \K' '\z' '' ref python evaluate-commands %sh{ # Grammar @@ -108,20 +101,20 @@ evaluate-commands %sh{ # Highlight keywords printf %s " - add-highlighter shared/python/code regex '\b(${values})\b' 0:value - add-highlighter shared/python/code regex '\b(${meta})\b' 0:meta - add-highlighter shared/python/code regex '\b(${attribute})\b' 0:attribute - add-highlighter shared/python/code regex '\bdef\s+(${methods})\b' 1:function - add-highlighter shared/python/code regex '\b(${exceptions})\b' 0:function - add-highlighter shared/python/code regex '\b(${keywords})\b' 0:keyword - add-highlighter shared/python/code regex '\b(${functions})\b\(' 1:builtin - add-highlighter shared/python/code regex '\b(${types})\b' 0:type - add-highlighter shared/python/code regex '@[\w_]+\b' 0:attribute + add-highlighter shared/python/code/ regex '\b(${values})\b' 0:value + add-highlighter shared/python/code/ regex '\b(${meta})\b' 0:meta + add-highlighter shared/python/code/ regex '\b(${attribute})\b' 0:attribute + add-highlighter shared/python/code/ regex '\bdef\s+(${methods})\b' 1:function + add-highlighter shared/python/code/ regex '\b(${exceptions})\b' 0:function + add-highlighter shared/python/code/ regex '\b(${keywords})\b' 0:keyword + add-highlighter shared/python/code/ regex '\b(${functions})\b\(' 1:builtin + add-highlighter shared/python/code/ regex '\b(${types})\b' 0:type + add-highlighter shared/python/code/ regex '@[\w_]+\b' 0:attribute " } -add-highlighter shared/python/code regex (?<=[\w\s\d'"_])(<=|<<|>>|>=|<>|<|>|!=|==|\||\^|&|\+|-|\*\*|\*|//|/|%|~) 0:operator -add-highlighter shared/python/code regex (?<=[\w\s\d'"_])((?!])=(?![=])|[+*-]=) 0:builtin +add-highlighter shared/python/code/ regex (?<=[\w\s\d'"_])(<=|<<|>>|>=|<>|<|>|!=|==|\||\^|&|\+|-|\*\*|\*|//|/|%|~) 0:operator +add-highlighter shared/python/code/ regex (?<=[\w\s\d'"_])((?!])=(?![=])|[+*-]=) 0:builtin # Commands # ‾‾‾‾‾‾‾‾ @@ -142,7 +135,7 @@ define-command -hidden python-indent-on-new-line %{ # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter window ref python } +hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter window/python ref python } hook global WinSetOption filetype=python %{ hook window InsertChar \n -group python-indent python-indent-on-new-line diff --git a/rc/core/sh.kak b/rc/core/sh.kak index e2c836af..8bba36eb 100644 --- a/rc/core/sh.kak +++ b/rc/core/sh.kak @@ -27,7 +27,7 @@ evaluate-commands %sh{ }" # Highlight keywords - printf %s "add-highlighter shared/sh/code/keywords regex \b($(join ${keywords} '|'))\b 0:keyword" + printf %s "add-highlighter shared/sh/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword" } add-highlighter shared/sh/code/operators regex [\[\]\(\)&|]{1,2} 0:operator