Autoload highlighters

This commit is contained in:
Matthew Martin 2020-08-09 19:33:44 -05:00
commit b62aeb6168
22 changed files with 2287 additions and 1907 deletions

View file

@ -30,31 +30,3 @@
# List of keyword and color pairs.
typeset -gA ZSH_HIGHLIGHT_PATTERNS
# Whether the pattern highlighter should be called or not.
_zsh_highlight_highlighter_pattern_predicate()
{
_zsh_highlight_buffer_modified
}
# Pattern syntax highlighting function.
_zsh_highlight_highlighter_pattern_paint()
{
setopt localoptions extendedglob
local pattern
for pattern in ${(k)ZSH_HIGHLIGHT_PATTERNS}; do
_zsh_highlight_pattern_highlighter_loop "$BUFFER" "$pattern"
done
}
_zsh_highlight_pattern_highlighter_loop()
{
# This does *not* do its job syntactically, sorry.
local buf="$1" pat="$2"
local -a match mbegin mend
local MATCH; integer MBEGIN MEND
if [[ "$buf" == (#b)(*)(${~pat})* ]]; then
region_highlight+=("$((mbegin[2] - 1)) $mend[2] $ZSH_HIGHLIGHT_PATTERNS[$pat], memo=zsh-syntax-highlighting")
"$0" "$match[1]" "$pat"; return $?
fi
}