diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index d100edb..96243fe 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -1,3 +1,4 @@ +() { # that's here to make the line numbers in errors match the file line numbers. # ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2016 zsh-syntax-highlighting contributors # All rights reserved. @@ -28,13 +29,17 @@ # ------------------------------------------------------------------------------------------------- # First of all, ensure predictable parsing. -zsh_highlight__aliases=`builtin alias -Lm '[^+]*'` +local zsh_highlight__aliases="$(builtin alias -Lm '[^+]*')" # In zsh <= 5.2, `alias -L` emits aliases that begin with a plus sign ('alias -- +foo=42') # them without a '--' guard, so they don't round trip. # # Hence, we exclude them from unaliasing: builtin unalias -m '[^+]*' +# Set the 5.4-to-be WARN_NESTED_VAR option if it's available. +emulate -L zsh +setopt localoptions warncreateglobal ${(k)options[(I)warnnestedvar]} + # Set $0 to the expected value, regardless of functionargzero. 0=${(%):-%N} if true; then @@ -45,7 +50,7 @@ if true; then # When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION # would be set to '$Format:%H$' literally. That's an invalid value, and obtaining # the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so: - ZSH_HIGHLIGHT_REVISION=HEAD + typeset -g ZSH_HIGHLIGHT_REVISION=HEAD fi fi @@ -428,7 +433,7 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { zmodload zsh/parameter 2>/dev/null || true # Initialize the array of active highlighters if needed. -[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) +[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS[1]=main # Restore the aliases we unned eval "$zsh_highlight__aliases" @@ -436,3 +441,6 @@ builtin unset zsh_highlight__aliases # Set $?. true + +# End anonymous function +}