From 0fa59e5fd283dc89ad9c6ceb8c3e0b0974d8b1d0 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 2 Oct 2017 20:59:22 +0800 Subject: [PATCH] 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. --- rc/base/haskell.kak | 6 +++--- rc/base/html.kak | 4 ++-- rc/base/lisp.kak | 2 +- rc/base/markdown.kak | 2 +- rc/base/perl.kak | 8 ++++---- rc/base/ruby.kak | 2 +- rc/core/asciidoc.kak | 6 +++--- rc/core/c-family.kak | 8 ++++---- rc/core/kakrc.kak | 4 ++-- rc/extra/haml.kak | 8 ++++---- rc/extra/php.kak | 2 +- rc/extra/pug.kak | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/rc/base/haskell.kak b/rc/base/haskell.kak index 6fd781c8..4106b895 100644 --- a/rc/base/haskell.kak +++ b/rc/base/haskell.kak @@ -40,13 +40,13 @@ add-highlighter -group /haskell/code regex (?> # 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: !. .! diff --git a/rc/base/html.kak b/rc/base/html.kak index 385b2667..b1695535 100644 --- a/rc/base/html.kak +++ b/rc/base/html.kak @@ -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 } diff --git a/rc/base/lisp.kak b/rc/base/lisp.kak index 2b806b70..3a448712 100644 --- a/rc/base/lisp.kak +++ b/rc/base/lisp.kak @@ -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 diff --git a/rc/base/markdown.kak b/rc/base/markdown.kak index 8d50cad8..b992b83e 100644 --- a/rc/base/markdown.kak +++ b/rc/base/markdown.kak @@ -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 diff --git a/rc/base/perl.kak b/rc/base/perl.kak index 7ba1e14b..45c70c72 100644 --- a/rc/base/perl.kak +++ b/rc/base/perl.kak @@ -12,10 +12,10 @@ hook global BufCreate .*\.p[lm] %{ # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code perl \ - command '(? } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } - # indent after line ending with %[[:punct:]] - try %{ exec -draft k \%[[:punct:]]$ j } + # indent after line ending with %[\W\S] + try %{ exec -draft k \%[\W\S]$ j } } } diff --git a/rc/extra/haml.kak b/rc/extra/haml.kak index 75169e43..11e525b0 100644 --- a/rc/extra/haml.kak +++ b/rc/extra/haml.kak @@ -12,11 +12,11 @@ hook global BufCreate .*[.](haml) %{ # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter -group / regions -default code haml \ - comment ^\h*/ $ '' \ + 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 (?