1 Commits

Author SHA1 Message Date
Matthew Martin
1089e3a408 themes: Initial support 2019-07-20 10:51:23 -05:00
59 changed files with 193 additions and 1582 deletions

View File

@@ -1,9 +0,0 @@
# Top-most editorconfig file
root = true
[*]
end_of_line = lf
tab_width = 2
indent_size = 2
indent_style = space

View File

@@ -1 +1 @@
0.7.1 0.7.0-dev

View File

@@ -1,4 +1,4 @@
Copyright (c) 2010-2020 zsh-syntax-highlighting contributors Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted Redistribution and use in source and binary forms, with or without modification, are permitted

View File

@@ -6,7 +6,7 @@ How to install
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package] * Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository]) * Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository])
* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository]) * Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository])
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port]) * FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`textproc/zsh-syntax-highlighting`][freebsd-port])
* Gentoo: [mv overlay][gentoo-overlay] * Gentoo: [mv overlay][gentoo-overlay]
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package] * Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository]) * Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])

View File

@@ -1,3 +1,5 @@
**This branch will be rebased from time to time.**
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis] zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
======================= =======================

View File

@@ -1,79 +1,3 @@
# Changes in version 0.7.1
- Remove out-of-date information from the 0.7.0 changelog.
# Changes in version 0.7.0
This is a stable bugfix and feature release. Major new features and changes include:
- Add `ZSH_HIGHLIGHT_DIRS_BLACKLIST` to disable "path" and "path prefix"
highlighting for specific directories
[#379]
- Add the "regexp" highlighter, modelled after the pattern highlighter
[4e6f60063f1c]
- When a word uses globbing, only the globbing metacharacters will be highlighted as globbing:
in `: foo*bar`, only the `*` will be blue.
[e48af357532c]
- Highlight pasted quotes (e.g., `: foo"bar"`)
[dc1b2f6fa4bb]
- Highlight command substitutions (`` : `ls` ``, `: $(ls)`)
[c0e64fe13178 and parents, e86f75a840e7, et al]
- Highlight process substitutions (`: >(nl)`, `: <(pwd)`, `: =(git diff)`)
[c0e64fe13178 and parents, e86f75a840e7, et al]
- Highlight command substitutions inside double quotes (``: "`foo`"``)
[f16e858f0c83]
- Highlight many precommands (e.g., `nice`, `stdbuf`, `eatmydata`;
see `$precommand_options` in the source)
- Highlight numeric globs (e.g., `echo /lib<->`)
- Assorted improvement to aliases highlighting
(e.g.,
`alias sudo_u='sudo -u'; sudo_u jrandom ls`,
`alias x=y y=z z=nosuchcommand; x`,
`alias ls='ls -l'; \ls`)
[f3410c5862fc, 57386f30aec8, #544, and many others]
- Highlight some more syntax errors
[dea05e44e671, 298ef6a2fa30]
- New styles: named file descriptors, `RC_QUOTES`, and unclosed quotes (e.g., `echo "foo<CURSOR>`)
[38c794a978cd, 25ae1c01216c, 967335dfc5fd]
- The 'brackets' highlighting no longer treats quotes specially.
[ecdda36ef56f]
Selected bugfixes include:
- Highlight `sudo` correctly when it's not installed
[26a82113b08b]
- Handle some non-default options being set in zshrc
[b07ada1255b7, a2a899b41b8, 972ad197c13d, b3f66fc8748f]
- Fix off-by-one highlighting in vi "visual" mode (vicmd keymap)
[be3882aeb054]
- The 'yank-pop' widget is not wrapped
[#183]
Known issues include:
- A multiline alias that uses a simple command terminator (such as `;`, `|`, `&&`)
before a newline will incorrectly be highlighted as an error. See issue #677
for examples and workarounds.
[#677]
# Changes in version 0.6.0 # Changes in version 0.6.0
This is a stable release, featuring bugfixes and minor improvements. This is a stable release, featuring bugfixes and minor improvements.

View File

@@ -44,6 +44,18 @@ page][zshzle-Character-Highlighting].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
Styles may be set directly or by themes. If no theme is specified in
`ZSH_HIGHLIGHT_THEME` the `default` theme will be loaded. Additional themes
may be layered on top (overriding previous theme's settings) by calling
`_zsh_highlight_load_theme`. `_zsh_highlight_load_theme` takes either an
absolute path to a theme file to load or a theme name. For a theme name the
base theme from the themes directory is loaded and then the extensions of the
theme that any active highlighter has are loaded. Names must not contain a `/`.
The `default` theme is a colorful theme that preserves the defaults the
highlighters originally had. The `error-only` theme is also available for
highlighting only syntax errors.
Some highlighters support additional configuration parameters; see each Some highlighters support additional configuration parameters; see each
highlighter's documentation for details and examples. highlighter's documentation for details and examples.
@@ -70,13 +82,8 @@ To create your own `acme` highlighter:
* Implement the `_zsh_highlight_highlighter_acme_paint` function. * Implement the `_zsh_highlight_highlighter_acme_paint` function.
This function does the actual syntax highlighting, by calling This function does the actual syntax highlighting, by calling
`_zsh_highlight_add_highlight` with the start and end of the region to `_zsh_highlight_add_highlight` with the start and end of the region to
be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. Define the default be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. The key should
style for that key in the highlighter script outside of any function with be prefixed with your highlighter name and a colon
`: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix
the key with your highlighter name and a colon. For example:
```zsh
: ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green}
_zsh_highlight_highlighter_acme_paint() { _zsh_highlight_highlighter_acme_paint() {
# Colorize the whole buffer with the 'aurora' style # Colorize the whole buffer with the 'aurora' style
@@ -104,7 +111,16 @@ To create your own `acme` highlighter:
`_zsh_highlight_highlighter_acme_paint` respectively. `_zsh_highlight_highlighter_acme_paint` respectively.
These names are still supported for backwards compatibility; These names are still supported for backwards compatibility;
however, support for them will be removed in a future major or minor release (v0.x.0 or v1.0.0). however, support for them will be removed in a a future major or minor release (v0.x.0 or v1.0.0).
* Optionally extended the built-in themes in
`highlighters/${myhighlighter}/themes/${themename}`.
Define the theme's style for that key with `ZSH_HIGHLIGHT_STYLES[key]=value`,
being sure to prefix the key with your highlighter name and a colon. For
example:
ZSH_HIGHLIGHT_STYLES[myhighlighter:aurora]=fg=green
* Activate your highlighter in `~/.zshrc`: * Activate your highlighter in `~/.zshrc`:

View File

@@ -85,10 +85,11 @@ manual page][zshzle-Character-Highlighting].
#### Parameters #### Parameters
To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array. To avoid partial path lookups on a path, add the path to the `X_ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
This interface is still experimental.
```zsh ```zsh
ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share) X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
``` ```
### Useless trivia ### Useless trivia

View File

@@ -28,15 +28,6 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[bracket-error]:=fg=red,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-1]:=fg=blue,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-2]:=fg=green,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-3]:=fg=magenta,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-4]:=fg=yellow,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-5]:=fg=cyan,bold}
: ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout}
# Whether the brackets highlighter should be called or not. # Whether the brackets highlighter should be called or not.
_zsh_highlight_highlighter_brackets_predicate() _zsh_highlight_highlighter_brackets_predicate()
{ {

View File

@@ -28,9 +28,6 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout}
# Whether the cursor highlighter should be called or not. # Whether the cursor highlighter should be called or not.
_zsh_highlight_highlighter_cursor_predicate() _zsh_highlight_highlighter_cursor_predicate()
{ {

View File

@@ -28,9 +28,6 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[line]:=}
# Whether the root highlighter should be called or not. # Whether the root highlighter should be called or not.
_zsh_highlight_highlighter_line_predicate() _zsh_highlight_highlighter_line_predicate()
{ {

View File

@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Copyright (c) 2010-2020 zsh-syntax-highlighting contributors # Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without modification, are permitted # Redistribution and use in source and binary forms, with or without modification, are permitted
@@ -28,39 +28,6 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[default]:=none}
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
: ${ZSH_HIGHLIGHT_STYLES[command-substitution]:=none}
: ${ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[process-substitution]:=none}
: ${ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none}
: ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none}
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
# Whether the highlighter should be called or not. # Whether the highlighter should be called or not.
_zsh_highlight_highlighter_main_predicate() _zsh_highlight_highlighter_main_predicate()
{ {
@@ -77,16 +44,6 @@ _zsh_highlight_main_add_region_highlight() {
[[ $1 == unknown-token ]] && alias_style=unknown-token [[ $1 == unknown-token ]] && alias_style=unknown-token
return return
fi fi
if (( in_param )); then
if [[ $1 == unknown-token ]]; then
param_style=unknown-token
fi
if [[ -n $param_style ]]; then
return
fi
param_style=$1
return
fi
# The calculation was relative to $buf but region_highlight is relative to $BUFFER. # The calculation was relative to $buf but region_highlight is relative to $BUFFER.
(( start += buf_offset )) (( start += buf_offset ))
@@ -198,7 +155,7 @@ _zsh_highlight_main__type() {
elif { [[ $1 != */* ]] || is-at-least 5.3 } && elif { [[ $1 != */* ]] || is-at-least 5.3 } &&
# Add a subshell to avoid a zsh upstream bug; see issue #606. # Add a subshell to avoid a zsh upstream bug; see issue #606.
# ### Remove the subshell when we stop supporting zsh 5.7.1 (I assume 5.8 will have the bugfix). # ### Remove the subshell when we stop supporting zsh 5.7.1 (I assume 5.8 will have the bugfix).
! (builtin type -w -- "$1") >/dev/null 2>&1; then ! (builtin type -w -- $1) >/dev/null 2>&1; then
REPLY=none REPLY=none
fi fi
fi fi
@@ -213,7 +170,7 @@ _zsh_highlight_main__type() {
# starts with an arithmetic expression [«((…))» as the first thing inside # starts with an arithmetic expression [«((…))» as the first thing inside
# «$(…)»], which is area that has had some parsing bugs before 5.6 # «$(…)»], which is area that has had some parsing bugs before 5.6
# (approximately). # (approximately).
REPLY="${$(:; (( aliases_allowed )) || unalias -- "$1" 2>/dev/null; LC_ALL=C builtin type -w -- "$1" 2>/dev/null)##*: }" REPLY="${$(:; (( aliases_allowed )) || unalias -- $1 2>/dev/null; LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
if [[ $REPLY == 'alias' ]]; then if [[ $REPLY == 'alias' ]]; then
may_cache=0 may_cache=0
fi fi
@@ -319,33 +276,15 @@ _zsh_highlight_highlighter_main_paint()
'builtin' '' 'builtin' ''
'command' :pvV 'command' :pvV
'exec' a:cl 'exec' a:cl
'nocorrect' ''
'noglob' '' 'noglob' ''
# 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands.
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016 'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
'nice' n: # as of current POSIX spec 'nice' n: # as of current POSIX spec
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags 'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
# Argumentless flags that can't be followed by a command: -e -h -K -k -V -v 'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
'sudo' Cgprtu:AEHPSbilns # as of sudo 1.8.21p2
'stdbuf' ioe: 'stdbuf' ioe:
'eatmydata' ''
'catchsegv' ''
'nohup' ''
'setsid' :wc
# As of OpenSSH 8.1p1; -k is deliberately left out since it may not be followed by a command
'ssh-agent' aEPt:csDd
# suckless-tools v44
# Argumentless flags that can't be followed by a command: -v
'tabbed' gnprtTuU:cdfhs
# moreutils 0.62-1
'chronic' :ev
'ifne' :n
) )
# Commands that would need to skip one positional argument:
# flock
# ssh
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
local right_brace_is_recognised_everywhere=false local right_brace_is_recognised_everywhere=false
@@ -383,12 +322,6 @@ _zsh_highlight_highlighter_main_paint()
'!' # reserved word; unrelated to $histchars[1] '!' # reserved word; unrelated to $histchars[1]
) )
if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.'
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
fi
_zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER" _zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER"
# end is a reserved word # end is a reserved word
@@ -416,13 +349,13 @@ _zsh_highlight_main_highlighter_highlight_list()
# alias_style is the style to apply to an alias once in_alias=0 # alias_style is the style to apply to an alias once in_alias=0
# Usually 'alias' but set to 'unknown-token' if any word expanded from # Usually 'alias' but set to 'unknown-token' if any word expanded from
# the alias would be highlighted as unknown-token # the alias would be highlighted as unknown-token
# param_style is analogous for parameter expansions # last_alias is the last alias arg (lhs) expanded (if in an alias).
local alias_style param_style arg buf=$4 highlight_glob=true style # This allows for expanding alias ls='ls -l' while avoiding loops.
local alias_style arg buf=$4 highlight_glob=true last_alias style
local in_array_assignment=false # true between 'a=(' and the matching ')' local in_array_assignment=false # true between 'a=(' and the matching ')'
# in_alias is equal to the number of shifts needed until arg=args[1] pops an # in_alias is equal to the number of shifts needed until arg=args[1] pops an
# arg from BUFFER and not added by an alias. # arg from BUFFER and not added by an alias.
# in_param is analogous for parameter expansions integer in_alias=0 len=$#buf
integer in_alias=0 in_param=0 len=$#buf
local -a match mbegin mend list_highlights local -a match mbegin mend list_highlights
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a # seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
local -A seen_alias local -A seen_alias
@@ -458,12 +391,12 @@ _zsh_highlight_main_highlighter_highlight_list()
# #
# When the kind of a word is not yet known, $this_word / $next_word may contain # When the kind of a word is not yet known, $this_word / $next_word may contain
# multiple states. For example, after "sudo -i", the next word may be either # multiple states. For example, after "sudo -i", the next word may be either
# another --flag or a command name, hence the state would include both ':start:' # another --flag or a command name, hence the state would include both :start:
# and ':sudo_opt:'. # and :sudo_opt:.
# #
# The tokens are always added with both leading and trailing colons to serve as # The tokens are always added with both leading and trailing colons to serve as
# word delimiters (an improvised array); [[ $x == *':foo:'* ]] and x=${x//:foo:/} # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/}
# will DTRT regardless of how many elements or repetitions $x has. # will DTRT regardless of how many elements or repetitions $x has..
# #
# Handling of redirections: upon seeing a redirection token, we must stall # Handling of redirections: upon seeing a redirection token, we must stall
# the current state --- that is, the value of $this_word --- for two iterations # the current state --- that is, the value of $this_word --- for two iterations
@@ -496,19 +429,11 @@ _zsh_highlight_main_highlighter_highlight_list()
if (( in_alias )); then if (( in_alias )); then
(( in_alias-- )) (( in_alias-- ))
if (( in_alias == 0 )); then if (( in_alias == 0 )); then
seen_alias=() last_alias= seen_alias=()
# start_pos and end_pos are of the alias (previous $arg) here # start_pos and end_pos are of the alias (previous $arg) here
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
fi fi
fi fi
if (( in_param )); then
(( in_param-- ))
if (( in_param == 0 )); then
# start_pos and end_pos are of the '$foo' word (previous $arg) here
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
param_style=""
fi
fi
# Initialize this_word and next_word. # Initialize this_word and next_word.
if (( in_redirection == 0 )); then if (( in_redirection == 0 )); then
@@ -533,7 +458,7 @@ _zsh_highlight_main_highlighter_highlight_list()
fi fi
fi fi
if (( in_alias == 0 && in_param == 0 )); then if (( in_alias == 0 )); then
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf. # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
[[ "$proc_buf" = (#b)(#s)(([ $'\t']|\\$'\n')#)* ]] [[ "$proc_buf" = (#b)(#s)(([ $'\t']|\\$'\n')#)* ]]
# The first, outer parenthesis # The first, outer parenthesis
@@ -576,19 +501,20 @@ _zsh_highlight_main_highlighter_highlight_list()
continue continue
fi fi
if [[ $this_word == *':start:'* ]] && ! (( in_redirection )); then if [[ $this_word == *:start:* ]] && ! (( in_redirection )); then
# Expand aliases. # Expand aliases.
# An alias is ineligible for expansion while it's being expanded (see #652/#653). _zsh_highlight_main__type "$arg"
_zsh_highlight_main__type "$arg" "$(( ! ${+seen_alias[$arg]} ))"
local res="$REPLY" local res="$REPLY"
if [[ $res == "alias" ]]; then if [[ $res == "alias" ]] && [[ $last_alias != $arg ]]; then
# Mark insane aliases as unknown-token (cf. #263). # Avoid looping forever on alias a=b b=c c=b, but allow alias foo='foo bar'
if [[ $arg == ?*=* ]]; then # Also mark insane aliases as unknown-token (cf. #263).
if (( $+seen_alias[$arg] )) || [[ $arg == ?*=* ]]; then
(( in_alias == 0 )) && in_alias=1 (( in_alias == 0 )) && in_alias=1
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
continue continue
fi fi
seen_alias[$arg]=1 seen_alias[$arg]=1
last_alias=$arg
_zsh_highlight_main__resolve_alias $arg _zsh_highlight_main__resolve_alias $arg
local -a alias_args local -a alias_args
# Elision is desired in case alias x='' # Elision is desired in case alias x=''
@@ -611,7 +537,8 @@ _zsh_highlight_main_highlighter_highlight_list()
continue continue
else else
_zsh_highlight_main_highlighter_expand_path $arg _zsh_highlight_main_highlighter_expand_path $arg
_zsh_highlight_main__type "$REPLY" 0 arg=$REPLY
_zsh_highlight_main__type "$arg" 0
res="$REPLY" res="$REPLY"
fi fi
fi fi
@@ -646,7 +573,6 @@ _zsh_highlight_main_highlighter_highlight_list()
local -a match mbegin mend local -a match mbegin mend
local MATCH; integer MBEGIN MEND local MATCH; integer MBEGIN MEND
local parameter_name local parameter_name
local -a words
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
parameter_name=${${arg:2}%?} parameter_name=${${arg:2}%?}
elif [[ $arg[1] == '$' ]]; then elif [[ $arg[1] == '$' ]]; then
@@ -659,16 +585,14 @@ _zsh_highlight_main_highlighter_highlight_list()
# Set $arg. # Set $arg.
case ${(tP)MATCH} in case ${(tP)MATCH} in
(*array*|*assoc*) (*array*|*assoc*)
words=( ${(P)MATCH} ) local -a words; words=( ${(P)MATCH} )
arg=${words[1]}
;; ;;
(*) (*)
# scalar, presumably # scalar, presumably
words=( ${(P)MATCH} ) arg=${(P)MATCH}
;; ;;
esac esac
(( in_param = 1 + $#words ))
args=( $words $args )
arg=$args[1]
_zsh_highlight_main__type "$arg" 0 _zsh_highlight_main__type "$arg" 0
res=$REPLY res=$REPLY
fi fi
@@ -693,20 +617,16 @@ _zsh_highlight_main_highlighter_highlight_list()
elif [[ -n $flags_sans_argument ]] && elif [[ -n $flags_sans_argument ]] &&
[[ $arg == '-'[$flags_sans_argument]# ]]; then [[ $arg == '-'[$flags_sans_argument]# ]]; then
# Flag that requires no argument # Flag that requires no argument
this_word=':sudo_opt:' this_word=:sudo_opt:
next_word+=':start:' next_word+=':start:'
next_word+=':sudo_opt:' next_word+=':sudo_opt:'
elif [[ $arg == '-'* ]]; then elif [[ $arg == '-'* ]]; then
# Unknown flag. We don't know whether it takes an argument or not, # Unknown flag
# so modify $next_word as we do for flags that require no argument. this_word=:sudo_opt:
# With that behaviour, if the flag in fact takes no argument we'll
# highlight the inner command word correctly, and if it does take an
# argument we'll highlight the command word correctly if the argument
# was given in the same shell word as the flag (as in '-uphy1729' or
# '--user=phy1729' without spaces).
this_word=':sudo_opt:'
next_word+=':start:' next_word+=':start:'
next_word+=':sudo_opt:' next_word+=':sudo_opt:'
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
continue
else else
# Not an option flag; nothing to do. (If the command line is # Not an option flag; nothing to do. (If the command line is
# syntactically valid, ${this_word//:sudo_opt:/} should be # syntactically valid, ${this_word//:sudo_opt:/} should be
@@ -759,10 +679,6 @@ _zsh_highlight_main_highlighter_highlight_list()
style=reserved-word style=reserved-word
# Match braces and handle special cases. # Match braces and handle special cases.
case $arg in case $arg in
(time|nocorrect)
next_word=${next_word//:regular:/}
next_word+=':start:'
;;
($'\x7b') ($'\x7b')
braces_stack='Y'"$braces_stack" braces_stack='Y'"$braces_stack"
;; ;;
@@ -840,7 +756,7 @@ _zsh_highlight_main_highlighter_highlight_list()
function) style=function;; function) style=function;;
command) style=command;; command) style=command;;
hashed) style=hashed-command;; hashed) style=hashed-command;;
none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then none) if _zsh_highlight_main_highlighter_check_assign; then
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
local i=$(( arg[(i)=] + 1 )) local i=$(( arg[(i)=] + 1 ))
if [[ $arg[i] == '(' ]]; then if [[ $arg[i] == '(' ]]; then
@@ -852,7 +768,7 @@ _zsh_highlight_main_highlighter_highlight_list()
# Discard :start_of_pipeline:, if present, as '!' is not valid # Discard :start_of_pipeline:, if present, as '!' is not valid
# after assignments. # after assignments.
next_word+=':start:' next_word+=':start:'
if (( i <= $#arg )); then if (( start_pos + i <= end_pos )); then
() { () {
local highlight_glob=false local highlight_glob=false
[[ $zsyh_user_options[globassign] == on ]] && highlight_glob=true [[ $zsyh_user_options[globassign] == on ]] && highlight_glob=true
@@ -861,14 +777,11 @@ _zsh_highlight_main_highlighter_highlight_list()
fi fi
fi fi
continue continue
elif (( ! in_param )) && elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
style=history-expansion style=history-expansion
elif (( ! in_param )) && elif [[ $arg[0,1] == $histchars[2,2] ]]; then
[[ $arg[0,1] == $histchars[2,2] ]]; then
style=history-expansion style=history-expansion
elif (( ! in_param )) && elif [[ $arg[1,2] == '((' ]]; then
[[ $arg[1,2] == '((' ]]; then
# Arithmetic evaluation. # Arithmetic evaluation.
# #
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...} # Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@@ -883,17 +796,14 @@ _zsh_highlight_main_highlighter_highlight_list()
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word _zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
fi fi
continue continue
elif (( ! in_param )) && elif [[ $arg == '()' ]]; then
[[ $arg == '()' ]]; then
# anonymous function # anonymous function
style=reserved-word style=reserved-word
elif (( ! in_param )) && elif [[ $arg == $'\x28' ]]; then
[[ $arg == $'\x28' ]]; then
# subshell # subshell
style=reserved-word style=reserved-word
braces_stack='R'"$braces_stack" braces_stack='R'"$braces_stack"
elif (( ! in_param )) && elif [[ $arg == $'\x29' ]]; then
[[ $arg == $'\x29' ]]; then
# end of subshell or command substitution # end of subshell or command substitution
if _zsh_highlight_main__stack_pop 'S'; then if _zsh_highlight_main__stack_pop 'S'; then
REPLY=$start_pos REPLY=$start_pos
@@ -975,7 +885,6 @@ _zsh_highlight_main_highlighter_highlight_list()
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
done done
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style (( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]] [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
REPLY=$(( end_pos + ${#match[1]} - 1 )) REPLY=$(( end_pos + ${#match[1]} - 1 ))
reply=($list_highlights) reply=($list_highlights)
@@ -1024,7 +933,7 @@ _zsh_highlight_main_highlighter_check_path()
tmp_path=$tmp_path:a tmp_path=$tmp_path:a
while [[ $tmp_path != / ]]; do while [[ $tmp_path != / ]]; do
[[ -n ${(M)ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1 [[ -n ${(M)X_ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
tmp_path=$tmp_path:h tmp_path=$tmp_path:h
done done
@@ -1082,7 +991,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
'=') '=')
if [[ $arg[i+1] == $'\x28' ]]; then if [[ $arg[i+1] == $'\x28' ]]; then
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1096,7 +1005,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
fi fi
esac esac
for (( ; i <= $#arg ; i += 1 )); do for (( ; i <= end_pos - start_pos ; i += 1 )); do
case "$arg[$i]" in case "$arg[$i]" in
"\\") (( i += 1 )); continue;; "\\") (( i += 1 )); continue;;
"'") "'")
@@ -1126,7 +1035,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
elif [[ $arg[i+1] == $'\x28' ]]; then elif [[ $arg[i+1] == $'\x28' ]]; then
start=$i start=$i
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1149,7 +1058,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren
start=$i start=$i
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1175,7 +1084,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
esac esac
done done
if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,-1]; then if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,end_pos]; then
base_style=$REPLY base_style=$REPLY
_zsh_highlight_main_highlighter_highlight_path_separators $base_style _zsh_highlight_main_highlighter_highlight_path_separators $base_style
highlights+=($reply) highlights+=($reply)
@@ -1227,7 +1136,7 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
local i j k ret style local i j k ret style
reply=() reply=()
for (( i = $1 + 1 ; i <= $#arg ; i += 1 )) ; do for (( i = $1 + 1 ; i <= end_pos - start_pos ; i += 1 )) ; do
(( j = i + start_pos - 1 )) (( j = i + start_pos - 1 ))
(( k = j + 1 )) (( k = j + 1 ))
case "$arg[$i]" in case "$arg[$i]" in
@@ -1258,7 +1167,7 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
breaks+=( $last_break $(( start_pos + i - 1 )) ) breaks+=( $last_break $(( start_pos + i - 1 )) )
(( i += 2 )) (( i += 2 ))
saved_reply=($reply) saved_reply=($reply)
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
last_break=$(( start_pos + i )) last_break=$(( start_pos + i ))
@@ -1324,13 +1233,13 @@ _zsh_highlight_main_highlighter_highlight_dollar_quote()
integer c integer c
reply=() reply=()
for (( i = $1 + 2 ; i <= $#arg ; i += 1 )) ; do for (( i = $1 + 2 ; i <= end_pos - start_pos ; i += 1 )) ; do
(( j = i + start_pos - 1 )) (( j = i + start_pos - 1 ))
(( k = j + 1 )) (( k = j + 1 ))
case "$arg[$i]" in case "$arg[$i]" in
"'") break;; "'") break;;
"\\") style=back-dollar-quoted-argument "\\") style=back-dollar-quoted-argument
for (( c = i + 1 ; c <= $#arg ; c += 1 )); do for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do
[[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
done done
AA=$arg[$i+1,$c-1] AA=$arg[$i+1,$c-1]
@@ -1385,7 +1294,7 @@ _zsh_highlight_main_highlighter_highlight_backtick()
last=$(( arg1 + 1 )) last=$(( arg1 + 1 ))
# Remove one layer of backslashes and find the end # Remove one layer of backslashes and find the end
while i=$arg[(ib:i+1:)[\\\\\`]]; do # find the next \ or ` while i=$arg[(ib:i+1:)[\\\\\`]]; do # find the next \ or `
if (( i > $#arg )); then if (( i > end_pos - start_pos )); then
buf=$buf$arg[last,i] buf=$buf$arg[last,i]
offsets[i-arg1-offset]='' # So we never index past the end offsets[i-arg1-offset]='' # So we never index past the end
(( i-- )) (( i-- ))
@@ -1469,4 +1378,4 @@ else
# Make sure the cache is unset # Make sure the cache is unset
unset _zsh_highlight_main__command_type_cache unset _zsh_highlight_main__command_type_cache
fi fi
typeset -ga ZSH_HIGHLIGHT_DIRS_BLACKLIST typeset -ga X_ZSH_HIGHLIGHT_DIRS_BLACKLIST

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'/'
expected_region_highlight=(
'1 1 path' # /
)

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'/bi'
expected_region_highlight=(
'1 3 path_prefix' # /bi
)

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'/bin'
expected_region_highlight=(
'1 4 path' # /bin
)

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'/bin/s'
expected_region_highlight=(
'1 6 path_prefix' # /bin/s
)

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'/bin/sh'
expected_region_highlight=(
'1 7 command' # /bin/sh
)

View File

@@ -1,35 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2015 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias foo="echo hello world"
BUFFER="foo"
expected_region_highlight+=(
"1 3 alias" # foo
)

View File

@@ -1,37 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Alias must be at least 4 characters to test the regression
# cf. 139ea2b189819c43cc251825981c116959b15cc3
alias foobar='echo "$(echo foobar)"'
BUFFER='foobar'
expected_region_highlight=(
"1 6 alias" # foobar
)

View File

@@ -1,36 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias" # ls
)

View File

@@ -1,36 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls=tmp tmp='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias" # ls
)

View File

@@ -1,35 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2015 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls="ls"
BUFFER="ls"
expected_region_highlight+=(
"1 2 alias" # ls
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias '$foo'='echo alias'
local foo; foo=(echo param)
BUFFER='$foo'
expected_region_highlight=(
'1 4 alias' # $foo
)

View File

@@ -28,7 +28,6 @@
# vim: ft=zsh sw=2 ts=2 et # vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# See also param-precommand-option-argument1.zsh
alias sudo_u='sudo -u' alias sudo_u='sudo -u'
sudo(){} sudo(){}

View File

@@ -28,7 +28,6 @@
# vim: ft=zsh sw=2 ts=2 et # vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# See also param-precommand-option-argument3.zsh
alias sudo_u='sudo -u' alias sudo_u='sudo -u'
sudo(){} sudo(){}

View File

@@ -32,5 +32,5 @@ alias x=/
BUFFER=$'x' BUFFER=$'x'
expected_region_highlight=( expected_region_highlight=(
'1 1 unknown-token "issue #668"' # x (/) '1 1 unknown-token "issue #202"' # x (/)
) )

View File

@@ -1,37 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'s="foo\'bar"'
expected_region_highlight=(
'1 11 assign' # s="foo'bar"
'3 11 default' # "foo'bar"
'3 11 double-quoted-argument' # "foo'bar"
)

View File

@@ -1,37 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'s="foo \'\' bar"'
expected_region_highlight=(
'1 14 assign' # s="foo '' bar"
'3 14 default' # "foo '' bar"
'3 14 double-quoted-argument' # "foo '' bar"
)

View File

@@ -1,37 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'1="foo"'
expected_region_highlight=(
'1 7 assign' # 1="foo"
'3 7 default' # "foo"
'3 7 double-quoted-argument' # "foo"
)

View File

@@ -1,34 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'\\'
expected_region_highlight=(
'1 1 unknown-token' # \\
)

View File

@@ -1,44 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Test elision of some, but not all of the words
# See issue #667 for the case of eliding all words
local -a x; x=(sudo "")
sudo(){}
BUFFER=$'$x -u phy1729 ls'
expected_region_highlight=(
'1 2 precommand' # $x
# The "" is elided. If it weren't elided, the «ls» would be highlighted as an ordinary argument.
'4 5 single-hyphen-option' # -u
'7 13 default' # phy1729
'15 16 command' # ls
)

View File

@@ -30,7 +30,7 @@
mkdir foo mkdir foo
touch foo/bar touch foo/bar
BUFFER=": foo/bar $PWD/foo foo/b" BUFFER=": foo/bar $PWD/foo foo/b"
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar) X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
expected_region_highlight=( expected_region_highlight=(
'1 1 builtin' # : '1 1 builtin' # :

View File

@@ -28,12 +28,10 @@
# vim: ft=zsh sw=2 ts=2 et # vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Newline after semicolon isn't unknown-token BUFFER=$':;\n'
BUFFER=$':;\n:'
expected_region_highlight=( expected_region_highlight=(
'1 1 builtin' # : '1 1 builtin' # :
'2 2 commandseparator' # ; '2 2 commandseparator' # ;
'3 3 commandseparator "issue #616"' # \n '3 3 issue-623 "issue #616"' # \n
'4 4 builtin' # :
) )

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'exec >/dev/null;'
expected_region_highlight=(
'1 4 precommand' # exec
'6 6 redirection' # >
'7 15 path' # /dev/null
'16 16 commandseparator "issue #676"' # ;
)

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# See also alias-precommand-option-argument1.zsh
local -a sudo_u; sudo_u=(sudo -u)
sudo(){}
BUFFER='$sudo_u phy1729 echo foo'
expected_region_highlight=(
'1 7 precommand' # $sudo_u
'9 15 default' # phy1729
'18 20 command "issue #540"' # echo (not builtin)
'22 24 default' # foo
)

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# See also alias-precommand-option-argument3.zsh
local -a sudo_u; sudo_u=(sudo -u)
sudo(){}
BUFFER='$sudo_u phy1729 ls foo'
expected_region_highlight=(
'1 7 precommand' # sudo_u
'9 15 default' # phy1729
'17 18 command' # ls
'20 22 default' # foo
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
local x="()"
BUFFER=$'$x ls'
expected_region_highlight=(
'1 2 unknown-token' # $x
'4 5 command' # ls
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
local x="^foo^bar"
BUFFER=$'$x ls'
expected_region_highlight=(
'1 2 unknown-token' # $x
'4 5 default' # ls
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
local foobar='x=$(ls)'
BUFFER=$'$foobar'
expected_region_highlight=(
# Used to highlight the "ba" as 'command' because the 'ls' showed through; issues #670 and #674
'1 7 unknown-token' # $foobar (not an assignment)
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
local y='x=$(ls)'
BUFFER=$'$y'
expected_region_highlight=(
# Used to trigger a "BUG" message on stderr - issues #670 and #674
'1 2 unknown-token' # $y (not an assignment)
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2013 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$': \'foo\'bar"baz"'
expected_region_highlight=(
'1 1 builtin' # :
'3 15 default' # \'foo\'bar"baz"
'3 7 single-quoted-argument' # \'foo\'
'11 15 double-quoted-argument' # "baz"
)

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
hash sudo=false
BUFFER='sudo -e /etc/passwd'
expected_region_highlight=(
'1 4 precommand' # sudo
'6 7 single-hyphen-option' # -e
'9 19 path' # /etc/passwd
)

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
hash sudo=false
BUFFER='sudo -e /does/not/exist'
expected_region_highlight=(
'1 4 precommand' # sudo
'6 7 single-hyphen-option' # -e
'9 23 normal "issue #678"' # /does/not/exist
)

View File

@@ -38,6 +38,6 @@ expected_region_highlight=(
'10 11 command' # ls '10 11 command' # ls
'12 12 commandseparator' # ; '12 12 commandseparator' # ;
'14 17 precommand' # sudo '14 17 precommand' # sudo
'19 20 single-hyphen-option' # -x '19 20 unknown-token' # -x
'22 23 command' # ls '22 23 command' # ls
) )

View File

@@ -1,46 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2017, 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'< <(pwd) > >(nl)'
expected_region_highlight=(
'1 1 redirection' # <
'3 8 default' # <(pwd)
'3 8 process-substitution' # <(pwd)
'3 4 process-substitution-delimiter' # <(
'5 7 builtin' # pwd
'8 8 process-substitution-delimiter' # )
'10 10 redirection' # >
'12 16 default' # >(nl)
'12 16 process-substitution' # >(nl)
'12 13 process-substitution-delimiter' # >(
'14 15 command' # nl
'16 16 process-substitution-delimiter' # )
)

View File

@@ -1,37 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'">" foo ls'
expected_region_highlight=(
'1 3 unknown-token' # ">" - not "redirection"
'5 7 default' # foo
'9 10 default' # ls - not "command"
)

View File

@@ -1,38 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$': > -x >> --yy'
expected_region_highlight=(
'1 1 builtin' # :
'3 3 redirection' # >
'5 6 default' # -x
'8 9 redirection' # >>
'11 14 default' # --yy
)

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
hash sudo='false'
BUFFER='sudo --askpass ls'
expected_region_highlight=(
'1 4 precommand' # sudo
'6 14 double-hyphen-option' # --askpass
'16 17 command' # ls (we don't know whether --askpass takes an argument)
)

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'time ls; nocorrect ls'
expected_region_highlight=(
'1 4 reserved-word' # time
'6 7 command' # ls
'8 8 commandseparator' # ;
'10 18 reserved-word' # nocorrect
'20 21 command' # ls
)

View File

@@ -1,40 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'time ls; nocorrect ls'
alias time=':' nocorrect=':'
expected_region_highlight=(
'1 4 alias' # time
'6 7 default' # ls
'8 8 commandseparator' # ;
'10 18 alias' # nocorrect
'20 21 default' # ls
)

View File

@@ -28,9 +28,6 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[root]:=standout}
# Whether the root highlighter should be called or not. # Whether the root highlighter should be called or not.
_zsh_highlight_highlighter_root_predicate() _zsh_highlight_highlighter_root_predicate()
{ {

View File

@@ -5,13 +5,11 @@
- Check open issues and outstanding pull requests - Check open issues and outstanding pull requests
- Confirm `make test` passes - Confirm `make test` passes
- check with multiple zsh versions - check with multiple zsh versions
(easiest to check travis: https://travis-ci.org/zsh-users/zsh-syntax-highlighting/)
- Update changelog.md - Update changelog.md
`tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master` `tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master`
- Make sure there are no local commits and that `git status` is clean; - Remove `-dev` suffix from `./.version`;
Remove `-dev` suffix from `./.version`;
Commit that using `git commit -m "Tag version $(<.version)." .version`; Commit that using `git commit -m "Tag version $(<.version)." .version`;
Tag it using `git tag -s -m "Tag version $(<.version)" $(<.version)`; Tag it using `git tag -m "Tag version $(<.version)"`;
Increment `./.version` and restore the `-dev` suffix; Increment `./.version` and restore the `-dev` suffix;
Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`. Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`.
- Push with `git push && git push --tags` - Push with `git push && git push --tags`

View File

@@ -1,40 +0,0 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
type perl sponge >/dev/null || { print -ru2 -- "$0: This script requires perl(1) and sponge(1) [from moreutils]"; exit 1; }
local editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" )
() {
> "$2" perl -nE '$highlighter = $1 if /^Running test (\S*)/; say "highlighters/${highlighter}/test-data/$1.zsh" if /^# (\S*)/' "$1"
>>"$2" echo ""
>>"$2" cat <"$1"
"${editor[@]}" -- "$2"
} =(${MAKE:-make} quiet-test) =(:)
# TODO: tee(1) the quiet-test output to /dev/tty as it's happening, with colors.

View File

@@ -32,17 +32,16 @@ emulate -LR zsh
setopt localoptions extendedglob setopt localoptions extendedglob
# Argument parsing. # Argument parsing.
if (( $# * $# - 7 * $# + 12 )) || [[ $1 == -* ]]; then if (( $# != 3 )) || [[ $1 == -* ]]; then
print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME [PREAMBLE]" print -r -- >&2 "$0: usage: $0 BUFFER HIGHLIGHTER BASENAME"
print -r -- >&2 "" print -r -- >&2 ""
print -r -- >&2 "Generate highlighters/HIGHLIGHTER/test-data/BASENAME.zsh based on the" print -r -- >&2 "Generate highlighters/HIGHLIGHTER/test-data/BASENAME.zsh based on the"
print -r -- >&2 "current highlighting of BUFFER, using the setup code PREAMBLE." print -r -- >&2 "current highlighting of BUFFER."
exit 1 exit 1
fi fi
buffer=$1 buffer=$1
ZSH_HIGHLIGHT_HIGHLIGHTERS=( $2 ) ZSH_HIGHLIGHT_HIGHLIGHTERS=( $2 )
fname=${0:A:h:h}/highlighters/$2/test-data/${3%.zsh}.zsh fname=${0:A:h:h}/highlighters/$2/test-data/${3%.zsh}.zsh
preamble=${4:-""}
# Load the main script. # Load the main script.
. ${0:A:h:h}/zsh-syntax-highlighting.zsh . ${0:A:h:h}/zsh-syntax-highlighting.zsh
@@ -56,18 +55,13 @@ _zsh_highlight_add_highlight()
# Copyright block # Copyright block
year="`LC_ALL=C date +%Y`" year="`LC_ALL=C date +%Y`"
if ! { read -q "?Set copyright year to $year? " } always { echo "" }; then if ! read -q "?Set copyright year to $year? "; then
year="YYYY" year="YYYY"
fi fi
<$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/" > $fname exec >$fname
<$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/"
# Assumes stdout is line-buffered # Assumes stdout is line-buffered
git add -- $fname git add -- $fname
exec > >(tee -a $fname)
# Preamble
if [[ -n $preamble ]]; then
print -rl -- "$preamble" ""
fi
# Buffer # Buffer
print -n 'BUFFER=' print -n 'BUFFER='
@@ -88,17 +82,8 @@ print 'expected_region_highlight=('
PREBUFFER="" PREBUFFER=""
BUFFER="$buffer" BUFFER="$buffer"
region_highlight=() region_highlight=()
eval $( # TODO: use run_test() from tests/test-highlighting.zsh (to get a tempdir)
exec 3>&1 >/dev/null _zsh_highlight
typeset -r __tests_tmpdir="$(mktemp -d)"
{
# Use a subshell to ensure $__tests_tmpdir, which is to be rm -rf'd, won't be modified.
(cd -- "$__tests_tmpdir" && eval $preamble && _zsh_highlight && typeset -p region_highlight >&3)
: # workaround zsh bug workers/45305 with respect to the $(…) subshell we're in
} always {
rm -rf -- ${__tests_tmpdir}
}
)
for ((i=1; i<=${#region_highlight}; i++)); do for ((i=1; i<=${#region_highlight}; i++)); do
local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} ) local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} )

View File

@@ -40,8 +40,6 @@ use strict;
undef $/; # slurp mode undef $/; # slurp mode
print for print for
grep { /^ok.*# TODO/m or /^not ok(?!.*# TODO)/m or /^Bail out!/m } grep { /^ok.*# TODO/m or /^not ok(?!.*# TODO)/m }
# Split on plan lines and remove them from the output. (To keep them, split /^(?=#)/m,
# use the lookahead syntax, «(?=…)», to make the match zero-length.)
split /^\d+\.\.\d+$/m,
<STDIN>; <STDIN>;

View File

@@ -93,13 +93,9 @@ ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
# In zsh<5.3, 'typeset -p arrayvar' emits two lines, so we use this wrapper instead. # In zsh<5.3, 'typeset -p arrayvar' emits two lines, so we use this wrapper instead.
typeset_p() { typeset_p() {
for 1 ; do for 1 ; do
if [[ ${(tP)1} == *array* ]]; then print -r -- "$1=( ${(@q-P)1} )"
print -r -- "$1=( ${(@q-P)1} )" done
else
print -r -- "$1=${(q-P)1}"
fi
done
} }
# Escape # as ♯ and newline as ↵ they are illegal in the 'description' part of TAP output # Escape # as ♯ and newline as ↵ they are illegal in the 'description' part of TAP output
@@ -117,11 +113,12 @@ run_test_internal() {
local srcdir="$PWD" local srcdir="$PWD"
builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! On ${(qq)1}: cd failed: $?"; return 1 } builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! On ${(qq)1}: cd failed: $?"; return 1 }
echo "# ${1:t:r}"
# Load the data and prepare checking it. # Load the data and prepare checking it.
local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET REPLY skip_test unsorted=0 local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET REPLY skip_test unsorted=0
local expected_mismatch local expected_mismatch
local -a expected_region_highlight region_highlight local -a expected_region_highlight region_highlight
. "$srcdir"/"$1" . "$srcdir"/"$1"
(( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; } (( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; }
@@ -142,12 +139,7 @@ run_test_internal() {
expected_region_highlight=("${(@n)expected_region_highlight}") expected_region_highlight=("${(@n)expected_region_highlight}")
fi fi
# Print the plan line, and some comments for human readers
echo "1..$(( $#expected_region_highlight + 1))" echo "1..$(( $#expected_region_highlight + 1))"
echo "## ${1:t:r}"
[[ -n $PREBUFFER ]] && printf '# %s\n' "$(typeset_p PREBUFFER)"
[[ -n $BUFFER ]] && printf '# %s\n' "$(typeset_p BUFFER)"
local i local i
for ((i=1; i<=$#expected_region_highlight; i++)); do for ((i=1; i<=$#expected_region_highlight; i++)); do
local -a expected_highlight_zone; expected_highlight_zone=( ${(z)expected_region_highlight[i]} ) local -a expected_highlight_zone; expected_highlight_zone=( ${(z)expected_region_highlight[i]} )
@@ -210,7 +202,7 @@ run_test() {
local ret=$pipestatus[1] stderr=$pipestatus[2] local ret=$pipestatus[1] stderr=$pipestatus[2]
if (( ! stderr )); then if (( ! stderr )); then
# stdout will become stderr # stdout will become stderr
echo "Bail out! On ${(qq)1}: output on stderr"; return 1 echo "Bail out! On ${(qq)1}: output on stderr"; return 1
else else
return $ret return $ret
fi fi

50
themes/default Normal file
View File

@@ -0,0 +1,50 @@
# brackets
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
# cursor
ZSH_HIGHLIGHT_STYLES[cursor]=standout
# line
ZSH_HIGHLIGHT_STYLES[line]=
# main
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=yellow
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[commandseparator]=none
ZSH_HIGHLIGHT_STYLES[path]=underline
ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue
ZSH_HIGHLIGHT_STYLES[command-substitution]=none
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[process-substitution]=none
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=none
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=cyan
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[assign]=none
ZSH_HIGHLIGHT_STYLES[redirection]=none
ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
ZSH_HIGHLIGHT_STYLES[named-fd]=none
ZSH_HIGHLIGHT_STYLES[arg0]=fg=green
# root
ZSH_HIGHLIGHT_STYLES[root]=standout

2
themes/error-only Normal file
View File

@@ -0,0 +1,2 @@
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold

View File

@@ -157,25 +157,24 @@ _zsh_highlight()
# Re-apply zle_highlight settings # Re-apply zle_highlight settings
# region # region
() { if (( REGION_ACTIVE == 1 )); then
(( REGION_ACTIVE )) || return _zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR"
integer min max elif (( REGION_ACTIVE == 2 )); then
if (( MARK > CURSOR )) ; then () {
min=$CURSOR max=$MARK
else
min=$MARK max=$CURSOR
fi
if (( REGION_ACTIVE == 1 )); then
[[ $KEYMAP = vicmd ]] && (( max++ ))
elif (( REGION_ACTIVE == 2 )); then
local needle=$'\n' local needle=$'\n'
integer min max
if (( MARK > CURSOR )) ; then
min=$CURSOR max=$MARK
else
min=$MARK max=$CURSOR
fi
# CURSOR and MARK are 0 indexed between letters like region_highlight # CURSOR and MARK are 0 indexed between letters like region_highlight
# Do not include the newline in the highlight # Do not include the newline in the highlight
(( min = ${BUFFER[(Ib:min:)$needle]} )) (( min = ${BUFFER[(Ib:min:)$needle]} ))
(( max = ${BUFFER[(ib:max:)$needle]} - 1 )) (( max = ${BUFFER[(ib:max:)$needle]} - 1 ))
fi _zsh_highlight_apply_zle_highlight region standout "$min" "$max"
_zsh_highlight_apply_zle_highlight region standout "$min" "$max" }
} fi
# yank / paste (zsh-5.1.1 and newer) # yank / paste (zsh-5.1.1 and newer)
(( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END" (( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END"
@@ -400,6 +399,24 @@ _zsh_highlight_load_highlighters()
} }
# Load theme
# $1 should be a theme defined in themes/ or an absolute path
_zsh_highlight_load_theme()
{
local theme=$1
shift 1
if [[ ${theme[1]} == / ]]; then
source $theme
elif [[ $theme == */* ]]; then
print -r -- >&2 "zsh-syntax-highlighting: failed on invalid theme name: ${(qq)theme}"
return 1
else
for theme in ${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:h}/themes/$theme(N) $ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR/$^ZSH_HIGHLIGHT_HIGHLIGHTERS/$theme(N); do
source $theme
done
fi
}
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Setup # Setup
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
@@ -411,7 +428,7 @@ _zsh_highlight_bind_widgets || {
} }
# Resolve highlighters directory location. # Resolve highlighters directory location.
_zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || { _zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:=${${0:A}:h}/highlighters}" || {
print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.' print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.'
return 1 return 1
} }
@@ -433,11 +450,8 @@ zmodload zsh/parameter 2>/dev/null || true
# Initialize the array of active highlighters if needed. # 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=(main)
if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then # Load the theme.
print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.' _zsh_highlight_load_theme "${ZSH_HIGHLIGHT_THEME-default}"
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
fi
# Restore the aliases we unned # Restore the aliases we unned
eval "$zsh_highlight__aliases" eval "$zsh_highlight__aliases"