[#52] Add zstyles to configure syntax-highlighting

This commit is contained in:
Sorin Ionescu 2012-12-23 15:50:12 -05:00
parent b42479a7c7
commit 810a4490d7
3 changed files with 29 additions and 1 deletions

View file

@ -38,6 +38,18 @@ To enable all highlighters, add the following to *zpreztorc*:
'cursor' \ 'cursor' \
'root' 'root'
### Highlighting Styles
Each syntax highlighter defines styles used to highlight tokens.
To highlight, for example, builtins, commands, and functions in blue instead of
green, add the following to *zpreztorc*:
zstyle ':prezto:module:syntax-highlighting' styles \
'builtin' 'bg=blue' \
'command' 'bg=blue' \
'function' 'bg=blue'
Authors Authors
------- -------

View file

@ -13,9 +13,18 @@ fi
# Source module files. # Source module files.
source "${0:h}/external/zsh-syntax-highlighting.zsh" source "${0:h}/external/zsh-syntax-highlighting.zsh"
# Set the highlighters. # Set highlighters.
zstyle -a ':prezto:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS' zstyle -a ':prezto:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS'
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
fi fi
# Set highlighting styles.
typeset -A syntax_highlighting_styles
zstyle -a ':prezto:module:syntax-highlighting' styles 'syntax_highlighting_styles'
for syntax_highlighting_style in "${(k)syntax_highlighting_styles[@]}"; do
ZSH_HIGHLIGHT_STYLES[$syntax_highlighting_style]=\
"$syntax_highlighting_styles[$syntax_highlighting_style]"
done
unset syntax_highlighting_style{s,}

View file

@ -110,6 +110,13 @@ zstyle ':prezto:module:prompt' theme 'sorin'
# 'pattern' \ # 'pattern' \
# 'cursor' \ # 'cursor' \
# 'root' # 'root'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
#
# #
# Terminal # Terminal