Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc26731555 | ||
|
|
411864d35b | ||
|
|
d1666463a7 | ||
|
|
dea1fedc73 | ||
|
|
b56ee542d6 | ||
|
|
3c43da5ffe | ||
|
|
f2ba507bbc | ||
|
|
28e661bbc8 | ||
|
|
39a6c476dd | ||
|
|
5feed23962 | ||
|
|
ad522a0914 | ||
|
|
462779629a | ||
|
|
73cb832702 | ||
|
|
be083d7f37 | ||
|
|
237f89ad62 | ||
|
|
835fec7f3c | ||
|
|
9523d6d49c | ||
|
|
aac4a44238 | ||
|
|
4f49c4a35f | ||
|
|
b8fa1b9dc9 | ||
|
|
5efd062a4d | ||
|
|
67be62107b | ||
|
|
74949c2d91 | ||
|
|
8d5afe47f7 | ||
|
|
76ea9e1df3 | ||
|
|
50fbb5f76e | ||
|
|
2dce602727 | ||
|
|
9396ad5c5f | ||
|
|
347cf0eb06 | ||
|
|
5625e30b87 | ||
|
|
fed37a90ac | ||
|
|
626c034c68 | ||
|
|
3d74aa47e4 | ||
|
|
5398949cb3 |
16
INSTALL.md
16
INSTALL.md
@@ -4,17 +4,25 @@ How to install
|
|||||||
### Using packages
|
### Using packages
|
||||||
|
|
||||||
* 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]
|
* 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])
|
||||||
|
* 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]
|
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
|
||||||
|
* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
||||||
|
* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
||||||
|
|
||||||
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
|
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
|
||||||
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
|
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
|
||||||
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
|
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
|
||||||
|
[freebsd-port]: http://www.freshports.org/textproc/zsh-syntax-highlighting/
|
||||||
[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting
|
[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting
|
||||||
[brew-package]: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh-syntax-highlighting.rb
|
[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-syntax-highlighting.rb
|
||||||
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
|
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
|
||||||
|
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
|
||||||
|
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
|
||||||
|
[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
|
||||||
|
|
||||||
|
|
||||||
### In your ~/.zshrc
|
### In your ~/.zshrc
|
||||||
@@ -78,7 +86,7 @@ Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
|
|||||||
|
|
||||||
#### [zplug](https://github.com/zplug/zplug)
|
#### [zplug](https://github.com/zplug/zplug)
|
||||||
|
|
||||||
Add `zplug "zsh-users/zsh-syntax-highlighting", nice:10` to your `.zshrc`.
|
Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`.
|
||||||
|
|
||||||
#### [zplugin](https://github.com/psprint/zplugin)
|
#### [zplugin](https://github.com/psprint/zplugin)
|
||||||
|
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -46,20 +46,19 @@ syntax highlighting.
|
|||||||
|
|
||||||
### Does syntax highlighting work during incremental history search?
|
### Does syntax highlighting work during incremental history search?
|
||||||
|
|
||||||
Highlighting the command line during an incremental history search
|
Highlighting the command line during an incremental history search (by default bound to
|
||||||
(with the `history-incremental-search-backward` widget, which is
|
to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.4 or newer.
|
||||||
bound by default to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.3
|
|
||||||
or newer.
|
|
||||||
|
|
||||||
Under zsh 5.2 and older, the zsh-default [underlining][zshzle-Character-Highlighting]
|
Under zsh versions older than 5.4, the zsh-default [underlining][zshzle-Character-Highlighting]
|
||||||
of the matched portion of the buffer remains available, but zsh-syntax-highlighting's
|
of the matched portion of the buffer remains available, but zsh-syntax-highlighting's
|
||||||
additional highlighting is unavailable. (Those versions of zsh do not provide
|
additional highlighting is unavailable. (Those versions of zsh do not provide
|
||||||
enough information to allow computing the highlighting correctly.)
|
enough information to allow computing the highlighting correctly.)
|
||||||
|
|
||||||
See [issue #288][i288] for details.
|
See issues [#288][i288] and [#415][i415] for details.
|
||||||
|
|
||||||
[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
|
||||||
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
|
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
|
||||||
|
[i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415
|
||||||
|
|
||||||
### How are new releases announced?
|
### How are new releases announced?
|
||||||
|
|
||||||
|
|||||||
74
changelog.md
74
changelog.md
@@ -1,3 +1,77 @@
|
|||||||
|
# Changes in version 0.6.0
|
||||||
|
|
||||||
|
This is a stable release, featuring bugfixes and minor improvements.
|
||||||
|
|
||||||
|
|
||||||
|
## Performance improvements:
|
||||||
|
|
||||||
|
(none)
|
||||||
|
|
||||||
|
|
||||||
|
## Added highlighting of:
|
||||||
|
|
||||||
|
- The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting].
|
||||||
|
(79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support)
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|
||||||
|
- Possible history expansions in double-quoted strings.
|
||||||
|
(76ea9e1df316)
|
||||||
|
|
||||||
|
- Mismatched `if`/`then`/`elif`/`else`/`fi`.
|
||||||
|
(73cb83270262)
|
||||||
|
|
||||||
|
|
||||||
|
## Fixed highlighting of:
|
||||||
|
|
||||||
|
- A comment line followed by a non-comment line.
|
||||||
|
(#385, 9396ad5c5f9c)
|
||||||
|
|
||||||
|
- An unquoted `$*` (expands to the positional parameters).
|
||||||
|
(237f89ad629f)
|
||||||
|
|
||||||
|
- history-incremental-pattern-search-backward under zsh 5.3.1.
|
||||||
|
(#407, #415, 462779629a0c)
|
||||||
|
|
||||||
|
|
||||||
|
## API changes (for highlighter authors):
|
||||||
|
|
||||||
|
(none)
|
||||||
|
|
||||||
|
|
||||||
|
## Developer-visible changes:
|
||||||
|
|
||||||
|
- tests: Set the `ALIAS_FUNC_DEF` option for zsh 5.4 compatibility.
|
||||||
|
(9523d6d49cb3)
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes:
|
||||||
|
|
||||||
|
- docs: Added before/after screenshots.
|
||||||
|
(cd9ec14a65ec..b7e277106b49)
|
||||||
|
|
||||||
|
- docs: Link Fedora package.
|
||||||
|
(3d74aa47e4a7, 5feed23962df)
|
||||||
|
|
||||||
|
- docs: Link FreeBSD port.
|
||||||
|
(626c034c68d7)
|
||||||
|
|
||||||
|
- docs: Link OpenSUSE Build Service packages
|
||||||
|
(#419, dea1fedc7358)
|
||||||
|
|
||||||
|
- Prevent user-defined aliases from taking effect in z-sy-h's own code.
|
||||||
|
(#390, 2dce602727d7, 8d5afe47f774; and #392, #395, b8fa1b9dc954)
|
||||||
|
|
||||||
|
- docs: Update zplug installation instructions.
|
||||||
|
(#399, 4f49c4a35f17)
|
||||||
|
|
||||||
|
- Improve "unhandled ZLE widget 'foo'" error message.
|
||||||
|
(#409, be083d7f3710)
|
||||||
|
|
||||||
|
- Fix printing of "failed loading highlighters" error message.
|
||||||
|
(#426, ad522a091429)
|
||||||
|
|
||||||
|
|
||||||
# Changes in version 0.5.0
|
# Changes in version 0.5.0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ _zsh_highlight_main__type() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ! (( $+REPLY )); then
|
if ! (( $+REPLY )); then
|
||||||
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }"
|
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
|
||||||
fi
|
fi
|
||||||
if (( $+_zsh_highlight_main__command_type_cache )); then
|
if (( $+_zsh_highlight_main__command_type_cache )); then
|
||||||
_zsh_highlight_main__command_type_cache[(e)$1]=$REPLY
|
_zsh_highlight_main__command_type_cache[(e)$1]=$REPLY
|
||||||
@@ -241,6 +241,8 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
# "Y" for curly
|
# "Y" for curly
|
||||||
# "D" for do/done
|
# "D" for do/done
|
||||||
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
||||||
|
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
|
||||||
|
# ":" for 'then'
|
||||||
local braces_stack
|
local braces_stack
|
||||||
|
|
||||||
if (( path_dirs_was_set )); then
|
if (( path_dirs_was_set )); then
|
||||||
@@ -418,6 +420,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
fi
|
fi
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
already_added=1
|
already_added=1
|
||||||
|
start_pos=$end_pos
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -508,6 +511,29 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
('done')
|
('done')
|
||||||
_zsh_highlight_main__stack_pop 'D' style=reserved-word
|
_zsh_highlight_main__stack_pop 'D' style=reserved-word
|
||||||
;;
|
;;
|
||||||
|
('if')
|
||||||
|
braces_stack=':?'"$braces_stack"
|
||||||
|
;;
|
||||||
|
('then')
|
||||||
|
_zsh_highlight_main__stack_pop ':' style=reserved-word
|
||||||
|
;;
|
||||||
|
('elif')
|
||||||
|
if [[ ${braces_stack[1]} == '?' ]]; then
|
||||||
|
braces_stack=':'"$braces_stack"
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
('else')
|
||||||
|
if [[ ${braces_stack[1]} == '?' ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
('fi')
|
||||||
|
_zsh_highlight_main__stack_pop '?' ""
|
||||||
|
;;
|
||||||
('foreach')
|
('foreach')
|
||||||
braces_stack='$'"$braces_stack"
|
braces_stack='$'"$braces_stack"
|
||||||
;;
|
;;
|
||||||
@@ -657,6 +683,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
already_added=1
|
already_added=1
|
||||||
;;
|
;;
|
||||||
'`'*) style=back-quoted-argument;;
|
'`'*) style=back-quoted-argument;;
|
||||||
|
[$][*]) style=default;;
|
||||||
[*?]*|*[^\\][*?]*)
|
[*?]*|*[^\\][*?]*)
|
||||||
$highlight_glob && style=globbing || style=default;;
|
$highlight_glob && style=globbing || style=default;;
|
||||||
*) if false; then
|
*) if false; then
|
||||||
@@ -817,6 +844,13 @@ _zsh_highlight_main_highlighter_highlight_string()
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
($histchars[1]) # ! - may be a history expansion
|
||||||
|
if [[ $arg[i+1] != ('='|$'\x28'|$'\x7b'|[[:blank:]]) ]]; then
|
||||||
|
style=history-expansion
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*) continue ;;
|
*) continue ;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
alias alias1="unused expansion"
|
alias alias1="unused expansion"
|
||||||
alias -s alias2="echo"
|
alias -s alias2="echo"
|
||||||
|
if set -o | grep -q aliasfuncdef; then
|
||||||
|
setopt alias_func_def # 5.4+
|
||||||
|
fi
|
||||||
alias1() {} # to check that it's highlighted as an alias, not as a function
|
alias1() {} # to check that it's highlighted as an alias, not as a function
|
||||||
|
|
||||||
BUFFER='x.alias2; alias1'
|
BUFFER='x.alias2; alias1'
|
||||||
|
|||||||
35
highlighters/main/test-data/arg0-colon.zsh
Normal file
35
highlighters/main/test-data/arg0-colon.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 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: /'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 5 unknown-token' # \'x: /
|
||||||
|
)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 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='elif true; then echo two; fi'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 unknown-token' # elif
|
||||||
|
'6 9 builtin' # true
|
||||||
|
'10 10 commandseparator' # ;
|
||||||
|
'12 15 unknown-token' # then
|
||||||
|
'17 20 builtin' # echo
|
||||||
|
'22 24 default' # two
|
||||||
|
'25 25 commandseparator' # ;
|
||||||
|
'27 28 unknown-token' # fi
|
||||||
|
)
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 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='if false; then echo one; elif true; then echo two; else echo three; fi'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # if
|
||||||
|
'4 8 builtin' # false
|
||||||
|
'9 9 commandseparator' # ;
|
||||||
|
'11 14 reserved-word' # then
|
||||||
|
'16 19 builtin' # echo
|
||||||
|
'21 23 default' # one
|
||||||
|
'24 24 commandseparator' # ;
|
||||||
|
'26 29 reserved-word' # elif
|
||||||
|
'31 34 builtin' # true
|
||||||
|
'35 35 commandseparator' # ;
|
||||||
|
'37 40 reserved-word' # then
|
||||||
|
'42 45 builtin' # echo
|
||||||
|
'47 49 default' # two
|
||||||
|
'50 50 commandseparator' # ;
|
||||||
|
'52 55 reserved-word' # else
|
||||||
|
'57 60 builtin' # echo
|
||||||
|
'62 66 default' # three
|
||||||
|
'67 67 commandseparator' # ;
|
||||||
|
'69 70 reserved-word' # fi
|
||||||
|
)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 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='if false; then echo one; fi'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # if
|
||||||
|
'4 8 builtin' # false
|
||||||
|
'9 9 commandseparator' # ;
|
||||||
|
'11 14 reserved-word' # then
|
||||||
|
'16 19 builtin' # echo
|
||||||
|
'21 23 default' # one
|
||||||
|
'24 24 commandseparator' # ;
|
||||||
|
'26 27 reserved-word' # fi
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/comment-followed.zsh
Normal file
39
highlighters/main/test-data/comment-followed.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt interactivecomments
|
||||||
|
BUFFER=$'# foo\ntrue'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 5 comment' # #
|
||||||
|
#'6 6 '"' # \n
|
||||||
|
|
||||||
|
'7 10 builtin' # true
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/history-double-quoted-no.zsh
Normal file
36
highlighters/main/test-data/history-double-quoted-no.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 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='echo "foo != bar !{baz}"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 24 double-quoted-argument' # "foo != bar !{baz}" - no history expansions
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 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='echo "Hello!"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 11 double-quoted-argument' # "Hello
|
||||||
|
'12 12 history-expansion' # !
|
||||||
|
'13 13 double-quoted-argument' # "
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/history-double-quoted-yes.zsh
Normal file
38
highlighters/main/test-data/history-double-quoted-yes.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 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='echo "foo !bar"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 10 double-quoted-argument' # "foo
|
||||||
|
'11 11 history-expansion' # !
|
||||||
|
'12 15 double-quoted-argument' # bar"
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/parameter-star.zsh
Normal file
36
highlighters/main/test-data/parameter-star.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 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='() { : $* }'
|
||||||
|
|
||||||
|
# This tests that $* isn't highlighted as a glob.
|
||||||
|
# If we ever add a "unquoted parameter" style, the expectation may change.
|
||||||
|
expected_region_highlight=(
|
||||||
|
"8 9 default" # $*
|
||||||
|
)
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
- 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`
|
||||||
- Remove `-dev` suffix from `./.version`;
|
- Remove `-dev` suffix from `./.version`;
|
||||||
Commit that using 'git commit -m "Tag version $(<.version).";
|
Commit that using `git commit -m "Tag version $(<.version)."`;
|
||||||
Tag it using `git tag $(<.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'.
|
Commit that using 'git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5'.
|
||||||
- Push with `git push --tags`
|
- Push with `git push --tags`
|
||||||
|
|||||||
@@ -47,8 +47,33 @@
|
|||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set up results_filter
|
||||||
|
local results_filter
|
||||||
|
if [[ $QUIET == y ]]; then
|
||||||
|
if type -w perl >/dev/null; then
|
||||||
|
results_filter=${0:A:h}/tap-filter
|
||||||
|
else
|
||||||
|
echo >&2 "Bail out! quiet mode not supported: perl not found"; exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
results_filter=cat
|
||||||
|
fi
|
||||||
|
[[ -n $results_filter ]] || { echo >&2 "Bail out! BUG setting \$results_filter"; exit 2 }
|
||||||
|
|
||||||
# Load the main script.
|
# Load the main script.
|
||||||
|
# While here, test that it doesn't eat aliases.
|
||||||
|
print > >($results_filter | ${0:A:h}/tap-colorizer.zsh) -r -- "# global (driver) tests"
|
||||||
|
print > >($results_filter | ${0:A:h}/tap-colorizer.zsh) -r -- "1..1"
|
||||||
|
alias -- +plus=plus
|
||||||
|
alias -- _other=other
|
||||||
|
original_alias_dash_L_output="$(alias -L)"
|
||||||
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
||||||
|
if [[ $original_alias_dash_L_output == $(alias -L) ]]; then
|
||||||
|
print -r -- "ok 1 # 'alias -- +foo=bar' is preserved"
|
||||||
|
else
|
||||||
|
print -r -- "not ok 1 # 'alias -- +foo=bar' is preserved"
|
||||||
|
exit 1
|
||||||
|
fi > >($results_filter | ${0:A:h}/tap-colorizer.zsh)
|
||||||
|
|
||||||
# Overwrite _zsh_highlight_add_highlight so we get the key itself instead of the style
|
# Overwrite _zsh_highlight_add_highlight so we get the key itself instead of the style
|
||||||
_zsh_highlight_add_highlight()
|
_zsh_highlight_add_highlight()
|
||||||
@@ -157,19 +182,6 @@ run_test() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set up results_filter
|
|
||||||
local results_filter
|
|
||||||
if [[ $QUIET == y ]]; then
|
|
||||||
if type -w perl >/dev/null; then
|
|
||||||
results_filter=${0:A:h}/tap-filter
|
|
||||||
else
|
|
||||||
echo >&2 "Bail out! quiet mode not supported: perl not found"; exit 2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
results_filter=cat
|
|
||||||
fi
|
|
||||||
[[ -n $results_filter ]] || { echo >&2 "Bail out! BUG setting \$results_filter"; exit 2 }
|
|
||||||
|
|
||||||
# Process each test data file in test data directory.
|
# Process each test data file in test data directory.
|
||||||
integer something_failed=0
|
integer something_failed=0
|
||||||
ZSH_HIGHLIGHT_STYLES=()
|
ZSH_HIGHLIGHT_STYLES=()
|
||||||
|
|||||||
@@ -27,6 +27,13 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# First of all, ensure predictable parsing.
|
||||||
|
zsh_highlight__aliases=`builtin alias -Lm '[^+]*'`
|
||||||
|
# In zsh <= 5.2, `alias -L` emits aliases that begin with a plus sign ('alias -- +foo=42')
|
||||||
|
# them without a '--' guard, so they don't round trip.
|
||||||
|
#
|
||||||
|
# Hence, we exclude them from unaliasing:
|
||||||
|
builtin unalias -m '[^+]*'
|
||||||
|
|
||||||
# Set $0 to the expected value, regardless of functionargzero.
|
# Set $0 to the expected value, regardless of functionargzero.
|
||||||
0=${(%):-%N}
|
0=${(%):-%N}
|
||||||
@@ -46,6 +53,15 @@ fi
|
|||||||
# Core highlighting update system
|
# Core highlighting update system
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Use workaround for bug in ZSH?
|
||||||
|
# zsh-users/zsh@48cadf4 http://www.zsh.org/mla/workers//2017/msg00034.html
|
||||||
|
autoload -U is-at-least
|
||||||
|
if is-at-least 5.4; then
|
||||||
|
zsh_highlight__pat_static_bug=false
|
||||||
|
else
|
||||||
|
zsh_highlight__pat_static_bug=true
|
||||||
|
fi
|
||||||
|
|
||||||
# Array declaring active highlighters names.
|
# Array declaring active highlighters names.
|
||||||
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
|
typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
|
||||||
|
|
||||||
@@ -60,7 +76,9 @@ _zsh_highlight()
|
|||||||
|
|
||||||
# Remove all highlighting in isearch, so that only the underlining done by zsh itself remains.
|
# Remove all highlighting in isearch, so that only the underlining done by zsh itself remains.
|
||||||
# For details see FAQ entry 'Why does syntax highlighting not work while searching history?'.
|
# For details see FAQ entry 'Why does syntax highlighting not work while searching history?'.
|
||||||
if [[ $WIDGET == zle-isearch-update ]]; then
|
# This disables highlighting during isearch (for reasons explained in README.md) unless zsh is new enough
|
||||||
|
# and doesn't have the pattern matching bug
|
||||||
|
if [[ $WIDGET == zle-isearch-update ]] && { $zsh_highlight__pat_static_bug || ! (( $+ISEARCHMATCH_ACTIVE )) }; then
|
||||||
region_highlight=()
|
region_highlight=()
|
||||||
return $ret
|
return $ret
|
||||||
fi
|
fi
|
||||||
@@ -142,6 +160,12 @@ _zsh_highlight()
|
|||||||
# 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"
|
||||||
|
|
||||||
|
# isearch
|
||||||
|
(( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END"
|
||||||
|
|
||||||
|
# suffix
|
||||||
|
(( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END"
|
||||||
|
|
||||||
|
|
||||||
return $ret
|
return $ret
|
||||||
|
|
||||||
@@ -304,6 +328,7 @@ _zsh_highlight_bind_widgets()
|
|||||||
else
|
else
|
||||||
# Default: unhandled case.
|
# Default: unhandled case.
|
||||||
print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}"
|
print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}"
|
||||||
|
print -r -- >&2 "zsh-syntax-highlighting: (This is sometimes caused by doing \`bindkey <keys> ${(q-)cur_widget}\` without creating the ${(qq)cur_widget} widget with \`zle -N\` or \`zle -C\`.)"
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -327,8 +352,8 @@ _zsh_highlight_load_highlighters()
|
|||||||
local highlighter highlighter_dir
|
local highlighter highlighter_dir
|
||||||
for highlighter_dir ($1/*/); do
|
for highlighter_dir ($1/*/); do
|
||||||
highlighter="${highlighter_dir:t}"
|
highlighter="${highlighter_dir:t}"
|
||||||
[[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] &&
|
[[ -f "$highlighter_dir${highlighter}-highlighter.zsh" ]] &&
|
||||||
. "$highlighter_dir/${highlighter}-highlighter.zsh"
|
. "$highlighter_dir${highlighter}-highlighter.zsh"
|
||||||
if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null &&
|
if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null &&
|
||||||
type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null;
|
type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null;
|
||||||
then
|
then
|
||||||
@@ -345,7 +370,7 @@ _zsh_highlight_load_highlighters()
|
|||||||
eval "_zsh_highlight_highlighter_${(q)highlighter}_paint() { _zsh_highlight_${(q)highlighter}_highlighter \"\$@\" }"
|
eval "_zsh_highlight_highlighter_${(q)highlighter}_paint() { _zsh_highlight_${(q)highlighter}_highlighter \"\$@\" }"
|
||||||
eval "_zsh_highlight_highlighter_${(q)highlighter}_predicate() { _zsh_highlight_${(q)highlighter}_highlighter_predicate \"\$@\" }"
|
eval "_zsh_highlight_highlighter_${(q)highlighter}_predicate() { _zsh_highlight_${(q)highlighter}_highlighter_predicate \"\$@\" }"
|
||||||
else
|
else
|
||||||
print -r -- >&2 "zsh-syntax-highlighting: ${(qq)highlighter} highlighter should define both required functions '_zsh_highlight_highlighter_${highlighter}_paint' and '_zsh_highlight_highlighter_${highlighter}_predicate' in ${(qq):-"$highlighter_dir/${highlighter}-highlighter.zsh"}."
|
print -r -- >&2 "zsh-syntax-highlighting: ${(qq)highlighter} highlighter should define both required functions '_zsh_highlight_highlighter_${highlighter}_paint' and '_zsh_highlight_highlighter_${highlighter}_predicate' in ${(qq):-"$highlighter_dir${highlighter}-highlighter.zsh"}."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -363,7 +388,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 -- >&@ 'zsh-syntax-highlighting: failed loading highlighters, exiting.'
|
print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.'
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +406,12 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
|
|||||||
# Load zsh/parameter module if available
|
# Load zsh/parameter module if available
|
||||||
zmodload zsh/parameter 2>/dev/null || true
|
zmodload zsh/parameter 2>/dev/null || true
|
||||||
|
|
||||||
autoload -U is-at-least
|
|
||||||
|
|
||||||
# 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) || true
|
[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
|
||||||
|
|
||||||
|
# Restore the aliases we unned
|
||||||
|
eval "$zsh_highlight__aliases"
|
||||||
|
builtin unset zsh_highlight__aliases
|
||||||
|
|
||||||
|
# Set $?.
|
||||||
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user