From 810a4490d71afeedd19dcaefdb77f3c0adb6f377 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 23 Dec 2012 15:50:12 -0500 Subject: [PATCH] [#52] Add zstyles to configure syntax-highlighting --- modules/syntax-highlighting/README.md | 12 ++++++++++++ modules/syntax-highlighting/init.zsh | 11 ++++++++++- runcoms/zpreztorc | 7 +++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/syntax-highlighting/README.md b/modules/syntax-highlighting/README.md index 7fb84e2b..c88c54cf 100644 --- a/modules/syntax-highlighting/README.md +++ b/modules/syntax-highlighting/README.md @@ -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 ------- diff --git a/modules/syntax-highlighting/init.zsh b/modules/syntax-highlighting/init.zsh index 0d360174..132481f6 100644 --- a/modules/syntax-highlighting/init.zsh +++ b/modules/syntax-highlighting/init.zsh @@ -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,} + diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index e0f55787..5494fd93 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -110,6 +110,13 @@ zstyle ':prezto:module:prompt' theme 'sorin' # 'pattern' \ # 'cursor' \ # 'root' +# +# Set syntax highlighting styles. +# zstyle ':prezto:module:syntax-highlighting' styles \ +# 'builtin' 'bg=blue' \ +# 'command' 'bg=blue' \ +# 'function' 'bg=blue' +# # # Terminal