Use stricter regex syntax
boost regex tolerates non-escaped special characters, and escaped non-special characters. Standardize on stricter syntax, where special characters must be escaped, and non-special characters must not.
This commit is contained in:
parent
78530b82be
commit
bf6e5daa08
|
@ -23,7 +23,7 @@ hook -group etc-resolv-conf-highlight global WinSetOption filetype=(?!etc-resolv
|
|||
## /etc/hosts
|
||||
add-highlighter -group / group etc-hosts
|
||||
add-highlighter -group /etc-hosts regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute
|
||||
add-highlighter -group /etc-hosts regex \#.*?$ 0:comment
|
||||
add-highlighter -group /etc-hosts regex '#.*?$' 0:comment
|
||||
|
||||
hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ add-highlighter ref etc-hosts }
|
||||
hook -group etc-hosts-highlight global WinSetOption filetype=(?!etc-hosts).* %{ remove-highlighter etc-hosts }
|
||||
|
@ -31,7 +31,7 @@ hook -group etc-hosts-highlight global WinSetOption filetype=(?!etc-hosts).* %{
|
|||
## /etc/fstab
|
||||
add-highlighter -group / group etc-fstab
|
||||
add-highlighter -group /etc-fstab regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute
|
||||
add-highlighter -group /etc-fstab regex \#.*?$ 0:comment
|
||||
add-highlighter -group /etc-fstab regex '#.*?$' 0:comment
|
||||
|
||||
hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ add-highlighter ref etc-fstab }
|
||||
hook -group etc-fstab-highlight global WinSetOption filetype=(?!etc-fstab).* %{ remove-highlighter etc-fstab }
|
||||
|
|
|
@ -14,7 +14,7 @@ hook global BufCreate .*[.](hs) %{
|
|||
add-highlighter -group / regions -default code haskell \
|
||||
string '(?<!\'\\)(?<!\')"' (?<!\\)(\\\\)*" '' \
|
||||
macro ^\h*?\K# (?<!\\)\n '' \
|
||||
pragma \{-# \#-\} \{- \
|
||||
pragma \{-# '#-\}' \{- \
|
||||
comment \{- -\} \{- \
|
||||
comment --(?![!#$%&*+./<>?@\\\^|~=]) $ ''
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ hook global BufCreate .*\.(repo|service|target|socket|ini|cfg) %{
|
|||
}
|
||||
|
||||
add-highlighter -group / regions -default code ini \
|
||||
comment (^|\h)\K[\#\;] $ ''
|
||||
comment '(^|\h)\K[#;]' $ ''
|
||||
|
||||
add-highlighter -group /ini/code regex "^\h*\[[^\]]*\]" 0:title
|
||||
add-highlighter -group /ini/code regex "^\h*([^\[][^=\n]*=)([^\n]*)" 1:variable 2:value
|
||||
|
|
|
@ -25,7 +25,7 @@ add-highlighter -group /javascript/single_string fill string
|
|||
add-highlighter -group /javascript/regex fill meta
|
||||
add-highlighter -group /javascript/comment fill comment
|
||||
add-highlighter -group /javascript/literal fill string
|
||||
add-highlighter -group /javascript/literal regex \${.*?} 0:value
|
||||
add-highlighter -group /javascript/literal regex \$\{.*?\} 0:value
|
||||
|
||||
add-highlighter -group /javascript/code regex \$\w* 0:variable
|
||||
add-highlighter -group /javascript/code regex \b(document|false|null|parent|self|this|true|undefined|window)\b 0:value
|
||||
|
|
|
@ -12,10 +12,10 @@ hook global BufCreate .*[.](lua) %{
|
|||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
add-highlighter -group / regions -default code lua \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
string "'" (?<!\\)(\\\\)*' '' \
|
||||
comment '--' '$' '' \
|
||||
comment '\Q--[[' ']]' '' \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
string "'" (?<!\\)(\\\\)*' '' \
|
||||
comment '--' '$' '' \
|
||||
comment '--\[\[' '\]\]' '' \
|
||||
|
||||
add-highlighter -group /lua/string fill string
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ def -hidden ruby-indent-on-new-line %{
|
|||
def -hidden ruby-insert-on-new-line %{
|
||||
eval -no-hooks -draft -itersel %{
|
||||
# copy _#_ comment prefix and following white spaces
|
||||
try %{ exec -draft k <a-x> s ^ \h * \K \# \h * <ret> y gh j P }
|
||||
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
|
||||
# wisely add end structure
|
||||
eval -save-regs x %{
|
||||
try %{ exec -draft k <a-x> s ^ \h + <ret> \" x y } catch %{ reg x '' }
|
||||
|
|
|
@ -12,17 +12,17 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{
|
|||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
add-highlighter -group / regions -default code kakrc \
|
||||
comment (^|\h)\K\# $ '' \
|
||||
comment (^|\h)\K# $ '' \
|
||||
double_string %{(^|\h)\K"} %{(?<!\\)(\\\\)*"} '' \
|
||||
single_string %{(^|\h)\K'} %{(?<!\\)(\\\\)*'} '' \
|
||||
shell '(^|\h)\K%sh\{' '\}' '\{' \
|
||||
shell '(^|\h)\K%sh\(' '\)' '\(' \
|
||||
shell '(^|\h)\K%sh\[' '\]' '\[' \
|
||||
shell '(^|\h)\K%sh\<' '\>' '\<' \
|
||||
shell '(^|\h)\K%sh<' '>' '<' \
|
||||
shell '(^|\h)\K-shell-(completion|candidates)\h+%\{' '\}' '\{' \
|
||||
shell '(^|\h)\K-shell-(completion|candidates)\h+%\(' '\)' '\(' \
|
||||
shell '(^|\h)\K-shell-(completion|candidates)\h+%\[' '\]' '\[' \
|
||||
shell '(^|\h)\K-shell-(completion|candidates)\h+%\<' '\>' '\<'
|
||||
shell '(^|\h)\K-shell-(completion|candidates)\h+%<' '>' '<'
|
||||
|
||||
%sh{
|
||||
# Grammar
|
||||
|
|
|
@ -56,7 +56,7 @@ def -hidden coffee-filter-around-selections %{
|
|||
def -hidden coffee-indent-on-new-line %{
|
||||
eval -draft -itersel %{
|
||||
# copy '#' comment prefix and following white spaces
|
||||
try %{ exec -draft k <a-x> s ^ \h * \K \# \h * <ret> y gh j P }
|
||||
try %{ exec -draft k <a-x> s '^\h*\K#\h*' <ret> y gh j P }
|
||||
# preserve previous line indent
|
||||
try %{ exec -draft \; K <a-&> }
|
||||
# filter previous line
|
||||
|
|
|
@ -3,7 +3,7 @@ hook global BufCreate .*\.ks %{
|
|||
}
|
||||
|
||||
add-highlighter -group / regions -default code kickstart \
|
||||
comment (^|\h)\K\# $ '' \
|
||||
comment '(^|\h)\K#' $ '' \
|
||||
double_string '"' (?<!\\)(\\\\)*" '' \
|
||||
single_string "'" (?<!\\)(\\\\)*' '' \
|
||||
packages '^\h*\K%packages\b' '^\h*\K%end\b' '' \
|
||||
|
|
|
@ -18,7 +18,7 @@ add-highlighter -group /latex/comment fill comment
|
|||
# Scopes, starting with a backslash
|
||||
add-highlighter -group /latex/content regex '\\(?!_)\w+\b' 0:keyword
|
||||
# Options passed to scopes, between brackets
|
||||
add-highlighter -group /latex/content regex '\\(?!_)\w+\b\[([^]]+)\]' 1:value
|
||||
add-highlighter -group /latex/content regex '\\(?!_)\w+\b\[([^\]]+)\]' 1:value
|
||||
# Content between dollar signs/pairs
|
||||
add-highlighter -group /latex/content regex '(\$(\\\$|[^$])+\$)|(\$\$(\\\$|[^$])+\$\$)' 0:magenta
|
||||
# Emphasized text
|
||||
|
|
|
@ -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_-]*)*)?(?<=\S)\h+\K.*' $ '' \
|
||||
javascript ^\h*[-=!] $ '' \
|
||||
double_string '"' (?:(?<!\\)(\\\\)*"|$) '' \
|
||||
single_string "'" (?:(?<!\\)(\\\\)*'|$) '' \
|
||||
|
@ -38,7 +38,7 @@ add-highlighter -group /pug/puglang regex \b(\block|extends|include|a
|
|||
add-highlighter -group /pug/attribute regex [()=] 0:operator
|
||||
add-highlighter -group /pug/text regex \h*(\|) 1:meta
|
||||
add-highlighter -group /pug/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*) 1:type
|
||||
add-highlighter -group /pug/code regex (\#[A-Za-z][A-Za-z0-9_-]*) 1:variable
|
||||
add-highlighter -group /pug/code regex '(#[A-Za-z][A-Za-z0-9_-]*)' 1:variable
|
||||
add-highlighter -group /pug/code regex ((?:\.[A-Za-z][A-Za-z0-9_-]*)*) 1:value
|
||||
|
||||
# Commands
|
||||
|
|
Loading…
Reference in New Issue
Block a user