From 3802e03b4cece0517b205af7af868b5c9a32de7d Mon Sep 17 00:00:00 2001 From: garinger Date: Tue, 5 Jul 2011 06:48:02 -0700 Subject: [PATCH 1/2] exclude .beep --- zsh-syntax-highlighting.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 zsh-syntax-highlighting.zsh diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh old mode 100755 new mode 100644 index 55200f3..3f72ff2 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -132,7 +132,7 @@ highlighters_dir="${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${0:h}/highlighters}" } # Override ZLE widgets to make them invoke _zsh_highlight. -for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command)}; do +for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command|.beep)}; do if [[ "$widgets[$event]" == completion:* ]]; then eval "zle -C orig-$event ${${${widgets[$event]}#*:}/:/ } ; $event() { builtin zle orig-$event && _zsh_highlight } ; zle -N $event" else From 48c30a805ab4e49fc83f8d66c1e0474f53c9d31b Mon Sep 17 00:00:00 2001 From: garinger Date: Fri, 8 Jul 2011 07:52:32 -0700 Subject: [PATCH 2/2] highlight opening bracket with "bracket-error" style, if the closing bracket is still missing --- highlighters/brackets/brackets-highlighter.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/highlighters/brackets/brackets-highlighter.zsh b/highlighters/brackets/brackets-highlighter.zsh index 63aae99..2a2130e 100644 --- a/highlighters/brackets/brackets-highlighter.zsh +++ b/highlighters/brackets/brackets-highlighter.zsh @@ -46,8 +46,9 @@ _zsh_highlight_brackets_highlighter_predicate() # Brackets highlighting function. _zsh_highlight_brackets_highlighter() { - bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} + local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} if ((bracket_color_size > 0)); then + local c level pos typeset -A levelpos lastoflevel matching revmatching ((level = 0)) for pos in {1..${#BUFFER}}; do @@ -64,15 +65,16 @@ _zsh_highlight_brackets_highlighter() esac done for pos in ${(k)levelpos}; do - level=$levelpos[$pos] - if ((level < 1)); then + if [[ -z $matching[$pos] ]] && [[ -z $revmatching[$pos] ]]; then region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[bracket-error]) else - region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[bracket-level-$(( (level - 1) % bracket_color_size + 1 ))]) + local style=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 )) + region_highlight+=("$((pos - 1)) $pos "$ZSH_HIGHLIGHT_STYLES[$style]) fi done ((c = CURSOR + 1)) if [[ -n $levelpos[$c] ]]; then + local otherpos ((otherpos = -1)) [[ -n $matching[$c] ]] && otherpos=$matching[$c] [[ -n $revmatching[$c] ]] && otherpos=$revmatching[$c]