Fix highlighters in rc/core post syntax refactoring

This commit is contained in:
Maxime Coste 2018-06-28 21:08:58 +10:00
parent 7976f8289e
commit e486a97ad8
9 changed files with 81 additions and 89 deletions

View File

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

View File

@ -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#} %{(?<!\\)\n} "" group
add-highlighter shared/FT/macro/fill fill meta
add-highlighter shared/FT/macro/include regex ^\h*#include\h+(\S*) 1:module
add-highlighter shared/FT/macro/ fill meta
add-highlighter shared/FT/macro/ regex ^\h*#include\h+(\S*) 1:module
' | sed -e "s/FT/${ft}/g; s/QUOTE/'/g; s/MAYBEAT/${maybe_at}/;"
done
}
@ -181,18 +181,18 @@ evaluate-commands %sh{
# c++ specific
# integer literals
add-highlighter shared/cpp/code/integer1 regex %{(?i)(?<!\.)\b[1-9]('?\d+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/integer2 regex %{(?i)(?<!\.)\b0b[01]('?[01]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/integer3 regex %{(?i)(?<!\.)\b0('?[0-7]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/integer4 regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b[1-9]('?\d+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0b[01]('?[01]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0('?[0-7]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*(ul?l?|ll?u?)?\b(?!\.)} 0:value
# floating point literals
add-highlighter shared/cpp/code/float1 regex %{(?i)(?<!\.)\b\d('?\d+)*\.([fl]\b|\B)(?!\.)} 0:value
add-highlighter shared/cpp/code/float2 regex %{(?i)(?<!\.)\b\d('?\d+)*\.?e[+-]?\d('?\d+)*[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/float3 regex %{(?i)(?<!\.)(\b(\d('?\d+)*)|\B)\.\d('?[\d]+)*(e[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/float4 regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*\.([fl]\b|\B)(?!\.)} 0:value
add-highlighter shared/cpp/code/float5 regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*\.?p[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/float6 regex %{(?i)(?<!\.)\b0x([\da-f]('?[\da-f]+)*)?\.\d('?[\d]+)*(p[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b\d('?\d+)*\.([fl]\b|\B)(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b\d('?\d+)*\.?e[+-]?\d('?\d+)*[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)(\b(\d('?\d+)*)|\B)\.\d('?[\d]+)*(e[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*\.([fl]\b|\B)(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0x[\da-f]('?[\da-f]+)*\.?p[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
add-highlighter shared/cpp/code/ regex %{(?i)(?<!\.)\b0x([\da-f]('?[\da-f]+)*)?\.\d('?[\d]+)*(p[+-]?\d('?\d+)*)?[fl]?\b(?!\.)} 0:value
# character literals (no multi-character literals)
add-highlighter shared/cpp/code/char regex %{(\b(u8|u|U|L)|\B)'((\\.)|[^'\\])'\B} 0:value

View File

@ -2,10 +2,10 @@ hook global BufCreate .*\.(diff|patch) %{
set-option buffer filetype diff
}
add-highlighter shared/ group diff
add-highlighter shared/diff regex "^\+[^\n]*\n" 0:green,default
add-highlighter shared/diff regex "^-[^\n]*\n" 0:red,default
add-highlighter shared/diff regex "^@@[^\n]*@@" 0:cyan,default
add-highlighter shared/diff group
add-highlighter shared/diff/ regex "^\+[^\n]*\n" 0:green,default
add-highlighter shared/diff/ regex "^-[^\n]*\n" 0:red,default
add-highlighter shared/diff/ regex "^@@[^\n]*@@" 0:cyan,default
hook -group diff-highlight global WinSetOption filetype=diff %{ add-highlighter window ref diff }
hook -group diff-highlight global WinSetOption filetype=(?!diff).* %{ remove-highlighter window/diff }

View File

@ -122,9 +122,9 @@ define-command -params 1 -hidden doc-render %{
try %{ execute-keys -draft \%s \\((?=\*)|(?=`)) <ret> 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 <ret> :doc-follow-link<ret>
}

View File

@ -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 %{

View File

@ -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 <ret> make-jump

View File

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

View File

@ -11,35 +11,28 @@ hook global BufCreate .*[.](py) %{
# Highlighters & Completion
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/ regions -default code python \
docstring '"""' '"""' '' \
docstring "'''" "'''" '' \
double_string '"' (?<!\\)(\\\\)*" '' \
single_string "'" (?<!\\)(\\\\)*' '' \
comment '#' '$' ''
add-highlighter shared/python regions
add-highlighter shared/python/code default-region group
add-highlighter shared/python/docstring region -match-capture ("""|''') ("""|''') '' regions
add-highlighter shared/python/double_string region '"' (?<!\\)(\\\\)*" '' fill string
add-highlighter shared/python/single_string region "'" (?<!\\)(\\\\)*' '' fill string
add-highlighter shared/python/comment region '#' '$' '' fill comment
# Integer formats
add-highlighter shared/python/code regex '(?i)\b0b[01]+l?\b' 0:value
add-highlighter shared/python/code regex '(?i)\b0x[\da-f]+l?\b' 0:value
add-highlighter shared/python/code regex '(?i)\b0o?[0-7]+l?\b' 0:value
add-highlighter shared/python/code regex '(?i)\b([1-9]\d*|0)l?\b' 0:value
add-highlighter shared/python/code/ regex '(?i)\b0b[01]+l?\b' 0:value
add-highlighter shared/python/code/ regex '(?i)\b0x[\da-f]+l?\b' 0:value
add-highlighter shared/python/code/ regex '(?i)\b0o?[0-7]+l?\b' 0:value
add-highlighter shared/python/code/ regex '(?i)\b([1-9]\d*|0)l?\b' 0:value
# Float formats
add-highlighter shared/python/code regex '\b\d+[eE][+-]?\d+\b' 0:value
add-highlighter shared/python/code regex '(\b\d+)?\.\d+\b' 0:value
add-highlighter shared/python/code regex '\b\d+\.' 0:value
add-highlighter shared/python/code/ regex '\b\d+[eE][+-]?\d+\b' 0:value
add-highlighter shared/python/code/ regex '(\b\d+)?\.\d+\b' 0:value
add-highlighter shared/python/code/ regex '\b\d+\.' 0:value
# Imaginary formats
add-highlighter shared/python/code regex '\b\d+\+\d+[jJ]\b' 0:value
add-highlighter shared/python/code/ regex '\b\d+\+\d+[jJ]\b' 0:value
add-highlighter shared/python/double_string fill string
add-highlighter shared/python/single_string fill string
add-highlighter shared/python/docstring/ regions -default docstring py-docstring \
python '>>> \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

View File

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