Update syntax hilighting plugin
authorJoerg Jaspert <joerg@debian.org>
Wed, 15 Nov 2017 08:33:40 +0000 (09:33 +0100)
committerJoerg Jaspert <joerg@debian.org>
Wed, 15 Nov 2017 08:33:40 +0000 (09:33 +0100)
56 files changed:
.zsh/zsh-syntax-highlighting/.gitattributes [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/.gitignore
.zsh/zsh-syntax-highlighting/.travis.yml [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/.version
.zsh/zsh-syntax-highlighting/INSTALL.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/Makefile [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/README.md
.zsh/zsh-syntax-highlighting/changelog.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/brackets.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/cursor.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/line.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/main.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/pattern.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/docs/highlighters/root.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/brackets/README.md [changed from file to symlink]
.zsh/zsh-syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/only-error.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/cursor/README.md [changed from file to symlink]
.zsh/zsh-syntax-highlighting/highlighters/main/README.md [changed from file to symlink]
.zsh/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/commmand-parameter.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/function.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-no.zsh [moved from .zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-space- .zsh with 88% similarity]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-unescaped.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-yes.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/option-path_dirs.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/parameter-star.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-broken-symlink.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word2.zsh
.zsh/zsh-syntax-highlighting/highlighters/pattern/README.md [changed from file to symlink]
.zsh/zsh-syntax-highlighting/highlighters/root/README.md [changed from file to symlink]
.zsh/zsh-syntax-highlighting/images/after1-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/after1.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/after2-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/after2.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/after3-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/after3.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before1-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before1.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before2-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before2.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before3-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/before3.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/preview-smaller.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/images/preview.png [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/release.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/tests/README.md
.zsh/zsh-syntax-highlighting/tests/tap-colorizer.zsh
.zsh/zsh-syntax-highlighting/tests/test-highlighting.zsh
.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh [changed from symlink to file mode: 0644]
.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

diff --git a/.zsh/zsh-syntax-highlighting/.gitattributes b/.zsh/zsh-syntax-highlighting/.gitattributes
new file mode 100644 (file)
index 0000000..715e624
--- /dev/null
@@ -0,0 +1 @@
+.revision-hash export-subst
diff --git a/.zsh/zsh-syntax-highlighting/.travis.yml b/.zsh/zsh-syntax-highlighting/.travis.yml
new file mode 100644 (file)
index 0000000..db5dbc4
--- /dev/null
@@ -0,0 +1,48 @@
+language: generic
+sudo: required
+
+env:
+  - ZSH=master
+  - ZSH=5.4.2
+  - ZSH=5.4.1
+  - ZSH=5.4
+  - ZSH=5.3.1
+  - ZSH=5.3
+  - ZSH=5.2
+  - ZSH=5.1.1
+  - ZSH=5.1
+  - ZSH=5.0.8
+  - ZSH=5.0.7
+  - ZSH=5.0.6
+  - ZSH=5.0.5
+  - ZSH=5.0.4
+  - ZSH=5.0.3
+  - ZSH=5.0.2
+  - ZSH=5.0.1
+  - ZSH=5.0.0
+  - ZSH=4.3.17
+  - ZSH=4.3.16
+  - ZSH=4.3.15
+  - ZSH=4.3.14
+  - ZSH=4.3.13
+  - ZSH=4.3.12
+  - ZSH=4.3.11
+
+script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'make test'
+
+notifications:
+  webhooks:
+    urls:
+      - https://webhooks.gitter.im/e/367e241cdea60cb2070b
+    on_success: change
+    on_failure: always
+    on_start: never
+  irc:
+    channels:
+      - "chat.freenode.net#zsh-syntax-highlighting"
+    on_success: change
+    on_failure: always
+    on_start: never
+    use_notice: true
+    template:
+      - "%{repository}/%{branch}#%{build_number}: %{message} Changes : %{compare_url} | Build : %{build_url}"
diff --git a/.zsh/zsh-syntax-highlighting/INSTALL.md b/.zsh/zsh-syntax-highlighting/INSTALL.md
new file mode 100644 (file)
index 0000000..ca1bfa7
--- /dev/null
@@ -0,0 +1,111 @@
+How to install
+--------------
+
+### Using packages
+
+* 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])
+* 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]
+* 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])
+* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
+* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
+* Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package]
+
+[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
+[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
+[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
+[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
+[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
+[void-package]: https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
+
+
+### In your ~/.zshrc
+
+Simply clone this repository and source the script:
+
+        git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
+        echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
+
+  Then, enable syntax highlighting in the current interactive shell:
+
+        source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+
+  If `git` is not installed, download and extract a snapshot of the latest
+  development tree from:
+
+        https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
+
+  Note the `source` command must be **at the end** of `~/.zshrc`.
+
+
+### With a plugin manager
+
+Note that `zsh-syntax-highlighting` must be the last plugin sourced.
+
+The zsh-syntax-highlighting authors recommend manual installation over the use
+of a framework or plugin manager.
+
+This list is incomplete as there are too many [frameworks / plugin managers]
+(https://github.com/unixorn/awesome-zsh-plugins#frameworks) to list them all
+here.
+
+#### [Antigen](https://github.com/zsh-users/antigen)
+
+Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in
+your `.zshrc`.
+
+#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
+
+1. Clone this repository in oh-my-zsh's plugins directory:
+
+        git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
+
+2. Activate the plugin in `~/.zshrc`:
+
+        plugins=( [plugins...] zsh-syntax-highlighting)
+
+3. Source `~/.zshrc`  to take changes into account:
+
+        source ~/.zshrc
+
+#### [Prezto](https://github.com/sorin-ionescu/prezto)
+
+Zsh-syntax-highlighting is included with Prezto. See the [Prezto documentation]
+(https://github.com/sorin-ionescu/prezto/tree/master/modules/syntax-highlighting)
+to enable and configure highlighters.
+
+#### [zgen](https://github.com/tarjoilija/zgen)
+
+Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
+
+#### [zplug](https://github.com/zplug/zplug)
+
+Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`.
+
+#### [zplugin](https://github.com/psprint/zplugin)
+
+Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your
+`.zshrc`.
+
+
+### System-wide installation
+
+Any of the above methods is suitable for a single-user installation,
+which requires no special privileges.  If, however, you desire to install
+zsh-syntax-highlighting system-wide, you may do so by running
+
+    make install
+
+and directing your users to add
+
+    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+
+to their `.zshrc`s.
diff --git a/.zsh/zsh-syntax-highlighting/Makefile b/.zsh/zsh-syntax-highlighting/Makefile
new file mode 100644 (file)
index 0000000..6cc2648
--- /dev/null
@@ -0,0 +1,64 @@
+NAME=zsh-syntax-highlighting
+
+INSTALL?=install -c
+PREFIX?=/usr/local
+SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
+DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
+ZSH?=zsh # zsh binary to run tests with
+
+all:
+       cd docs && \
+       cp highlighters.md all.md && \
+       printf '\n\nIndividual highlighters documentation\n=====================================' >> all.md && \
+       for doc in highlighters/*.md; do printf '\n\n'; cat "$$doc"; done >> all.md
+
+install: all
+       $(INSTALL) -d $(SHARE_DIR)
+       $(INSTALL) -d $(DOC_DIR)
+       cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR)
+       cp COPYING.md README.md changelog.md $(DOC_DIR)
+       sed -e '1s/ .*//' -e '/^\[build-status-[a-z]*\]: /d' < README.md > $(DOC_DIR)/README.md
+       if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
+               git rev-parse HEAD; \
+       else \
+               cat .revision-hash; \
+       fi > $(SHARE_DIR)/.revision-hash
+       :
+# The [ -e ] check below is to because sh evaluates this with (the moral
+# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches.
+       for dirname in highlighters highlighters/*/ ; do \
+               $(INSTALL) -d $(SHARE_DIR)/"$$dirname"; \
+               for fname in "$$dirname"/*.zsh ; do [ -e "$$fname" ] && cp "$$fname" $(SHARE_DIR)"/$$dirname"; done; \
+       done
+       cp -R docs/* $(DOC_DIR)
+
+clean:
+       rm -f docs/all.md
+
+test:
+       @$(ZSH) -fc 'echo ZSH_PATCHLEVEL=$$ZSH_PATCHLEVEL'
+       @result=0; \
+       for test in highlighters/*; do \
+               if [ -d $$test/test-data ]; then \
+                       echo "Running test $${test##*/}"; \
+                       $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
+                       : $$(( result |= $$? )); \
+               fi \
+       done; \
+       exit $$result
+
+quiet-test:
+       $(MAKE) test QUIET=y
+
+perf:
+       @result=0; \
+       for test in highlighters/*; do \
+               if [ -d $$test/test-data ]; then \
+                       echo "Running test $${test##*/}"; \
+                       $(ZSH) -f tests/test-perfs.zsh "$${test##*/}"; \
+                       : $$(( result |= $$? )); \
+               fi \
+       done; \
+       exit $$result
+
+.PHONY: all install clean test perf
index 2c2b6d6..855be9e 100644 (file)
@@ -1,9 +1,9 @@
-zsh-syntax-highlighting
+zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
 =======================
 
 **[Fish shell][fish]-like like syntax highlighting for [Zsh][zsh].**
 
-*Requirements: zsh 4.3.17+.*
+*Requirements: zsh 4.3.11+.*
 
 [fish]: http://www.fishshell.com/
 [zsh]: http://www.zsh.org/
@@ -46,20 +46,19 @@ syntax highlighting.
 
 ### Does syntax highlighting work during incremental history search?
 
-Highlighting the command line during an incremental history search
-(with the `history-incremental-search-backward` widget, which is
-bound by default to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.3
-or newer.
+Highlighting the command line during an incremental history search (by default bound to
+to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.4 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
 additional highlighting is unavailable.  (Those versions of zsh do not provide
 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
 [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?
 
@@ -76,3 +75,6 @@ How to tweak
 Syntax highlighting is done by pluggable highlighter scripts.  See the
 [documentation on highlighters](docs/highlighters.md) for details and
 configuration settings.
+
+[build-status-image]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting.svg?branch=master
+[build-status-travis]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting
diff --git a/.zsh/zsh-syntax-highlighting/changelog.md b/.zsh/zsh-syntax-highlighting/changelog.md
new file mode 100644 (file)
index 0000000..f20e69d
--- /dev/null
@@ -0,0 +1,558 @@
+# 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
+
+
+## Performance improvements:
+
+We thank Sebastian Gniazdowski and "m0viefreak" for significant contributions
+in this area.
+
+- Optimize string operations in the `main` (default) highlighter.
+  (#372/3cb58fd7d7b9, 02229ebd6328, ef4bfe5bcc14, #372/c6b6513ac0d6, #374/15461e7d21c3)
+
+- Command word highlighting:  Use the `zsh/parameter` module to avoid forks.
+  Memoize (cache) the results.
+  (#298, 3ce01076b521, 2f18ba64e397, 12b879caf7a6; #320, 3b67e656bff5)
+
+- Avoid forks in the driver and in the `root` highlighter.
+  (b9112aec798a, 38c8fbea2dd2)
+
+
+## Added highlighting of:
+
+- `pkexec` (a precommand).
+  (#248, 4f3910cbbaa5)
+
+- Aliases that cannot be defined normally nor invoked normally (highlighted as an error).
+  (#263 (in part), 28932316cca6)
+
+- Path separators (`/`) — the default behaviour remains to highlight path separators
+  and path components the same way.
+  (#136, #260, 6cd39e7c70d3, 9a934d291e7c, f3d3aaa00cc4)
+
+- Assignments to individual positional arguments (`42=foo` to assign to `$42`).
+  (f4036a09cee3)
+
+- Linewise region (the `visual-line-mode` widget, bound to `V` in zsh's `vi` keymap).
+  (#267, a7a7f8b42280, ee07588cfd9b)
+
+- Command-lines recalled by `isearch` mode; requires zsh≥5.3.
+  (#261 (in part); #257; 4ad311ec0a68)
+
+- Command-lines whilst the `IGNORE_BRACES` or `IGNORE_CLOSE_BRACES` option is in effect.
+  (a8a6384356af, 02807f1826a5)
+
+- Mismatched parentheses and braces (in the `main` highlighter).
+  (51b9d79c3bb6, 2fabf7ca64b7, a4196eda5e6f, and others)
+
+- Mismatched `do`/`done` keywords.
+  (b2733a64da93)
+
+- Mismatched `foreach`/`end` keywords.
+  (#96, 2bb8f0703d8f)
+
+- In Bourne-style function definitions, when the `MULTI_FUNC_DEF` option is set
+  (which is the default), highlight the first word in the function body as
+  a command word: `f() { g "$@" }`.
+  (6f91850a01e1)
+
+- `always` blocks.
+  (#335, e5782e4ddfb6)
+
+- Command substitutions inside double quotes, `"$(echo foo)"`.
+  (#139 (in part), c3913e0d8ead)
+
+- Non-alphabetic parameters inside double quotes (`"$$"`, `"$#"`, `"$*"`, `"$@"`, `"$?"`, `"$-"`).
+  (4afe670f7a1b, 44ef6e38e5a7)
+
+- Command words from future versions of zsh (forward compatibly).
+  This also adds an `arg0` style that all other command word styles fall back to.
+  (b4537a972eed, bccc3dc26943)
+
+- Escaped history expansions inside double quotes: `: "\!"`
+  (28d7056a7a06, et seq)
+
+
+## Fixed highlighting of:
+
+- Command separator tokens in syntactically-invalid positions.
+  (09c4114eb980)
+
+- Redirections with a file descriptor number at command word.
+  (#238 (in part), 73ee7c1f6c4a)
+
+- The `select` prompt, `$PS3`.
+  (#268, 451665cb2a8b)
+
+- Values of variables in `vared`.
+  (e500ca246286)
+
+- `!` as an argument (neither a history expansion nor a reserved word).
+  (4c23a2fd1b90)
+
+- "division by zero" error under the `brackets` highlighter when `$ZSH_HIGHLIGHT_STYLES` is empty.
+  (f73f3d53d3a6)
+
+- Process substitutions, `<(pwd)` and `>(wc -l)`.
+  (#302, 6889ff6bd2ad, bfabffbf975c, fc9c892a3f15)
+
+- The non-`SHORT_LOOPS` form of `repeat` loops: `repeat 42; do true; done`.
+  (#290, 4832f18c50a5, ef68f50c048f, 6362c757b6f7)
+
+- Broken symlinks (are now highlighted as files).
+  (#342, 95f7206a9373, 53083da8215e)
+
+- Lines accepted from `isearch` mode.
+  (#284; #257, #259, #288; 5bae6219008b, a8fe22d42251)
+
+- Work around upstream bug that triggered when the command word was a relative
+  path, that when interpreted relative to a $PATH directory denoted a command;
+  the effect of that upstream bug was that the relative path was cached as
+  a "valid external command name".
+  (#354, #355, 51614ca2c994, fdaeec45146b, 7d38d07255e4;
+  upstream fix slated to be released in 5.3 (workers/39104))
+
+- After accepting a line with the cursor on a bracket, the matching bracket
+  of the bracket under the cursor no longer remains highlighted (with the
+  `brackets` highlighter).
+  (4c4baede519a)
+
+- The first word on a new line within an array assignment or initialization is no
+  longer considered a command position.
+  (8bf423d16d46)
+
+- Subshells that end at command position, `(A=42)`, `(true;)`.
+  (#231, 7fb6f9979121; #344, 4fc35362ee5a)
+
+- Command word after array assignment, `a=(lorem ipsum) pwd`.
+  (#330, 7fb6f9979121)
+
+
+## API changes (for highlighter authors):
+
+- New interface `_zsh_highlight_add_highlight`.
+  (341a3ae1f015, c346f6eb6fb6)
+
+- tests: Specify the style key, not its value, in test expectations.
+  (a830613467af, fd061b5730bf, eaa4335c3441, among others)
+
+- Module author documentation improvements.
+  (#306 (in part), 217669270418, 0ff354b44b6e, 80148f6c8402, 364f206a547f, and others)
+
+- The driver no longer defines a `_zsh_highlight_${highlighter}_highlighter_cache`
+  variable, which is in the highlighters' namespace.
+  (3e59ab41b6b8, 80148f6c8402, f91a7b885e7d)
+
+- Rename highlighter entry points.  The old names remain supported for
+  backwards compatibility.
+  (a3d5dfcbdae9, c793e0dceab1)
+
+- tests: Add the "NONE" expectation.
+  (4da9889d1545, 13018f3dd735, d37c55c788cd)
+
+- tests: consider a test that writes to stderr to have failed.
+  (#291, 1082067f9315)
+
+
+## Developer-visible changes:
+
+- Add `make quiet-test`.
+  (9b64ad750f35)
+
+- test harness: Better quote replaceables in error messages.
+  (30d8f92df225)
+
+- test harness: Fix exit code for XPASS.
+  (bb8d325c0cbd)
+
+- Create [HACKING.md](HACKING.md).
+  (cef49752fd0e)
+
+- tests: Emit a description for PASS test points.
+  (6aa57d60aa64, f0bae44b76dd)
+
+- tests: Create a script that generates a test file.
+  (8013dc3b8db6, et seq; `tests/generate.zsh`)
+
+
+## Other changes:
+
+- Under zsh≤5.2, widgets whose names start with a `_` are no longer excluded
+  from highlighting.
+  (ed33d2cb1388; reverts part of 186d80054a40 which was for #65)
+
+- Under zsh≤5.2, widgets implemented by a function named after the widget are
+  no longer excluded from highlighting.
+  (487b122c480d; reverts part of 776453cb5b69)
+
+- Under zsh≤5.2, shell-unsafe widget names can now be wrapped.
+  (#278, 6a634fac9fb9, et seq)
+
+- Correct some test expectations.
+  (78290e043bc5)
+
+- `zsh-syntax-highlighting.plugin.zsh`: Convert from symlink to plain file
+  for msys2 compatibility.
+  (#292, d4f8edc9f3ad)
+
+- Document installation under some plugin managers.
+  (e635f766bef9, 9cab566f539b)
+
+- Don't leak the `PATH_DIRS` option.
+  (7b82b88a7166)
+
+- Don't require the `FUNCTION_ARGZERO` option to be set.
+  (#338, 750aebc553f2)
+
+- Under zsh≤5.2, support binding incomplete/nonexistent widgets.
+  (9e569bb0fe04, part of #288)
+
+- Make the driver reentrant, fixing possibility of infinite recursion
+  under zsh≤5.2 under interaction with theoretical third-party code.
+  (#305, d711563fe1bf, 295d62ec888d, f3242cbd6aba)
+
+- Fix warnings when `WARN_CREATE_GLOBAL` is set prior to sourcing zsh-syntax-highlighting.
+  (z-sy-h already sets `WARN_CREATE_GLOBAL` internally.)
+  (da60234fb236)
+
+- Warn only once, rather than once per keypress, when a highlighter is unavailable.
+  (0a9b347483ae)
+
+
+# Changes in version 0.4.1
+
+## Fixes:
+
+- Arguments to widgets were not properly dash-escaped.  Only matters for widgets
+  that take arguments (i.e., that are invoked as `zle ${widget} -- ${args}`).
+  (282c7134e8ac, reverts c808d2187a73)
+
+
+# Changes in version 0.4.0
+
+
+## Added highlighting of:
+
+- incomplete sudo commands
+  (a3047a912100, 2f05620b19ae)
+
+        sudo;
+        sudo -u;
+
+- command words following reserved words
+  (#207, #222, b397b12ac139 et seq, 6fbd2aa9579b et seq, 8b4adbd991b0)
+
+        if ls; then ls; else ls; fi
+        repeat 10 do ls; done
+
+    (The `ls` are now highlighted as a command.)
+
+- comments (when `INTERACTIVE_COMMENTS` is set)
+  (#163, #167, 693de99a9030)
+
+        echo Hello # comment
+
+- closing brackets of arithmetic expansion, subshells, and blocks
+  (#226, a59f442d2d34, et seq)
+
+        (( foo ))
+        ( foo )
+        { foo }
+
+- command names enabled by the `PATH_DIRS` option
+  (#228, 96ee5116b182)
+
+        # When ~/bin/foo/bar exists, is executable, ~/bin is in $PATH,
+        # and 'setopt PATH_DIRS' is in effect
+        foo/bar
+
+- parameter expansions with braces inside double quotes
+  (#186, 6e3720f39d84)
+
+        echo "${foo}"
+
+- parameter expansions in command word
+  (#101, 4fcfb15913a2)
+
+        x=/bin/ls
+        $x -l
+
+- the command separators '|&', '&!', '&|'
+
+        view file.pdf &!  ls
+
+
+## Fixed highlighting of:
+
+- precommand modifiers at non-command-word position
+  (#209, 2c9f8c8c95fa)
+
+        ls command foo
+
+- sudo commands with infix redirections
+  (#221, be006aded590, 86e924970911)
+
+        sudo -u >/tmp/foo.out user ls
+
+- subshells; anonymous functions
+  (#166, #194, 0d1bfbcbfa67, 9e178f9f3948)
+
+        (true)
+        () { true }
+
+- parameter assignment statements with no command
+  (#205, 01d7eeb3c713)
+
+        A=1;
+
+    (The semicolon used to be highlighted as a mistake)
+
+- cursor highlighter: Remove the cursor highlighting when accepting a line.
+  (#109, 4f0c293fdef0)
+
+
+## Removed features:
+
+- Removed highlighting of approximate paths (`path_approx`).
+  (#187, 98aee7f8b9a3)
+
+
+## Other changes:
+
+- main highlighter refactored to use states rather than booleans.
+  (2080a441ac49, et seq)
+
+- Fix initialization when sourcing `zsh-syntax-highlighting.zsh` via a symlink
+  (083c47b00707)
+
+- docs: Add screenshot.
+  (57624bb9f64b)
+
+- widgets wrapping: Don't add '--' when invoking widgets.
+  (c808d2187a73) [_reverted in 0.4.1_]
+
+- Refresh highlighting upon `accept-*` widgets (`accept-line` et al).
+  (59fbdda64c21)
+
+- Stop leaking match/mbegin/mend to global scope (thanks to upstream
+  `WARN_CREATE_GLOBAL` improvements).
+  (d3deffbf46a4)
+
+- 'make install': Permit setting `$(SHARE_DIR)` from the environment.
+  (e1078a8b4cf1)
+
+- driver: Tolerate KSH_ARRAYS being set in the calling context.
+  (#162, 8f19af6b319d)
+
+- 'make install': Install documentation fully and properly.
+  (#219, b1619c001390, et seq)
+
+- docs: Improve 'main' highlighter's documentation.
+  (00de155063f5, 7d4252f5f596)
+
+- docs: Moved to a new docs/ tree; assorted minor updates
+  (c575f8f37567, 5b34c23cfad5, et seq)
+
+- docs: Split README.md into INSTALL.md
+  (0b3183f6cb9a)
+
+- driver: Report `$ZSH_HIGHLIGHT_REVISION` when running from git
+  (84734ba95026)
+
+
+## Developer-visible changes:
+
+- Test harness converted to [TAP](http://testanything.org/tap-specification.html) format
+  (d99aa58aaaef, et seq)
+
+- Run each test in a separate subprocess, isolating them from each other
+  (d99aa58aaaef, et seq)
+
+- Fix test failure with nonexisting $HOME
+  (#216, b2ac98b98150)
+
+- Test output is now colorized.
+  (4d3da30f8b72, 6fe07c096109)
+
+- Document `make install`
+  (a18a7427fd2c)
+
+- tests: Allow specifying the zsh binary to use.
+  (557bb7e0c6a0)
+
+- tests: Add 'make perf' target
+  (4513eaea71d7)
+
+- tests: Run each test in a sandbox directory
+  (c01533920245)
+
+
+# Changes in version 0.3.0
+
+
+## Added highlighting of:
+
+- suffix aliases (requires zsh 5.1.1 or newer):
+
+        alias -s png=display
+        foo.png
+
+- prefix redirections:
+
+        <foo.txt cat
+
+- redirection operators:
+
+        echo > foo.txt
+
+- arithmetic evaluations:
+
+        (( 42 ))
+
+- $'' strings, including \x/\octal/\u/\U escapes
+
+        : $'foo\u0040bar'
+
+- multiline strings:
+
+        % echo "line 1
+        line 2"
+
+- string literals that haven't been finished:
+
+        % echo "Hello, world
+
+- command words that involve tilde expansion:
+
+        % ~/bin/foo
+
+
+## Fixed highlighting of:
+
+- quoted command words:
+
+        % \ls
+
+- backslash escapes in "" strings:
+
+        % echo "\x41"
+
+- noglob after command separator:
+
+        % :; noglob echo *
+
+- glob after command separator, when the first command starts with 'noglob':
+
+        % noglob true; echo *
+
+- the region (vi visual mode / set-mark-command) (issue #165)
+
+- redirection and command separators that would be highlighted as `path_approx`
+
+        % echo foo;‸
+        % echo <‸
+
+    (where `‸` represents the cursor location)
+
+- escaped globbing (outside quotes)
+
+        % echo \*
+
+
+## Other changes:
+
+- implemented compatibility with zsh's paste highlighting (issue #175)
+
+- `$?` propagated correctly to wrapped widgets
+
+- don't leak $REPLY into global scope
+
+
+## Developer-visible changes:
+
+- added makefile with `install` and `test` targets
+
+- set `warn_create_global` internally
+
+- document release process
+
+
+
+
+# Version 0.2.1
+
+(Start of changelog.)
+
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters.md b/.zsh/zsh-syntax-highlighting/docs/highlighters.md
new file mode 100644 (file)
index 0000000..c0f79bc
--- /dev/null
@@ -0,0 +1,97 @@
+zsh-syntax-highlighting / highlighters
+======================================
+
+Syntax highlighting is done by pluggable highlighters:
+
+* `main` - the base highlighter, and the only one [active by default][1].
+* `brackets` - [matches brackets][2] and parenthesis.
+* `pattern` - matches [user-defined patterns][3].
+* `cursor` - matches [the cursor position][4].
+* `root` - highlights the whole command line [if the current user is root][5].
+* `line` - applied to [the whole command line][6].
+
+[1]: highlighters/main.md
+[2]: highlighters/brackets.md
+[3]: highlighters/pattern.md
+[4]: highlighters/cursor.md
+[5]: highlighters/root.md
+[6]: highlighters/line.md
+
+
+How to activate highlighters
+----------------------------
+
+To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in
+`~/.zshrc`, for example:
+
+    ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
+
+By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main`
+highlighter is active.
+
+
+How to tweak highlighters
+-------------------------
+
+Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` associative array.
+Navigate into the [individual highlighters' documentation](highlighters/) to
+see what styles (keys) each highlighter defines; the syntax for values is the
+same as the syntax of "types of highlighting" of the zsh builtin
+`$zle_highlight` array, which is documented in [the `zshzle(1)` manual
+page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
+
+Some highlighters support additional configuration parameters; see each
+highlighter's documentation for details and examples.
+
+
+How to implement a new highlighter
+----------------------------------
+
+To create your own `acme` highlighter:
+
+* Create your script at
+    `highlighters/acme/acme-highlighter.zsh`.
+
+* Implement the `_zsh_highlight_highlighter_acme_predicate` function.
+  This function must return 0 when the highlighter needs to be called and
+  non-zero otherwise, for example:
+
+        _zsh_highlight_highlighter_acme_predicate() {
+          # Call this highlighter in SVN working copies
+          [[ -d .svn ]]
+        }
+
+* Implement the `_zsh_highlight_highlighter_acme_paint` function.
+  This function does the actual syntax highlighting, by calling
+  `_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
+  style for that key in the highlighter script outside of any function with
+  `: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix
+  the key with your highlighter name and a colon. For example:
+
+        : ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green}
+
+        _zsh_highlight_highlighter_acme_paint() {
+          # Colorize the whole buffer with the 'aurora' style
+          _zsh_highlight_add_highlight 0 $#BUFFER acme:aurora
+        }
+
+* Name your own functions and global variables `_zsh_highlight_acme_*`.
+
+    - In zsh-syntax-highlighting 0.4.0 and earlier, the entrypoints 
+        `_zsh_highlight_highlighter_acme_predicate` and
+        `_zsh_highlight_highlighter_acme_paint`
+        were named
+        `_zsh_highlight_acme_highlighter_predicate` and
+        `_zsh_highlight_highlighter_acme_paint` respectively.
+
+        These names are still supported for backwards compatibility;
+        however, support for them will be removed in a a future major or minor release (v0.x.0 or v1.0.0).
+
+* Activate your highlighter in `~/.zshrc`:
+
+        ZSH_HIGHLIGHT_HIGHLIGHTERS+=(acme)
+
+* [Write tests](../tests/README.md).
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/brackets.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/brackets.md
new file mode 100644 (file)
index 0000000..9001074
--- /dev/null
@@ -0,0 +1,29 @@
+zsh-syntax-highlighting / highlighters / brackets
+-------------------------------------------------
+
+This is the `brackets` highlighter, that highlights brackets and parentheses, and
+matches them.
+
+
+### How to tweak it
+
+This highlighter defines the following styles:
+
+* `bracket-error` - unmatched brackets
+* `bracket-level-N` - brackets with nest level N
+* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket
+
+To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
+for example in `~/.zshrc`:
+
+    # To define styles for nested brackets up to level 4
+    ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
+    ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
+    ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
+    ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/cursor.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/cursor.md
new file mode 100644 (file)
index 0000000..7295fd1
--- /dev/null
@@ -0,0 +1,22 @@
+zsh-syntax-highlighting / highlighters / cursor
+-----------------------------------------------
+
+This is the `cursor` highlighter, that highlights the cursor.
+
+
+### How to tweak it
+
+This highlighter defines the following styles:
+
+* `cursor` - the style for the current cursor position
+
+To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
+for example in `~/.zshrc`:
+
+    ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/line.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/line.md
new file mode 100644 (file)
index 0000000..4ba14e9
--- /dev/null
@@ -0,0 +1,22 @@
+zsh-syntax-highlighting / highlighters / line
+---------------------------------------------
+
+This is the `line` highlighter, that highlights the whole line.
+
+
+### How to tweak it
+
+This highlighter defines the following styles:
+
+* `line` - the style for the whole line
+
+To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
+for example in `~/.zshrc`:
+
+    ZSH_HIGHLIGHT_STYLES[line]='bold'
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/main.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/main.md
new file mode 100644 (file)
index 0000000..bf83820
--- /dev/null
@@ -0,0 +1,91 @@
+zsh-syntax-highlighting / highlighters / main
+---------------------------------------------
+
+This is the `main` highlighter, that highlights:
+
+* Commands
+* Options
+* Arguments
+* Paths
+* Strings
+
+This highlighter is active by default.
+
+
+### How to tweak it
+
+This highlighter defines the following styles:
+
+* `unknown-token` - unknown tokens / errors
+* `reserved-word` - shell reserved words (`if`, `for`)
+* `alias` - aliases
+* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
+* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
+* `function` - function names
+* `command` - command names
+* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
+* `commandseparator` - command separation tokens (`;`, `&&`)
+* `hashed-command` - hashed commands
+* `path` - existing filenames
+* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
+* `path_prefix` - prefixes of existing filenames
+* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default)
+* `globbing` - globbing expressions (`*.txt`)
+* `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`)
+* `single-hyphen-option` - single hyphen options (`-o`)
+* `double-hyphen-option` - double hyphen options (`--option`)
+* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
+* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
+* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
+* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
+* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
+* `back-double-quoted-argument` -  back double quoted arguments (`\x` inside `""`)
+* `back-dollar-quoted-argument` -  back dollar quoted arguments (`\x` inside `$''`)
+* `assign` - parameter assignments
+* `redirection` - redirection operators (`<`, `>`, etc)
+* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
+* `arg0` - a command word other than one of those enumrated above (other than a command, precommand, alias, function, or shell builtin command).
+* `default` - everything else
+
+To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
+for example in `~/.zshrc`:
+
+    # Declare the variable
+    typeset -A ZSH_HIGHLIGHT_STYLES
+
+    # To differentiate aliases from other command types
+    ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
+    
+    # To have paths colored instead of underlined
+    ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
+    
+    # To disable highlighting of globbing expressions
+    ZSH_HIGHLIGHT_STYLES[globbing]='none'
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+### Useless trivia
+
+#### Forward compatibility.
+
+zsh-syntax-highlighting attempts to be forward-compatible with zsh.
+Specifically, we attempt to facilitate highlighting _command word_ types that
+had not yet been invented when this version of zsh-syntax-highlighting was
+released.
+
+A _command word_ is something like a function name, external command name, et
+cetera.  (See
+[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines]
+for a formal definition.)
+
+If a new _kind_ of command word is ever added to zsh — something conceptually
+different than "function" and "alias" and "external command" — then command words
+of that (new) kind will be highlighted by the style `arg0_$kind`,
+where `$kind` is the output of `type -w` on the new kind of command word.  If that
+style is not defined, then the style `arg0` will be used instead.
+
+[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/pattern.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/pattern.md
new file mode 100644 (file)
index 0000000..3ad5f24
--- /dev/null
@@ -0,0 +1,19 @@
+zsh-syntax-highlighting / highlighters / pattern
+------------------------------------------------
+
+This is the `pattern` highlighter, that highlights user-defined patterns.
+
+
+### How to tweak it
+
+To use this highlighter, associate patterns with styles in the
+`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`:
+
+    # To have commands starting with `rm -rf` in red:
+    ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/root.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/root.md
new file mode 100644 (file)
index 0000000..0b0d41f
--- /dev/null
@@ -0,0 +1,23 @@
+zsh-syntax-highlighting / highlighters / root
+---------------------------------------------
+
+This is the `root` highlighter, that highlights the whole line if the current
+user is root.
+
+
+### How to tweak it
+
+This highlighter defines the following styles:
+
+* `root` - the style for the whole line if the current user is root.
+
+To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
+for example in `~/.zshrc`:
+
+    ZSH_HIGHLIGHT_STYLES[root]='bg=red'
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
deleted file mode 100644 (file)
index 90010744a2912042def5c28dda3e14a77dac5527..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,29 +0,0 @@
-zsh-syntax-highlighting / highlighters / brackets
--------------------------------------------------
-
-This is the `brackets` highlighter, that highlights brackets and parentheses, and
-matches them.
-
-
-### How to tweak it
-
-This highlighter defines the following styles:
-
-* `bracket-error` - unmatched brackets
-* `bracket-level-N` - brackets with nest level N
-* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket
-
-To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
-for example in `~/.zshrc`:
-
-    # To define styles for nested brackets up to level 4
-    ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
-    ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
-    ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
-    ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
-
-The syntax for values is the same as the syntax of "types of highlighting" of
-the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
-manual page][zshzle-Character-Highlighting].
-
-[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..6997bd60d3a6b18806917ea116a0be17a16c811d
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/brackets.md
\ No newline at end of file
index 1bdd1f9..cb09b40 100644 (file)
@@ -59,11 +59,15 @@ _zsh_highlight_highlighter_brackets_paint()
         lastoflevel[$level]=$pos
         ;;
       [")]}"])
-        matchingpos=$lastoflevel[$level]
-        levelpos[$pos]=$((level--))
-       if _zsh_highlight_brackets_match $matchingpos $pos; then
-          matching[$matchingpos]=$pos
-          matching[$pos]=$matchingpos
+        if (( level > 0 )); then
+          matchingpos=$lastoflevel[$level]
+          levelpos[$pos]=$((level--))
+          if _zsh_highlight_brackets_match $matchingpos $pos; then
+            matching[$matchingpos]=$pos
+            matching[$pos]=$matchingpos
+          fi
+        else
+          levelpos[$pos]=-1
         fi
         ;;
       ['"'\'])
@@ -77,18 +81,17 @@ _zsh_highlight_highlighter_brackets_paint()
   for pos in ${(k)levelpos}; do
     if (( $+matching[$pos] )); then
       if (( bracket_color_size )); then
-        style=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
+        _zsh_highlight_add_highlight $((pos - 1)) $pos bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
       fi
     else
-      style=bracket-error
+      _zsh_highlight_add_highlight $((pos - 1)) $pos bracket-error
     fi
-    _zsh_highlight_add_highlight $((pos - 1)) $pos $style
   done
 
   # If cursor is on a bracket, then highlight corresponding bracket, if any.
   if [[ $WIDGET != zle-line-finish ]]; then
     pos=$((CURSOR + 1))
-    if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then
+    if (( $+levelpos[$pos] )) && (( $+matching[$pos] )); then
       local -i otherpos=$matching[$pos]
       _zsh_highlight_add_highlight $((otherpos - 1)) $otherpos cursor-matchingbracket
     fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/only-error.zsh b/.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/only-error.zsh
new file mode 100644 (file)
index 0000000..1c3a159
--- /dev/null
@@ -0,0 +1,35 @@
+# -------------------------------------------------------------------------------------------------
+# 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=': x)'
+
+expected_region_highlight=(
+  "1 3 NONE"
+  "4 4 bracket-error" # )
+)
deleted file mode 100644 (file)
index 7295fd191eec5d89905232282e7179b9d6eb9df1..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,22 +0,0 @@
-zsh-syntax-highlighting / highlighters / cursor
------------------------------------------------
-
-This is the `cursor` highlighter, that highlights the cursor.
-
-
-### How to tweak it
-
-This highlighter defines the following styles:
-
-* `cursor` - the style for the current cursor position
-
-To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
-for example in `~/.zshrc`:
-
-    ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
-
-The syntax for values is the same as the syntax of "types of highlighting" of
-the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
-manual page][zshzle-Character-Highlighting].
-
-[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..70e0c8c42ad0aa244876c42ed5e6395e39cba4d0
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/cursor.md
\ No newline at end of file
deleted file mode 100644 (file)
index bf838200263a4af319ba3b511d6bca9f57dd128e..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,91 +0,0 @@
-zsh-syntax-highlighting / highlighters / main
----------------------------------------------
-
-This is the `main` highlighter, that highlights:
-
-* Commands
-* Options
-* Arguments
-* Paths
-* Strings
-
-This highlighter is active by default.
-
-
-### How to tweak it
-
-This highlighter defines the following styles:
-
-* `unknown-token` - unknown tokens / errors
-* `reserved-word` - shell reserved words (`if`, `for`)
-* `alias` - aliases
-* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
-* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
-* `function` - function names
-* `command` - command names
-* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
-* `commandseparator` - command separation tokens (`;`, `&&`)
-* `hashed-command` - hashed commands
-* `path` - existing filenames
-* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
-* `path_prefix` - prefixes of existing filenames
-* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default)
-* `globbing` - globbing expressions (`*.txt`)
-* `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`)
-* `single-hyphen-option` - single hyphen options (`-o`)
-* `double-hyphen-option` - double hyphen options (`--option`)
-* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
-* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
-* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
-* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
-* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
-* `back-double-quoted-argument` -  back double quoted arguments (`\x` inside `""`)
-* `back-dollar-quoted-argument` -  back dollar quoted arguments (`\x` inside `$''`)
-* `assign` - parameter assignments
-* `redirection` - redirection operators (`<`, `>`, etc)
-* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
-* `arg0` - a command word other than one of those enumrated above (other than a command, precommand, alias, function, or shell builtin command).
-* `default` - everything else
-
-To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
-for example in `~/.zshrc`:
-
-    # Declare the variable
-    typeset -A ZSH_HIGHLIGHT_STYLES
-
-    # To differentiate aliases from other command types
-    ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
-    
-    # To have paths colored instead of underlined
-    ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
-    
-    # To disable highlighting of globbing expressions
-    ZSH_HIGHLIGHT_STYLES[globbing]='none'
-
-The syntax for values is the same as the syntax of "types of highlighting" of
-the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
-manual page][zshzle-Character-Highlighting].
-
-### Useless trivia
-
-#### Forward compatibility.
-
-zsh-syntax-highlighting attempts to be forward-compatible with zsh.
-Specifically, we attempt to facilitate highlighting _command word_ types that
-had not yet been invented when this version of zsh-syntax-highlighting was
-released.
-
-A _command word_ is something like a function name, external command name, et
-cetera.  (See
-[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines]
-for a formal definition.)
-
-If a new _kind_ of command word is ever added to zsh — something conceptually
-different than "function" and "alias" and "external command" — then command words
-of that (new) kind will be highlighted by the style `arg0_$kind`,
-where `$kind` is the output of `type -w` on the new kind of command word.  If that
-style is not defined, then the style `arg0` will be used instead.
-
-[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
-
-[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..035473184f87bf8a7210c39cdc807d13937874fd
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/main.md
\ No newline at end of file
index 617f820..d4a396a 100644 (file)
@@ -241,6 +241,8 @@ _zsh_highlight_highlighter_main_paint()
   # "Y" for curly
   # "D" for do/done
   # "$" 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
 
   if (( path_dirs_was_set )); then
@@ -509,6 +511,29 @@ _zsh_highlight_highlighter_main_paint()
                           ('done')
                             _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')
                             braces_stack='$'"$braces_stack"
                             ;;
@@ -658,6 +683,7 @@ _zsh_highlight_highlighter_main_paint()
                  already_added=1
                  ;;
         '`'*)    style=back-quoted-argument;;
+        [$][*])  style=default;;
         [*?]*|*[^\\][*?]*)
                  $highlight_glob && style=globbing || style=default;;
         *)       if false; then
@@ -818,6 +844,13 @@ _zsh_highlight_main_highlighter_highlight_string()
               continue
             fi
             ;;
+      ($histchars[1]) # ! - may be a history expansion
+            if [[ $arg[i+1] != ('='|$'\x28'|$'\x7b'|[[:blank:]]) ]]; then
+              style=history-expansion
+            else
+              continue
+            fi
+            ;;
       *) continue ;;
 
     esac
index 5129614..2977343 100644 (file)
@@ -29,6 +29,9 @@
 
 alias alias1="unused expansion"
 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
 
 BUFFER='x.alias2; alias1'
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch10-if-negative.zsh
new file mode 100644 (file)
index 0000000..9d0b53c
--- /dev/null
@@ -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
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch8-if-positive.zsh
new file mode 100644 (file)
index 0000000..d6838f0
--- /dev/null
@@ -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
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch9-if-positive.zsh
new file mode 100644 (file)
index 0000000..87c1ba7
--- /dev/null
@@ -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
+)
index fb43e9e..355f890 100644 (file)
@@ -27,7 +27,7 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-x=/usr/bin/env
+local x=/usr/bin/env
 BUFFER='$x "argument"'
 
 expected_region_highlight=(
index 6876391..426ee76 100644 (file)
@@ -39,6 +39,3 @@ expected_region_highlight=(
   "1 2 function" # cd
   "4 5 function" # ls
 )
-
-# don't 'unfunction cd ls', since cd() and ls() should still be a functions
-# when _zsh_highlight runs.  Leaving the wrapper functions is harmless.
@@ -1,6 +1,6 @@
 #!/usr/bin/env zsh
 # -------------------------------------------------------------------------------------------------
-# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without modification, are permitted
@@ -28,9 +28,9 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-BUFFER='ls highlighters/main/test-data/path-space-\ .zsh'
+BUFFER='echo "foo != bar !{baz}"'
 
 expected_region_highlight=(
-  "1 2  $ZSH_HIGHLIGHT_STYLES[command]" # ls
-  "4 48 $ZSH_HIGHLIGHT_STYLES[path]"    # highlighters/main/test-data/path-space-\ .zsh
+  '1 4 builtin' # echo
+  '6 24 double-quoted-argument' # "foo != bar !{baz}" - no history expansions
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-unescaped.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-unescaped.zsh
new file mode 100644 (file)
index 0000000..c828b44
--- /dev/null
@@ -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' # "
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-yes.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-yes.zsh
new file mode 100644 (file)
index 0000000..88c300e
--- /dev/null
@@ -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"
+)
index 1f3002a..0300c7e 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-## setup
-setopt PATH_DIRS
-mkdir -p foo/bar
-touch foo/bar/testing-issue-228
-chmod  +x foo/bar/testing-issue-228
-path+=( "$PWD"/foo )
+if [[ $OSTYPE == msys ]]; then
+  skip_test='Cannot chmod +x in msys2'
+else
+  setopt PATH_DIRS
+  mkdir -p foo/bar
+  touch foo/bar/testing-issue-228
+  chmod  +x foo/bar/testing-issue-228
+  path+=( "$PWD"/foo )
 
-BUFFER='bar/testing-issue-228'
+  BUFFER='bar/testing-issue-228'
 
-expected_region_highlight=(
-  "1 21 command" # bar/testing-issue-228
-)
+  expected_region_highlight=(
+    "1 21 command" # bar/testing-issue-228
+  )
+fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/parameter-star.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/parameter-star.zsh
new file mode 100644 (file)
index 0000000..1797e58
--- /dev/null
@@ -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" # $*
+)
index 84c7d59..c99f872 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-ln -s /nonexistent broken-symlink
-BUFFER=': broken-symlink'
-CURSOR=5 # to make path_prefix ineligible
+if [[ $OSTYPE == msys ]]; then
+  skip_test='Cannot create symlinks in msys2'
+else
+  ln -s /nonexistent broken-symlink
+  BUFFER=': broken-symlink'
+  CURSOR=5 # to make path_prefix ineligible
 
-expected_region_highlight=(
-  "3 16 path" # broken-symlink
-)
+  expected_region_highlight=(
+    "3 16 path" # broken-symlink
+  )
+fi
index 3485b45..d1c34af 100644 (file)
@@ -27,7 +27,7 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-lambda="''"
+local lambda="''"
 touch \$lambda
 BUFFER=': \$lambda'
 
deleted file mode 100644 (file)
index 3ad5f247a69ae5087015eab57d275203fb0103e8..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,19 +0,0 @@
-zsh-syntax-highlighting / highlighters / pattern
-------------------------------------------------
-
-This is the `pattern` highlighter, that highlights user-defined patterns.
-
-
-### How to tweak it
-
-To use this highlighter, associate patterns with styles in the
-`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`:
-
-    # To have commands starting with `rm -rf` in red:
-    ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
-
-The syntax for values is the same as the syntax of "types of highlighting" of
-the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
-manual page][zshzle-Character-Highlighting].
-
-[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..5ff00e645182a877655be38487877cd6307520d8
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/pattern.md
\ No newline at end of file
deleted file mode 100644 (file)
index 0b0d41f0f4e8e39617b18dee5935c701b7d1a687..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,23 +0,0 @@
-zsh-syntax-highlighting / highlighters / root
----------------------------------------------
-
-This is the `root` highlighter, that highlights the whole line if the current
-user is root.
-
-
-### How to tweak it
-
-This highlighter defines the following styles:
-
-* `root` - the style for the whole line if the current user is root.
-
-To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
-for example in `~/.zshrc`:
-
-    ZSH_HIGHLIGHT_STYLES[root]='bg=red'
-
-The syntax for values is the same as the syntax of "types of highlighting" of
-the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
-manual page][zshzle-Character-Highlighting].
-
-[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..ca6799d6f1059b74dee455346fd20217eb232a1c
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/root.md
\ No newline at end of file
diff --git a/.zsh/zsh-syntax-highlighting/images/after1-smaller.png b/.zsh/zsh-syntax-highlighting/images/after1-smaller.png
new file mode 100644 (file)
index 0000000..768294c
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after1-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/after1.png b/.zsh/zsh-syntax-highlighting/images/after1.png
new file mode 100644 (file)
index 0000000..ea378d3
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after1.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/after2-smaller.png b/.zsh/zsh-syntax-highlighting/images/after2-smaller.png
new file mode 100644 (file)
index 0000000..8b5b1f8
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after2-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/after2.png b/.zsh/zsh-syntax-highlighting/images/after2.png
new file mode 100644 (file)
index 0000000..ddcbfad
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after2.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/after3-smaller.png b/.zsh/zsh-syntax-highlighting/images/after3-smaller.png
new file mode 100644 (file)
index 0000000..d6aaa7b
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after3-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/after3.png b/.zsh/zsh-syntax-highlighting/images/after3.png
new file mode 100644 (file)
index 0000000..7a0af88
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/after3.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before1-smaller.png b/.zsh/zsh-syntax-highlighting/images/before1-smaller.png
new file mode 100644 (file)
index 0000000..b29551e
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before1-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before1.png b/.zsh/zsh-syntax-highlighting/images/before1.png
new file mode 100644 (file)
index 0000000..80c6f54
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before1.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before2-smaller.png b/.zsh/zsh-syntax-highlighting/images/before2-smaller.png
new file mode 100644 (file)
index 0000000..991a716
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before2-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before2.png b/.zsh/zsh-syntax-highlighting/images/before2.png
new file mode 100644 (file)
index 0000000..48cfc32
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before2.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before3-smaller.png b/.zsh/zsh-syntax-highlighting/images/before3-smaller.png
new file mode 100644 (file)
index 0000000..e525c6d
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before3-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/before3.png b/.zsh/zsh-syntax-highlighting/images/before3.png
new file mode 100644 (file)
index 0000000..40c3601
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/before3.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/preview-smaller.png b/.zsh/zsh-syntax-highlighting/images/preview-smaller.png
new file mode 100644 (file)
index 0000000..6fb84d1
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/preview-smaller.png differ
diff --git a/.zsh/zsh-syntax-highlighting/images/preview.png b/.zsh/zsh-syntax-highlighting/images/preview.png
new file mode 100644 (file)
index 0000000..545cc51
Binary files /dev/null and b/.zsh/zsh-syntax-highlighting/images/preview.png differ
diff --git a/.zsh/zsh-syntax-highlighting/release.md b/.zsh/zsh-syntax-highlighting/release.md
new file mode 100644 (file)
index 0000000..55a70f5
--- /dev/null
@@ -0,0 +1,18 @@
+# Release procedure (for developers):
+
+- For minor (A.B.0) releases:
+  - Check whether the release uses any not-yet-released zsh features
+- Check open issues and outstanding pull requests
+- Confirm `make test` passes
+  - check with multiple zsh versions
+- Update changelog.md
+  `tig --abbrev=12  --abbrev-commit 0.4.1..upstream/master`
+- Remove `-dev` suffix from `./.version`;
+  Commit that using `git commit -m "Tag version $(<.version)." .version`;
+  Tag it using `git tag -m "Tag version $(<.version)"`;
+  Increment `./.version` and restore the `-dev` suffix;
+  Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`.
+- Push with `git push && git push --tags`
+- Notify downstreams (OS packages)
+  - anitya should autodetect the tag
+- Update /topic on IRC
index 5526612..78433c3 100644 (file)
@@ -17,10 +17,15 @@ that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints.
 highlighting should be observed.
 If `$todo` exists, the test point is marked as TODO (the failure of that test
 point will not fail the test), and `$todo` is used as the explanation.
+If a test sets `$skip_test` to a non-empty string, the test will be skipped
+with the provided string as the reason.
 
 **Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
 interprets the indexes differently.
 
+**Note**: Tests are run with `setopt NOUNSET WARN_CREATE_GLOBAL`, so any
+variables the test creates must be declared local.
+
 **Isolation**: Each test is run in a separate subshell, so any variables,
 aliases, functions, etc., it defines will be visible to the tested code (that
 computes `$region_highlight`), but will not affect subsequent tests.  The
index cb645c6..eb24934 100755 (executable)
@@ -44,6 +44,10 @@ do
     (#* | <->..<->)
       print -nP %F{blue}
       ;;
+    # SKIP
+    (*# SKIP*)
+      print -nP %F{yellow}
+      ;;
     # XPASS
     (ok*# TODO*)
       print -nP %F{red}
index 1d169d6..a7b98a5 100755 (executable)
@@ -29,6 +29,8 @@
 # -------------------------------------------------------------------------------------------------
 
 
+setopt NO_UNSET WARN_CREATE_GLOBAL
+
 # Check an highlighter was given as argument.
 [[ -n "$1" ]] || {
   echo >&2 "Bail out! You must provide the name of a valid highlighter as argument."
   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.
+# 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
+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
 _zsh_highlight_add_highlight()
@@ -70,20 +97,26 @@ run_test_internal() {
   echo "# ${1:t:r}"
 
   # Load the data and prepare checking it.
-  PREBUFFER= BUFFER= ;
+  local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET skip_test
+  local -a expected_region_highlight region_highlight
   . "$srcdir"/"$1"
 
+  (( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; }
+
   # Check the data declares $PREBUFFER or $BUFFER.
   [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; }
   # Check the data declares $expected_region_highlight.
   (( ${#expected_region_highlight} == 0 )) && { echo >&2 "Bail out! 'expected_region_highlight' is not declared or empty."; return 1; }
 
+  # Set sane defaults for ZLE variables
+  : ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget}
+
   # Process the data.
-  region_highlight=()
   _zsh_highlight
 
   # Overlapping regions can be declared in region_highlight, so we first build an array of the
   # observed highlighting.
+  local i j
   local -A observed_result
   for ((i=1; i<=${#region_highlight}; i++)); do
     local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} )
@@ -110,12 +143,16 @@ run_test_internal() {
     integer start=$highlight_zone[1] end=$highlight_zone[2]
     # Escape # as ♯ since the former is illegal in the 'description' part of TAP output
     local desc="[$start,$end] «${BUFFER[$start,$end]//'#'/♯}»"
-    # Match the emptiness of observed_result if no highlighting is expected
-    [[ $highlight_zone[3] == NONE ]] && highlight_zone[3]=
-    [[ -n "$highlight_zone[4]" ]] && todo="# TODO $highlight_zone[4]"
+    (( $+highlight_zone[4] )) && todo="# TODO $highlight_zone[4]"
     for j in {$start..$end}; do
-      if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then
-        print -r -- "not ok $i - $desc - expected ${(qqq)highlight_zone[3]}, observed ${(qqq)observed_result[$j]}. $todo"
+      if
+       if [[ $highlight_zone[3] == NONE ]]; then
+         (( $+observed_result[$j] ))
+       else
+         [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]
+       fi
+      then
+        print -r -- "not ok $i - $desc - expected ${(qqq)highlight_zone[3]}, observed ${(qqq)observed_result[$j]-NONE}. $todo"
         continue 2
       fi
     done
@@ -157,19 +194,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.
 integer something_failed=0
 ZSH_HIGHLIGHT_STYLES=()
deleted file mode 120000 (symlink)
index cc95cd491cf8c977ba5e2639f54c9107ffa7e950..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-zsh-syntax-highlighting.zsh
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..f2456aecd5de5856dd43b57c3b51f45772adba53
--- /dev/null
@@ -0,0 +1,2 @@
+0=${(%):-%N}
+source ${0:A:h}/zsh-syntax-highlighting.zsh
index ec01306..e4e44fa 100644 (file)
 # 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.
 0=${(%):-%N}
@@ -46,6 +53,15 @@ fi
 # 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.
 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.
   # For details see FAQ entry 'Why does syntax highlighting not work while searching history?'.
-  if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCHMATCH_ACTIVE )); 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=()
     return $ret
   fi
@@ -170,7 +188,11 @@ _zsh_highlight_apply_zle_highlight() {
   integer first="$3" second="$4"
 
   # read the relevant entry from zle_highlight
-  local region="${zle_highlight[(r)${entry}:*]}"
+  #
+  # ### In zsh≥5.0.8 we'd use ${(b)entry}, but we support older zsh's, so we don't
+  # ### add (b).  The only effect is on the failure mode for callers that violate
+  # ### the precondition.
+  local region="${zle_highlight[(r)${entry}:*]-}"
 
   if [[ -z "$region" ]]; then
     # entry not specified at all, use default value
@@ -277,7 +299,7 @@ _zsh_highlight_bind_widgets()
 
   local cur_widget
   for cur_widget in $widgets_to_bind; do
-    case $widgets[$cur_widget] in
+    case ${widgets[$cur_widget]:-""} in
 
       # Already rebound event: do nothing.
       user:_zsh_highlight_widget_*);;
@@ -304,12 +326,13 @@ _zsh_highlight_bind_widgets()
 
       # Incomplete or nonexistent widget: Bind to z-sy-h directly.
       *) 
-         if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
+         if [[ $cur_widget == zle-* ]] && (( ! ${+widgets[$cur_widget]} )); then
            _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
            zle -N $cur_widget _zsh_highlight_widget_$cur_widget
          else
       # Default: unhandled case.
            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
     esac
   done
@@ -333,8 +356,8 @@ _zsh_highlight_load_highlighters()
   local highlighter highlighter_dir
   for highlighter_dir ($1/*/); do
     highlighter="${highlighter_dir:t}"
-    [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] &&
-      . "$highlighter_dir/${highlighter}-highlighter.zsh"
+    [[ -f "$highlighter_dir${highlighter}-highlighter.zsh" ]] &&
+      . "$highlighter_dir${highlighter}-highlighter.zsh"
     if type "_zsh_highlight_highlighter_${highlighter}_paint" &> /dev/null &&
        type "_zsh_highlight_highlighter_${highlighter}_predicate" &> /dev/null;
     then
@@ -351,7 +374,7 @@ _zsh_highlight_load_highlighters()
         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 \"\$@\" }"
     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
   done
 }
@@ -369,7 +392,7 @@ _zsh_highlight_bind_widgets || {
 
 # Resolve highlighters directory location.
 _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
 }
 
@@ -387,7 +410,12 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
 # Load zsh/parameter module if available
 zmodload zsh/parameter 2>/dev/null || true
 
-autoload -U is-at-least
-
 # 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