Skip to content

Commit

Permalink
[sorin-ionescu#52] Add zstyles to configure syntax-highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
sorin-ionescu authored and matthoffman committed Sep 18, 2014
1 parent 0734afc commit 500a207
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/syntax-highlighting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ To enable all highlighters, add the following to *zpreztorc*:
'cursor' \
'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
-------

Expand Down
11 changes: 10 additions & 1 deletion modules/syntax-highlighting/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ fi
# Source module files.
source "${0:h}/external/zsh-syntax-highlighting.zsh"

# Set the highlighters.
# Set highlighters.
zstyle -a ':prezto:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS'
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
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,}

7 changes: 7 additions & 0 deletions runcoms/zpreztorc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ zstyle ':prezto:module:prompt' theme 'matt'
# 'pattern' \
# 'cursor' \
# 'root'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
#

#
# Terminal
Expand Down

0 comments on commit 500a207

Please sign in to comment.