rc/: Tweak some regexes to be compatible with our impl limitations

The upcoming custom implementation does not support arbitrary lookarounds,
and other advanced regex features. Simplify the regexes to avoid those.
This commit is contained in:
Maxime Coste 2017-10-02 20:59:22 +08:00
parent bf6e5daa08
commit 0fa59e5fd2
12 changed files with 27 additions and 27 deletions

View File

@ -40,13 +40,13 @@ add-highlighter -group /haskell/code regex (?<!['\w])(case|do|else|if|in|let|mdo
# matches uppercase identifiers: Monad Control.Monad
# not non-space separated dot: Just.const
add-highlighter -group /haskell/code regex \b(\u['\w]*\.)*\u['\w]*(?!['\w])(?![.\l]) 0:variable
add-highlighter -group /haskell/code regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.\l]) 0:variable
# matches infix identifier: `mod` `Apa._T'M`
add-highlighter -group /haskell/code regex `\b(\u['\w]*\.)*[\w]['\w]*` 0:operator
add-highlighter -group /haskell/code regex `\b([A-Z]['\w]*\.)*[\w]['\w]*` 0:operator
# matches imported operators: M.! M.. Control.Monad.>>
# not operator keywords: M... M.->
add-highlighter -group /haskell/code regex \b\u['\w]*\.(?!([~=|:@\\]|<-|->|=>|\.\.|::)[^~<=>|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator
add-highlighter -group /haskell/code regex \b[A-Z]['\w]*\.(?!([~=|:@\\]|<-|->|=>|\.\.|::)[^~<=>|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator
# matches dot: .
# not possibly incomplete import: a.
# not other operators: !. .!

View File

@ -73,9 +73,9 @@ hook global WinSetOption filetype=(?:html|xml) %{
hook window InsertChar \n -group html-indent html-indent-on-new-line
}
hook -group html-highlight global WinSetOption filetype=(?!html|xml).* %{ remove-highlighter html }
hook -group html-highlight global WinSetOption filetype=(?!html)(?!xml).* %{ remove-highlighter html }
hook global WinSetOption filetype=(?!html|xml).* %{
hook global WinSetOption filetype=(?!html)(?!xml).* %{
remove-hooks window html-indent
remove-hooks window html-hooks
}

View File

@ -19,7 +19,7 @@ add-highlighter -group /lisp/string fill string
add-highlighter -group /lisp/comment fill comment
add-highlighter -group /lisp/code regex \b(nil|true|false)\b 0:value
add-highlighter -group /lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=|) 0:operator
add-highlighter -group /lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=) 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

View File

@ -110,7 +110,7 @@ add-highlighter -group /markdown/content regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0
# Atx-style header
add-highlighter -group /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 ^\h?((?:[\s\t]+)?[-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*\n)*$ 0:list 1:bullet
add-highlighter -group /markdown/content regex ^([-=~]+)\n[^\n\h].*?\n\1$ 0:block
add-highlighter -group /markdown/content regex \B\+[^\n]+?\+\B 0:mono
add-highlighter -group /markdown/content regex \B\*[^\n]+?\*\B 0:italic

View File

@ -12,10 +12,10 @@ hook global BufCreate .*\.p[lm] %{
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter -group / regions -default code perl \
command '(?<!\$|\\)`' (?<!\\)(\\\\)*` '' \
double_string '(?<!\$|\\)"' (?<!\\)(\\\\)*" '' \
single_string "(?<!\\$|\\\\)'" (?<!\\)(\\\\)*' '' \
comment '(?<!\$|\\)#' $ ''
command '(?<!\$)(?<!\\)`' (?<!\\)(\\\\)*` '' \
double_string '(?<!\$)(?<!\\)"' (?<!\\)(\\\\)*" '' \
single_string "(?<!\\$)(?<!\\\\)'" (?<!\\)(\\\\)*' '' \
comment '(?<!\$)(?<!\\)#' $ ''
add-highlighter -group /perl/command fill magenta
add-highlighter -group /perl/double_string fill string

View File

@ -45,7 +45,7 @@ add-highlighter -group /ruby/comment fill comment
add-highlighter -group /ruby/literal fill meta
add-highlighter -group /ruby/code regex \b([A-Za-z]\w*:(?=[^:]))|([$@][A-Za-z]\w*)|((?<=[^:]):(([A-Za-z]\w*[=?!]?)|(\[\]=?)))|([A-Z]\w*|^|\h)\K::(?=[A-Z]) 0:variable
add-highlighter -group /ruby/code regex \b([A-Za-z]\w*:(?!:))|([$@][A-Za-z]\w*)|((?<!:):(([A-Za-z]\w*[=?!]?)|(\[\]=?)))|([A-Z]\w*|^|\h)\K::(?=[A-Z]) 0:variable
%sh{
# Grammar

View File

@ -19,9 +19,9 @@ add-highlighter -group /asciidoc regex (\A|\n\n)[^\n]+\n~{2,}\h*$ 0:header
add-highlighter -group /asciidoc regex (\A|\n\n)[^\n]+\n\^{2,}\h*$ 0:header
add-highlighter -group /asciidoc regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:list 1:bullet
add-highlighter -group /asciidoc regex ^([-=~]+)\n[^\n\h].*?\n\1$ 0:block
add-highlighter -group /asciidoc regex (?<!\w)(?:\+[^\n]+?\+|`[^\n]+?`)(?!\w) 0:mono
add-highlighter -group /asciidoc regex (?<!\w)_[^\n]+?_(?!\w) 0:italic
add-highlighter -group /asciidoc regex (?<!\w)\*[^\n]+?\*(?!\w) 0:bold
add-highlighter -group /asciidoc regex \B(?:\+[^\n]+?\+|`[^\n]+?`)\B 0:mono
add-highlighter -group /asciidoc regex \B_[^\n]+?_\B 0:italic
add-highlighter -group /asciidoc regex \B\*[^\n]+?\*\B 0:bold
add-highlighter -group /asciidoc regex ^:[-\w]+: 0:meta
# Commands

View File

@ -261,7 +261,7 @@ hook global WinSetOption filetype=(c|cpp|objc) %[
alias window alt c-family-alternative-file
]
hook global WinSetOption filetype=(?!(c|cpp|objc)$).* %[
hook global WinSetOption filetype=(?!c)(?!cpp)(?!objc).* %[
remove-hooks window c-family-hooks
remove-hooks window c-family-indent
remove-hooks window c-family-insert
@ -270,13 +270,13 @@ hook global WinSetOption filetype=(?!(c|cpp|objc)$).* %[
]
hook -group c-highlight global WinSetOption filetype=c %[ add-highlighter ref c ]
hook -group c-highlight global WinSetOption filetype=(?!c$).* %[ remove-highlighter c ]
hook -group c-highlight global WinSetOption filetype=(?!c).* %[ remove-highlighter c ]
hook -group cpp-highlight global WinSetOption filetype=cpp %[ add-highlighter ref cpp ]
hook -group cpp-highlight global WinSetOption filetype=(?!cpp$).* %[ remove-highlighter cpp ]
hook -group cpp-highlight global WinSetOption filetype=(?!cpp).* %[ remove-highlighter cpp ]
hook -group objc-highlight global WinSetOption filetype=objc %[ add-highlighter ref objc ]
hook -group objc-highlight global WinSetOption filetype=(?!objc$).* %[ remove-highlighter objc ]
hook -group objc-highlight global WinSetOption filetype=(?!objc).* %[ remove-highlighter objc ]
decl -docstring %{control the type of include guard to be inserted in empty headers
Can be one of the following:

View File

@ -71,8 +71,8 @@ def -hidden kak-indent-on-new-line %{
try %{ exec -draft \; K <a-&> }
# cleanup trailing whitespaces from previous line
try %{ exec -draft k <a-x> s \h+$ <ret> d }
# indent after line ending with %[[:punct:]]
try %{ exec -draft k <a-x> <a-k> \%[[:punct:]]$ <ret> j <a-gt> }
# indent after line ending with %[\W\S]
try %{ exec -draft k <a-x> <a-k> \%[\W\S]$ <ret> j <a-gt> }
}
}

View File

@ -14,9 +14,9 @@ hook global BufCreate .*[.](haml) %{
add-highlighter -group / 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 (?=[^|]\n) '' \
coffee ^\h*:coffee\K (?=^\h*[%=-]) '' \
sass ^\h*:sass\K (?=^\h*[%=-]) ''
eval ^\h*[=-]\K (?<!\|)(?=\n) '' \
coffee ^\h*:coffee\K ^\h*[%=-]\K '' \
sass ^\h*:sass\K ^\h*[%=-]\K ''
# Filters
# http://haml.info/docs/yardoc/file.REFERENCE.html#filters

View File

@ -23,7 +23,7 @@ add-highlighter -group /php/code regex \$\w* 0:variable
add-highlighter -group /php/code regex \b(false|null|parent|self|this|true)\b 0:value
add-highlighter -group /php/code regex "-?[0-9]*\.?[0-9]+" 0:value
add-highlighter -group /php/code regex \b((string|int|bool)|[A-Z][a-z].*?)\b 0:type
add-highlighter -group /php/code regex (?<=\W)/[^\n/]+/[gimy]* 0:meta
add-highlighter -group /php/code regex \B/[^\n/]+/[gimy]* 0:meta
# Keywords are collected at
# http://php.net/manual/en/reserved.keywords.php

View File

@ -17,7 +17,7 @@ hook global BufCreate .*[.](pug|jade) %{
add-highlighter -group / 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_-]*)*)?(?<=\S)\h+\K.*' $ '' \
text '^\h*([A-Za-z][A-Za-z0-9_-]*)?(#[A-Za-z][A-Za-z0-9_-]*)?((?:\.[A-Za-z][A-Za-z0-9_-]*)*)?(?<!\t)(?<! )(?<!\n)\h+\K.*' $ '' \
javascript ^\h*[-=!] $ '' \
double_string '"' (?:(?<!\\)(\\\\)*"|$) '' \
single_string "'" (?:(?<!\\)(\\\\)*'|$) '' \