pax_global_header00006660000000000000000000000064126522272630014521gustar00rootroot0000000000000052 comment=c19ee583138ebab416b0d2efafbad7dc9f3f7c4f zsh-syntax-highlighting-0.4.1/000077500000000000000000000000001265222726300163165ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/.gitattributes000066400000000000000000000000341265222726300212060ustar00rootroot00000000000000.revision-hash export-subst zsh-syntax-highlighting-0.4.1/.gitignore000066400000000000000000000000301265222726300202770ustar00rootroot00000000000000*.zwc* .pc/ docs/all.md zsh-syntax-highlighting-0.4.1/.revision-hash000066400000000000000000000000511265222726300210720ustar00rootroot00000000000000c19ee583138ebab416b0d2efafbad7dc9f3f7c4f zsh-syntax-highlighting-0.4.1/.version000066400000000000000000000000061265222726300200000ustar00rootroot000000000000000.4.1 zsh-syntax-highlighting-0.4.1/COPYING.md000066400000000000000000000030101265222726300177420ustar00rootroot00000000000000Copyright (c) 2010-2015 zsh-syntax-highlighting contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zsh-syntax-highlighting-0.4.1/INSTALL.md000066400000000000000000000042231265222726300177470ustar00rootroot00000000000000How to install -------------- ### Using packages * Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package] * Gentoo: [mv overlay][gentoo-overlay] * Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package] [arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting [AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git [gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting [brew-package]: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh-syntax-highlighting.rb ### In your ~/.zshrc Simply clone this repository and source the script: git clone git://github.com/zsh-users/zsh-syntax-highlighting.git echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc source ~/.zshrc 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 oh-my-zsh Oh-my-zsh is a zsh configuration framework. It lives at . To install zsh-syntax-highlighting under oh-my-zsh: 1. Clone this repository in oh-my-zsh's plugins directory: git clone git://github.com/zsh-users/zsh-syntax-highlighting.git ~/.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 Note that `zsh-syntax-highlighting` must be the last plugin sourced, so make it the last element of the `$plugins` array. ### System-wide installation Either 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. zsh-syntax-highlighting-0.4.1/Makefile000066400000000000000000000032701265222726300177600ustar00rootroot00000000000000NAME=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) 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: @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 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 zsh-syntax-highlighting-0.4.1/README.md000066400000000000000000000026441265222726300176030ustar00rootroot00000000000000zsh-syntax-highlighting ======================= **[Fish shell][fish]-like like syntax highlighting for [Zsh][zsh].** *Requirements: zsh 4.3.17+.* [fish]: http://www.fishshell.com/ [zsh]: http://www.zsh.org/ This package provides syntax highlighing for the shell zsh. It enables highlighing of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors. [![Screenshot](images/preview-smaller.png)](images/preview.png) How to install -------------- See [INSTALL.md](INSTALL.md). FAQ --- ### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file? `zsh-syntax-highlighting.zsh` wraps ZLE widgets. It must be sourced after all custom widgets have been created (i.e., after all `zle -N` calls and after running `compinit`). Widgets created later will work, but will not update the syntax highlighting. ### How are new releases announced? There is currently no "push" announcements channel. However, the following alternatives exist: - GitHub's RSS feed of releases: https://github.com/zsh-users/zsh-syntax-highlighting/releases.atom - An anitya entry: https://release-monitoring.org/project/7552/ How to tweak ------------ Syntax highlighting is done by pluggable highlighter scripts. See the [documentation on highlighters](docs/highlighters.md) for details and configuration settings. zsh-syntax-highlighting-0.4.1/changelog.md000066400000000000000000000123651265222726300205760ustar00rootroot00000000000000 # 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 - 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.) zsh-syntax-highlighting-0.4.1/docs/000077500000000000000000000000001265222726300172465ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/docs/highlighters.md000066400000000000000000000051761265222726300222620ustar00rootroot00000000000000zsh-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 `myhighlighter` highlighter: * Create your script at `highlighters/${myhighlighter}/${myhighlighter}-highlighter.zsh`. * Implement the `_zsh_highlight_myhighlighter_highlighter_predicate` function. This function must return 0 when the highlighter needs to be called and non-zero otherwise, for example: _zsh_highlight_myhighlighter_highlighter_predicate() { # Call this highlighter in SVN working copies [[ -d .svn ]] } * Implement the `_zsh_highlight_myhighlighter_highlighter` function. This function does the actual syntax highlighting, by modifying `region_highlight`, for example: _zsh_highlight_myhighlighter_highlighter() { # Colorize the whole buffer with blue background region_highlight+=(0 $#BUFFER bg=blue) } * Activate your highlighter in `~/.zshrc`: ZSH_HIGHLIGHT_HIGHLIGHTERS+=(myhighlighter) zsh-syntax-highlighting-0.4.1/docs/highlighters/000077500000000000000000000000001265222726300217275ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/docs/highlighters/brackets.md000066400000000000000000000021751265222726300240540ustar00rootroot00000000000000zsh-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 zsh-syntax-highlighting-0.4.1/docs/highlighters/cursor.md000066400000000000000000000013631265222726300235710ustar00rootroot00000000000000zsh-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 zsh-syntax-highlighting-0.4.1/docs/highlighters/line.md000066400000000000000000000013351265222726300232020ustar00rootroot00000000000000zsh-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 zsh-syntax-highlighting-0.4.1/docs/highlighters/main.md000066400000000000000000000051041265222726300231750ustar00rootroot00000000000000zsh-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_prefix` - prefixes of existing filenames * `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`) * `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]. [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting zsh-syntax-highlighting-0.4.1/docs/highlighters/pattern.md000066400000000000000000000014021265222726300237230ustar00rootroot00000000000000zsh-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 zsh-syntax-highlighting-0.4.1/docs/highlighters/root.md000066400000000000000000000014301265222726300232320ustar00rootroot00000000000000zsh-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 zsh-syntax-highlighting-0.4.1/highlighters/000077500000000000000000000000001265222726300207775ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/README.md000066400000000000000000000004641265222726300222620ustar00rootroot00000000000000zsh-syntax-highlighting / highlighters ====================================== Navigate into the individual highlighters' documentation to see what styles (`$ZSH_HIGHLIGHT_STYLES` keys) each highlighter defines. Refer to the [documentation on highlighters](../docs/highlighters.md) for further information. zsh-syntax-highlighting-0.4.1/highlighters/brackets/000077500000000000000000000000001265222726300225755ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/brackets/README.md000077700000000000000000000000001265222726300322262../../docs/highlighters/brackets.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/brackets/brackets-highlighter.zsh000066400000000000000000000111111265222726300274100ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- # Define default styles. : ${ZSH_HIGHLIGHT_STYLES[bracket-error]:=fg=red,bold} : ${ZSH_HIGHLIGHT_STYLES[bracket-level-1]:=fg=blue,bold} : ${ZSH_HIGHLIGHT_STYLES[bracket-level-2]:=fg=green,bold} : ${ZSH_HIGHLIGHT_STYLES[bracket-level-3]:=fg=magenta,bold} : ${ZSH_HIGHLIGHT_STYLES[bracket-level-4]:=fg=yellow,bold} : ${ZSH_HIGHLIGHT_STYLES[bracket-level-5]:=fg=cyan,bold} : ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout} # Whether the brackets highlighter should be called or not. _zsh_highlight_brackets_highlighter_predicate() { _zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified } # Brackets highlighting function. _zsh_highlight_brackets_highlighter() { local level=0 pos local -A levelpos lastoflevel matching typepos region_highlight=() # Find all brackets and remember which one is matching for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do local char="$BUFFER[pos+1]" case $char in ["([{"]) levelpos[$pos]=$((++level)) lastoflevel[$level]=$pos _zsh_highlight_brackets_highlighter_brackettype "$char" ;; [")]}"]) matching[$lastoflevel[$level]]=$pos matching[$pos]=$lastoflevel[$level] levelpos[$pos]=$((level--)) _zsh_highlight_brackets_highlighter_brackettype "$char" ;; ['"'\']) # Skip everything inside quotes local quotetype=$char while (( $pos < ${#BUFFER} )) ; do (( pos++ )) [[ $BUFFER[$pos+1] == $quotetype ]] && break done ;; esac done # Now highlight all found brackets for pos in ${(k)levelpos}; do if [[ -n $matching[$pos] ]] && [[ $typepos[$pos] == $typepos[$matching[$pos]] ]]; then local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} local bracket_color_level=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 )) local style=$ZSH_HIGHLIGHT_STYLES[$bracket_color_level] region_highlight+=("$pos $((pos + 1)) $style") else local style=$ZSH_HIGHLIGHT_STYLES[bracket-error] region_highlight+=("$pos $((pos + 1)) $style") fi done # If cursor is on a bracket, then highlight corresponding bracket, if any pos=$CURSOR if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then local otherpos=$matching[$pos] local style=$ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket] region_highlight+=("$otherpos $((otherpos + 1)) $style") fi } # Helper function to differentiate type _zsh_highlight_brackets_highlighter_brackettype() { case $1 in ["()"]) typepos[$pos]=round;; ["[]"]) typepos[$pos]=bracket;; ["{}"]) typepos[$pos]=curly;; *) ;; esac } zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/000077500000000000000000000000001265222726300244635ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/mismatch-patentheses.zsh000066400000000000000000000043141265222726300313410ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo ({x}]' expected_region_highlight=( "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } "10 10 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/nested-parentheses.zsh000066400000000000000000000045101265222726300310120ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo $(echo ${(z)array})' expected_region_highlight=( "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( "14 14 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { "15 15 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ( "17 17 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ) "23 23 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } "24 24 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/quoted-patentheses.zsh000066400000000000000000000041321265222726300310330ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo "foo ( bar"' expected_region_highlight=( "1 16 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing ) zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/simple-parentheses.zsh000066400000000000000000000043201265222726300310200ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo ({x})' expected_region_highlight=( "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } "10 10 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/unclosed-patentheses.zsh000066400000000000000000000042301265222726300313450ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo ({x}' expected_region_highlight=( "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } ) zsh-syntax-highlighting-0.4.1/highlighters/brackets/test-data/unclosed-patentheses2.zsh000066400000000000000000000042271265222726300314350ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo {x})' expected_region_highlight=( "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # { "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # } "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/cursor/000077500000000000000000000000001265222726300223145ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/cursor/README.md000077700000000000000000000000001265222726300314642../../docs/highlighters/cursor.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/cursor/cursor-highlighter.zsh000066400000000000000000000046731265222726300266650ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- # Define default styles. : ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout} # Whether the cursor highlighter should be called or not. _zsh_highlight_cursor_highlighter_predicate() { # accept-* may trigger removal of cursor highlighting [[ $WIDGET == accept-* ]] || _zsh_highlight_cursor_moved } # Cursor highlighting function. _zsh_highlight_cursor_highlighter() { [[ $WIDGET == accept-* ]] && return region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]") } zsh-syntax-highlighting-0.4.1/highlighters/line/000077500000000000000000000000001265222726300217265ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/line/README.md000077700000000000000000000000001265222726300305102../../docs/highlighters/line.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/line/line-highlighter.zsh000066400000000000000000000044301265222726300257000ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- # Define default styles. : ${ZSH_HIGHLIGHT_STYLES[line]:=} # Whether the root highlighter should be called or not. _zsh_highlight_line_highlighter_predicate() { _zsh_highlight_buffer_modified } # root highlighting function. _zsh_highlight_line_highlighter() { region_highlight+=("0 $#BUFFER $ZSH_HIGHLIGHT_STYLES[line]") } zsh-syntax-highlighting-0.4.1/highlighters/main/000077500000000000000000000000001265222726300217235ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/main/README.md000077700000000000000000000000001265222726300305022../../docs/highlighters/main.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/main/main-highlighter.zsh000066400000000000000000000570261265222726300257030ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Define default styles. : ${ZSH_HIGHLIGHT_STYLES[default]:=none} : ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} : ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[alias]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline} : ${ZSH_HIGHLIGHT_STYLES[builtin]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[function]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[command]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline} : ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none} : ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green} : ${ZSH_HIGHLIGHT_STYLES[path]:=underline} : ${ZSH_HIGHLIGHT_STYLES[path_prefix]:=underline} : ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue} : ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none} : ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none} : ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none} : ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow} : ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan} : ${ZSH_HIGHLIGHT_STYLES[assign]:=none} : ${ZSH_HIGHLIGHT_STYLES[redirection]:=none} : ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold} # Whether the highlighter should be called or not. _zsh_highlight_main_highlighter_predicate() { # accept-* may trigger removal of path_prefix highlighting [[ $WIDGET == accept-* ]] || _zsh_highlight_buffer_modified } # Helper to deal with tokens crossing line boundaries. _zsh_highlight_main_add_region_highlight() { integer start=$1 end=$2 local style=$3 # The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is # relative to $BUFFER. (( start -= $#PREBUFFER )) (( end -= $#PREBUFFER )) (( end < 0 )) && return # having end<0 would be a bug (( start < 0 )) && start=0 # having start<0 is normal with e.g. multiline strings region_highlight+=("$start $end $style") } # Wrapper around 'type -w'. # # Takes a single argument and outputs the output of 'type -w $1'. # # NOTE: This runs 'setopt', but that should be safe since it'll only ever be # called inside a $(...) subshell, so the effects will be local. _zsh_highlight_main__type() { if (( $#options_to_set )); then setopt $options_to_set; fi LC_ALL=C builtin type -w -- $1 2>/dev/null } # Main syntax highlighting function. _zsh_highlight_main_highlighter() { ## Before we even 'emulate -L', we must test a few options that would reset. if [[ -o interactive_comments ]]; then local interactive_comments= # set to empty fi if [[ -o path_dirs ]]; then integer path_dirs_was_set=1 else integer path_dirs_was_set=0 fi emulate -L zsh setopt localoptions extendedglob bareglobqual ## Variable declarations and initializations local start_pos=0 end_pos highlight_glob=true arg style local in_array_assignment=false # true between 'a=(' and the matching ')' typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW local -a options_to_set # used in callees local buf="$PREBUFFER$BUFFER" region_highlight=() if (( path_dirs_was_set )); then options_to_set+=( PATH_DIRS ) fi unset path_dirs_was_set ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( '|' '||' ';' '&' '&&' '|&' '&!' '&|' # ### 'case' syntax, but followed by a pattern, not by a command # ';;' ';&' ';|' ) ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=( 'builtin' 'command' 'exec' 'nocorrect' 'noglob' ) # Tokens that, at (naively-determined) "command position", are followed by # a de jure command position. All of these are reserved words. ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW=( $'\x7b' # block $'\x28' # subshell '()' # anonymous function 'while' 'until' 'if' 'then' 'elif' 'else' 'do' 'time' 'coproc' '!' # reserved word; unrelated to $histchars[1] ) # State machine # # The states are: # - :start: Command word # - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i") # - :sudo_arg: The argument to a sudo leading-dash option that takes one, # when given as a separate word; i.e., "foo" in "-u foo" (two # words) but not in "-ufoo" (one word). # - :regular: "Not a command word", and command delimiters are permitted. # Mainly used to detect premature termination of commands. # # When the kind of a word is not yet known, $this_word / $next_word may contain # multiple states. For example, after "sudo -i", the next word may be either # another --flag or a command name, hence the state would include both :start: # and :sudo_opt:. # # The tokens are always added with both leading and trailing colons to serve as # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} # will DTRT regardless of how many elements or repetitions $x has.. # # Handling of redirections: upon seeing a redirection token, we must stall # the current state --- that is, the value of $this_word --- for two iterations # (one for the redirection operator, one for the word following it representing # the redirection target). Therefore, we set $in_redirection to 2 upon seeing a # redirection operator, decrement it each iteration, and stall the current state # when it is non-zero. Thus, upon reaching the next word (the one that follows # the redirection operator and target), $this_word will still contain values # appropriate for the word immediately following the word that preceded the # redirection operator. # # The "the previous word was a redirection operator" state is not communicated # to the next iteration via $next_word/$this_word as usual, but via # $in_redirection. The value of $next_word from the iteration that processed # the operator is discarded. # local this_word=':start:' next_word integer in_redirection for arg in ${interactive_comments-${(z)buf}} \ ${interactive_comments+${(zZ+c+)buf}}; do if (( in_redirection )); then (( --in_redirection )) fi if (( in_redirection == 0 )); then # Initialize $next_word to its default value. next_word=':regular:' else # Stall $next_word. fi # $already_added is set to 1 to disable adding an entry to region_highlight # for this iteration. Currently, that is done for "" and $'' strings, # which add the entry early so escape sequences within the string override # the string's color. integer already_added=0 local style_override="" if [[ $this_word == *':start:'* ]]; then in_array_assignment=false if [[ $arg == 'noglob' ]]; then highlight_glob=false fi fi # advance $start_pos, skipping over whitespace in $buf. if [[ $arg == ';' ]] ; then # We're looking for either a semicolon or a newline, whichever comes # first. Both of these are rendered as a ";" (SEPER) by the ${(z)..} # flag. # # We can't use the (Z+n+) flag because that elides the end-of-command # token altogether, so 'echo foo\necho bar' (two commands) becomes # indistinguishable from 'echo foo echo bar' (one command with three # words for arguments). local needle=$'[;\n]' integer offset=${${buf[start_pos+1,-1]}[(i)$needle]} (( start_pos += offset - 1 )) (( end_pos = start_pos + $#arg )) else ((start_pos+=${#buf[$start_pos+1,-1]}-${#${buf[$start_pos+1,-1]##([[:space:]]|\\[[:space:]])#}})) ((end_pos=$start_pos+${#arg})) fi if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then if [[ $this_word == *(':regular:'|':start:')* ]]; then style=$ZSH_HIGHLIGHT_STYLES[comment] else style=$ZSH_HIGHLIGHT_STYLES[unknown-token] # prematurely terminated fi _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style already_added=1 continue fi # Parse the sudo command line if (( ! in_redirection )); then if [[ $this_word == *':sudo_opt:'* ]]; then case "$arg" in # Flag that requires an argument '-'[Cgprtu]) this_word=${this_word//:start:/}; next_word=':sudo_arg:';; # This prevents misbehavior with sudo -u -otherargument '-'*) this_word=${this_word//:start:/}; next_word+=':start:'; next_word+=':sudo_opt:';; *) ;; esac elif [[ $this_word == *':sudo_arg:'* ]]; then next_word+=':sudo_opt:' next_word+=':start:' fi fi if [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then style=$ZSH_HIGHLIGHT_STYLES[precommand] elif [[ "$arg" = "sudo" ]]; then style=$ZSH_HIGHLIGHT_STYLES[precommand] next_word=${next_word//:regular:/} next_word+=':sudo_opt:' next_word+=':start:' else _zsh_highlight_main_highlighter_expand_path $arg local expanded_arg="$REPLY" local res="$(_zsh_highlight_main__type ${expanded_arg})" () { # Special-case: command word is '$foo', like that, without braces or anything. # # That's not entirely correct --- if the parameter's value happens to be a reserved # word, the parameter expansion will be highlighted as a reserved word --- but that # incorrectness is outweighed by the usability improvement of permitting the use of # parameters that refer to commands, functions, and builtins. local -a match mbegin mend local MATCH; integer MBEGIN MEND if [[ $res == *': none' ]] && (( ${+parameters} )) && [[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]]; then res="$(_zsh_highlight_main__type ${(P)MATCH})" fi } case $res in *': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; *': suffix alias') style=$ZSH_HIGHLIGHT_STYLES[suffix-alias] ;; *': alias') style=$ZSH_HIGHLIGHT_STYLES[alias] local aliased_command="${"$(alias -- $arg)"#*=}" [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg) ;; *': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];; *': function') style=$ZSH_HIGHLIGHT_STYLES[function];; *': command') style=$ZSH_HIGHLIGHT_STYLES[command];; *': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];; *) if _zsh_highlight_main_highlighter_check_assign; then style=$ZSH_HIGHLIGHT_STYLES[assign] if [[ $arg[-1] == '(' ]]; then in_array_assignment=true else # assignment to a scalar parameter. # (For array assignments, the command doesn't start until the ")" token.) next_word+=':start:' fi elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then style=$ZSH_HIGHLIGHT_STYLES[history-expansion] elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] && [[ $this_word == *':regular:'* ]]; then # This highlights empty commands (semicolon follows nothing) as an error. # Zsh accepts them, though. style=$ZSH_HIGHLIGHT_STYLES[commandseparator] elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then style=$ZSH_HIGHLIGHT_STYLES[redirection] (( in_redirection=2 )) elif [[ $arg[1,2] == '((' ]]; then # Arithmetic evaluation. # # Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...} # splitter would only output the '((' token if the matching '))' had # been typed. Therefore, under those versions of zsh, BUFFER="(( 42" # would be highlighted as an error until the matching "))" are typed. # # We highlight just the opening parentheses, as a reserved word; this # is how [[ ... ]] is highlighted, too. style=$ZSH_HIGHLIGHT_STYLES[reserved-word] _zsh_highlight_main_add_region_highlight $start_pos $((start_pos + 2)) $style already_added=1 if [[ $arg[-2,-1] == '))' ]]; then _zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos $style already_added=1 fi elif [[ $arg == '()' || $arg == $'\x28' ]]; then # anonymous function # subshell style=$ZSH_HIGHLIGHT_STYLES[reserved-word] else if _zsh_highlight_main_highlighter_check_path; then style=$ZSH_HIGHLIGHT_STYLES[path] else style=$ZSH_HIGHLIGHT_STYLES[unknown-token] fi fi ;; esac fi else # $arg is a non-command word case $arg in $'\x29') # subshell or end of array assignment if $in_array_assignment; then style=$ZSH_HIGHLIGHT_STYLES[assign] in_array_assignment=false else style=$ZSH_HIGHLIGHT_STYLES[reserved-word] fi;; $'\x7d') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; # block '--'*) style=$ZSH_HIGHLIGHT_STYLES[double-hyphen-option];; '-'*) style=$ZSH_HIGHLIGHT_STYLES[single-hyphen-option];; "'"*) style=$ZSH_HIGHLIGHT_STYLES[single-quoted-argument];; '"'*) style=$ZSH_HIGHLIGHT_STYLES[double-quoted-argument] _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style _zsh_highlight_main_highlighter_highlight_string already_added=1 ;; \$\'*) style=$ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument] _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style _zsh_highlight_main_highlighter_highlight_dollar_string already_added=1 ;; '`'*) style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];; [*?]*|*[^\\][*?]*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];; *) if false; then elif [[ $arg[0,1] = $histchars[0,1] ]]; then style=$ZSH_HIGHLIGHT_STYLES[history-expansion] elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then if [[ $this_word == *':regular:'* ]]; then style=$ZSH_HIGHLIGHT_STYLES[commandseparator] else style=$ZSH_HIGHLIGHT_STYLES[unknown-token] fi elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then style=$ZSH_HIGHLIGHT_STYLES[redirection] (( in_redirection=2 )) else if _zsh_highlight_main_highlighter_check_path; then style=$ZSH_HIGHLIGHT_STYLES[path] else style=$ZSH_HIGHLIGHT_STYLES[default] fi fi ;; esac fi # if a style_override was set (eg in _zsh_highlight_main_highlighter_check_path), use it [[ -n $style_override ]] && style=$ZSH_HIGHLIGHT_STYLES[$style_override] (( already_added )) || _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then next_word=':start:' highlight_glob=true elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] || [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then next_word=':start:' elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then # skip the repeat-count word in_redirection=2 # The redirection mechanism assumes $this_word describes the word # following the redirection. Make it so. # # The repeat-count word will be handled like a redirection target. this_word=':start:' fi start_pos=$end_pos (( in_redirection == 0 )) && this_word=$next_word done } # Check if $arg is variable assignment _zsh_highlight_main_highlighter_check_assign() { setopt localoptions extended_glob [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]] } # Check if $arg is a path. _zsh_highlight_main_highlighter_check_path() { _zsh_highlight_main_highlighter_expand_path $arg; local expanded_path="$REPLY" [[ -z $expanded_path ]] && return 1 [[ -e $expanded_path ]] && return 0 # Search the path in CDPATH local cdpath_dir for cdpath_dir in $cdpath ; do [[ -e "$cdpath_dir/$expanded_path" ]] && return 0 done # If dirname($arg) doesn't exist, neither does $arg. [[ ! -e ${expanded_path:h} ]] && return 1 # If this word ends the buffer, check if it's the prefix of a valid path. if [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos ]] && [[ $WIDGET != accept-* ]]; then local -a tmp tmp=( ${expanded_path}*(N) ) (( $#tmp > 0 )) && style_override=path_prefix && return 0 fi # It's not a path. return 1 } # Highlight special chars inside double-quoted strings _zsh_highlight_main_highlighter_highlight_string() { setopt localoptions noksharrays local -a match mbegin mend local MATCH; integer MBEGIN MEND local i j k style # Starting quote is at 1, so start parsing at offset 2 in the string. for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) (( k = j + 1 )) case "$arg[$i]" in '$' ) style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument] # Look for an alphanumeric parameter name. if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then (( k += $#MATCH )) # highlight the parameter name (( i += $#MATCH )) # skip past it elif [[ ${arg:$i} =~ ^[{]([A-Za-z_][A-Za-z0-9_]*|[0-9]+)[}] ]] ; then (( k += $#MATCH )) # highlight the parameter name and braces (( i += $#MATCH )) # skip past it else continue fi ;; "\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument] if [[ \\\`\"\$ == *$arg[$i+1]* ]]; then (( k += 1 )) # Color following char too. (( i += 1 )) # Skip parsing the escaped char. else continue fi ;; *) continue ;; esac _zsh_highlight_main_add_region_highlight $j $k $style done } # Highlight special chars inside dollar-quoted strings _zsh_highlight_main_highlighter_highlight_dollar_string() { setopt localoptions noksharrays local -a match mbegin mend local MATCH; integer MBEGIN MEND local i j k style local AA integer c # Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string. for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) (( k = j + 1 )) case "$arg[$i]" in "\\") style=$ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument] for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break done AA=$arg[$i+1,$c-1] # Matching for HEX and OCT values like \0xA6, \xA6 or \012 if [[ "$AA" =~ "^(x|X)[0-9a-fA-F]{1,2}" || "$AA" =~ "^[0-7]{1,3}" || "$AA" =~ "^u[0-9a-fA-F]{1,4}" || "$AA" =~ "^U[0-9a-fA-F]{1,8}" ]]; then (( k += $#MATCH )) (( i += $#MATCH )) else if (( $#arg > $i+1 )) && [[ $arg[$i+1] == [xXuU] ]]; then # \x not followed by hex digits is probably an error style=$ZSH_HIGHLIGHT_STYLES[unknown-token] fi (( k += 1 )) # Color following char too. (( i += 1 )) # Skip parsing the escaped char. fi ;; *) continue ;; esac _zsh_highlight_main_add_region_highlight $j $k $style done } # Called with a single positional argument. # Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value. # # Does not perform filename generation (globbing). _zsh_highlight_main_highlighter_expand_path() { (( $# == 1 )) || echo "zsh-syntax-highlighting: BUG: _zsh_highlight_main_highlighter_expand_path: called without argument" >&2 # The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}. setopt localoptions nonomatch unset REPLY : ${REPLY:=${(Q)~1}} } zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/000077500000000000000000000000001265222726300236115ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/alias.zsh000066400000000000000000000052741265222726300254400ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- alias alias1="unused expansion" alias -s alias2="echo" alias1() {} # to check that it's highlighted as an alias, not as a function ZSH_HIGHLIGHT_STYLES[alias]=$unused_highlight BUFFER='x.alias2; alias1' # Set expected_region_highlight as a function of zsh version. # # Highlight of suffix alias requires zsh-5.1.1 or newer; see issue #126, # and commit 36403 to zsh itself. Therefore, check if the requisite zsh # functionality is present, and skip verifying suffix-alias highlighting # if it isn't. expected_region_highlight=() if [[ "$(type -w x.alias2)" == *suffix* ]]; then expected_region_highlight+=( "1 8 $ZSH_HIGHLIGHT_STYLES[suffix-alias]" # x.alias2 ) fi expected_region_highlight+=( "11 16 $ZSH_HIGHLIGHT_STYLES[alias]" # alias1 ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/anonymous-function.zsh000066400000000000000000000045601265222726300302170ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='() echo hello; () { echo world }' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # () "4 7 $ZSH_HIGHLIGHT_STYLES[command]" # echo "9 13 $ZSH_HIGHLIGHT_STYLES[default]" # hello "14 14 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "16 17 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # () "19 19 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # { "21 24 $ZSH_HIGHLIGHT_STYLES[command]" # echo ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/arithmetic-evaluation.zsh000066400000000000000000000045261265222726300306440ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Must be at command word, since the word following 'if' isn't currently considered # a command word (issue #207). # # An opening '((' without matching '))' is highlighted correctly under zsh-5.1.1-52-g4bed2cf # or newer, only (issue #188). BUFFER='(( x == 42 ))' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # (( "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # )) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/assign-append.zsh000066400000000000000000000041361265222726300270740ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='a+=(lorem ipsum)' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[assign]" # a+=( ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/assign-array.zsh000066400000000000000000000043561265222726300267470ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='(A=(hello world))' expected_region_highlight=( "1 1 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ( "2 4 $ZSH_HIGHLIGHT_STYLES[assign]" # A=( "16 16 $ZSH_HIGHLIGHT_STYLES[assign]" # ) "17 17 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/assign-semicolon.zsh000066400000000000000000000042421265222726300276130ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[commandseparator]=$unused_highlight BUFFER='A=1; echo hello world' expected_region_highlight=( "4 4 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "6 9 $ZSH_HIGHLIGHT_STYLES[command]" # echo ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/assign-subshell.zsh000066400000000000000000000043011265222726300274400ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='(A=1)' expected_region_highlight=( "1 1 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ( "2 4 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1 "5 5 $ZSH_HIGHLIGHT_STYLES[reserved-word] 'issue #231'" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/assign.zsh000066400000000000000000000043651265222726300256330ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER='A=1 b=("foo" bar)' expected_region_highlight=( "1 3 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1 "5 7 $ZSH_HIGHLIGHT_STYLES[assign]" # b=( "8 12 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo" "17 17 $ZSH_HIGHLIGHT_STYLES[assign]" # ) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/back-quoted-argument.zsh000066400000000000000000000041621265222726300303610ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=$unused_highlight BUFFER='echo `echo 42`' expected_region_highlight=( "6 14 $ZSH_HIGHLIGHT_STYLES[back-quoted-argument]" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/backslash-continuation.zsh000066400000000000000000000041231265222726300310020ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- PREBUFFER=$'echo \\\n' BUFFER='noglob' expected_region_highlight=( "1 6 none" # 'noglob' highlighted as a string, not as a precomand ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/commandseparator.zsh000066400000000000000000000043741265222726300277060ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[commandseparator]=$unused_highlight BUFFER=':; pwd &! ls' expected_region_highlight=( "2 2 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "4 6 $ZSH_HIGHLIGHT_STYLES[builtin]" # pwd "8 9 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # &! "11 12 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/comment-leading.zsh000066400000000000000000000042061265222726300274040ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- setopt interactive_comments BUFFER='# echo foo' expected_region_highlight=( "1 1 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # # "2 10 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # " echo foo" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/comment-off.zsh000066400000000000000000000043111265222726300265500ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- unsetopt interactive_comments BUFFER='# echo foo' expected_region_highlight=( "1 1 ${(q-)ZSH_HIGHLIGHT_STYLES[unknown-token]}" # # "3 6 ${(q-)ZSH_HIGHLIGHT_STYLES[default]}" # " echo foo" "8 10 ${(q-)ZSH_HIGHLIGHT_STYLES[default]}" # " echo foo" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/comments.zsh000066400000000000000000000043311265222726300261650ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- setopt interactive_comments BUFFER='echo "foo #bar" #baz # quux' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[command]" # echo "6 15 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo #bar" "17 27 ${(q-)ZSH_HIGHLIGHT_STYLES[comment]}" # #baz # quux ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/commmand-parameter.zsh000066400000000000000000000041761265222726300301200ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- x=/usr/bin/env BUFFER='$x "argument"' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # $x "4 13 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "argument" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/control-flow.zsh000066400000000000000000000057171265222726300267760ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[alias]=$unused_highlight BUFFER='while if echo Hello; then ls /; else ls; fi; do stat "x"; done; repeat 10 ls' expected_region_highlight+=( "1 5 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # while "7 8 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # if "10 13 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo "15 19 $ZSH_HIGHLIGHT_STYLES[default]" # Hello "22 25 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # then "27 28 $ZSH_HIGHLIGHT_STYLES[command]" # ls "30 30 $ZSH_HIGHLIGHT_STYLES[path]" # / "31 31 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "33 36 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # else "38 39 $ZSH_HIGHLIGHT_STYLES[command]" # ls "42 43 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # fi "46 47 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # do "49 52 $ZSH_HIGHLIGHT_STYLES[command]" # stat "54 56 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "x" "59 62 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done "65 70 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat "75 76 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/dollar-quoted.zsh000066400000000000000000000043071265222726300271170ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=$unused_highlight BUFFER=": \$'*' 'foo'" expected_region_highlight=( "3 6 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $'*' - not a glob "8 12 $ZSH_HIGHLIGHT_STYLES[single-quoted-argument]" # 'foo' ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/dollar-quoted2.zsh000066400000000000000000000050111265222726300271720ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=$unused_highlight BUFFER=": \$'foo\xbar\udeadbeef\uzzzz'" expected_region_highlight=( "3 7 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $'foo "8 11 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \xba "12 12 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # r "13 18 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \dead "19 22 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # beef "23 24 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # \u "25 29 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # zzzz' ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/dollar-quoted3.zsh000066400000000000000000000044661265222726300272100ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Similar to double-quoted2.zsh ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=$unused_highlight # This test checks that the '1' gets highlighted correctly. Do not append to the BUFFER. BUFFER=": \$'\xa1" expected_region_highlight=( "3 4 $ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]" # $' "5 8 $ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]" # \xa1 ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/double-hyphen-option.zsh000066400000000000000000000041731265222726300304150ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=$unused_highlight BUFFER='hello --world' expected_region_highlight=( "7 13 $ZSH_HIGHLIGHT_STYLES[double-hyphen-option]" # --world ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/double-quoted.zsh000066400000000000000000000053151265222726300271140ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER=': "foo$bar:\`:\":\$:' BUFFER+=\\\\:\" expected_region_highlight=( "3 6 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo "7 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $bar "11 11 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : "12 13 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \` "14 14 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : "15 16 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \$ "17 17 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : "18 19 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \" "20 20 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # : "21 22 $ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]" # \\ "23 24 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # :" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/double-quoted2.zsh000066400000000000000000000043701265222726300271760ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Similar to dollar-quoted3.zsh # This test checks that the 'r' gets highlighted correctly. Do not append to the BUFFER. BUFFER=': "foo$bar' expected_region_highlight=( "3 6 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo "7 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $bar ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/double-quoted3.zsh000066400000000000000000000045651265222726300272050ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER=': "$" "$42foo"' BUFFER+=\ \"\\\'\\x\" expected_region_highlight=( "3 5 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "$" "7 7 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # " "8 10 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # $42 "11 14 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # foo" "16 21 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "\'\x" - \' and \x are not escape sequences ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/double-quoted4.zsh000066400000000000000000000042761265222726300272050ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER=': "${foo}bar"' expected_region_highlight=( "3 3 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # " "4 9 $ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]" # ${foo} "10 13 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # bar" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/empty-command.zsh000066400000000000000000000041361265222726300271150ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='echo; ;' expected_region_highlight=( "5 5 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "7 7 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ; ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/function.zsh000066400000000000000000000046601265222726300261720ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[function]=$unused_highlight cd() { builtin cd "$@" } ls() { command ls "$@" } BUFFER='cd;ls' # Use $unused_highlight to see that function highlighting has precedence over command and builtin expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[function]" # cd "4 5 $ZSH_HIGHLIGHT_STYLES[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. zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/glob.zsh000066400000000000000000000043641265222726300252710ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER=': foo* bar? *baz qux\?' expected_region_highlight=( "1 1 $ZSH_HIGHLIGHT_STYLES[builtin]" # : "3 6 $ZSH_HIGHLIGHT_STYLES[globbing]" # foo* "8 11 $ZSH_HIGHLIGHT_STYLES[globbing]" # bar? "13 16 $ZSH_HIGHLIGHT_STYLES[globbing]" # *baz "18 22 $ZSH_HIGHLIGHT_STYLES[default]" # qux\? ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/hashed-command.zsh000066400000000000000000000042441265222726300272130ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- hash zsh_syntax_highlighting_hash=/doesnotexist ZSH_HIGHLIGHT_STYLES[hashed-command]=$unused_highlight BUFFER='zsh_syntax_highlighting_hash' expected_region_highlight=( "1 28 $ZSH_HIGHLIGHT_STYLES[hashed-command]" ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/history-expansion.zsh000066400000000000000000000042361265222726300300470ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='!foo bar !baz' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # !foo "6 8 $ZSH_HIGHLIGHT_STYLES[default]" # bar "10 13 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # !baz ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/history-expansion2.zsh000066400000000000000000000040661265222726300301320ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='^foo^bar' expected_region_highlight=( "1 8 $ZSH_HIGHLIGHT_STYLES[history-expansion]" # ^foo^bar ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/multiline-string.zsh000066400000000000000000000041771265222726300276560ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- PREBUFFER=$'echo "foo1\n' BUFFER='foo2" ./' expected_region_highlight=( "1 5 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # 'foo2"' "7 8 $ZSH_HIGHLIGHT_STYLES[path]" # './' ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/multiline-string2.zsh000066400000000000000000000041771265222726300277400ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=$unused_highlight BUFFER=$'echo "foo1\n' expected_region_highlight=( "6 10 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # 'foo2"' ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/multiple-redirections.zsh000066400000000000000000000052031265222726300306620ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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='ps aux | grep java | sort | uniq | tail | head' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | "10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep "15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java "20 20 $ZSH_HIGHLIGHT_STYLES[default]" # | "22 25 $ZSH_HIGHLIGHT_STYLES[command]" # sort "27 27 $ZSH_HIGHLIGHT_STYLES[default]" # | "29 32 $ZSH_HIGHLIGHT_STYLES[command]" # uniq "34 34 $ZSH_HIGHLIGHT_STYLES[default]" # | "36 39 $ZSH_HIGHLIGHT_STYLES[command]" # tail "41 41 $ZSH_HIGHLIGHT_STYLES[default]" # | "43 46 $ZSH_HIGHLIGHT_STYLES[command]" # head ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/noglob-alias.zsh000066400000000000000000000040621265222726300267100ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- alias x=command BUFFER='x ls' expected_region_highlight=( "3 4 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/noglob1.zsh000066400000000000000000000040571265222726300257060ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER=':; noglob echo *' expected_region_highlight=( "16 16 $ZSH_HIGHLIGHT_STYLES[default]" # * ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/noglob2.zsh000066400000000000000000000041421265222726300257020ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='noglob echo *; echo *' expected_region_highlight=( "13 13 $ZSH_HIGHLIGHT_STYLES[default]" # * "21 21 $ZSH_HIGHLIGHT_STYLES[globbing]" # * ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/option-path_dirs.zsh000066400000000000000000000043141265222726300276240ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ## setup 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' expected_region_highlight=( "1 21 $ZSH_HIGHLIGHT_STYLES[command]" # bar/testing-issue-228 ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path-space.zsh000066400000000000000000000042271265222726300263710ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- mkdir A touch "A/mu with spaces" BUFFER='ls A/mu\ with\ spaces' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls "4 19 $ZSH_HIGHLIGHT_STYLES[path]" # A/mu\ with\ spaces ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path-tilde-home.zsh000066400000000000000000000041331265222726300273210ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- HOME="." BUFFER='ls ~' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls "4 4 $ZSH_HIGHLIGHT_STYLES[path]" # ~ ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path-tilde-home2.zsh000066400000000000000000000041451265222726300274060ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- HOME="/nonexistent" BUFFER='ls ~' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls "4 4 $ZSH_HIGHLIGHT_STYLES[default]" # ~ ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path-tilde-named.zsh000066400000000000000000000042741265222726300274630ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- mkdir mydir touch mydir/path-tilde-named.test hash -d D=mydir BUFFER='ls ~D/path-tilde-named.test' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls "4 27 $ZSH_HIGHLIGHT_STYLES[path]" # ~D/path-tilde-named.test ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path.zsh000066400000000000000000000041541265222726300252770ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- mkdir A touch A/mu BUFFER='ls A/mu' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls "4 7 $ZSH_HIGHLIGHT_STYLES[path]" # A/mu ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path_prefix.zsh000066400000000000000000000043021265222726300266470ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Assumes that '/bin/sh' exists and '/bin/s' does not exist. # Related to path_prefix2.zsh ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight BUFFER='ls /bin/s' expected_region_highlight=( "4 9 $ZSH_HIGHLIGHT_STYLES[path_prefix]" # /bin/s ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/path_prefix2.zsh000066400000000000000000000043201265222726300267310ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Assumes that '/bin/sh' exists and '/bin/s' does not exist. # Related to path_prefix.zsh ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight BUFFER='ls /bin/s' WIDGET=accept-line expected_region_highlight=( "4 9 $ZSH_HIGHLIGHT_STYLES[default]" # /bin/s ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/precommand.zsh000066400000000000000000000043641265222726300264730ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight BUFFER=': command zzzzzz' expected_region_highlight=( "1 1 $ZSH_HIGHLIGHT_STYLES[command]" # ls "3 9 $ZSH_HIGHLIGHT_STYLES[default]" # not precommand "11 16 $ZSH_HIGHLIGHT_STYLES[default]" # not unknown-token (since 'zzzzzz' is not a command) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/prefix-redirection.zsh000066400000000000000000000045021265222726300301420ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='>/tmp >/tmp sudo echo >/tmp foo' expected_region_highlight=( "2 5 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp "8 11 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp "13 16 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "18 21 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo "24 27 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp "29 31 $ZSH_HIGHLIGHT_STYLES[default]" # foo ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/redirection.zsh000066400000000000000000000043661265222726300266570ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # Redirection before and after the command word are implemented differently; test both. ZSH_HIGHLIGHT_STYLES[redirection]=$unused_highlight BUFFER='<<>&!bar' expected_region_highlight=( "1 3 $ZSH_HIGHLIGHT_STYLES[redirection]" # <<< "13 16 $ZSH_HIGHLIGHT_STYLES[redirection]" # >>&! ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/reserved-word.zsh000066400000000000000000000044271265222726300271360ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[reserved-word]=$unused_highlight BUFFER='repeat "1" do done' expected_region_highlight=( "1 6 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # repeat "8 10 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "1" "12 13 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # do "15 18 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # done ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/simple-command.zsh000066400000000000000000000040451265222726300272470ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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='ls' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/simple-redirection.zsh000066400000000000000000000043561265222726300301450ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='ps aux | grep java' expected_region_highlight=( "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | "10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep "15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/subshell.zsh000066400000000000000000000046451265222726300261710ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='tar cf - * | (cd /target; tar xfp -) | { cat }' expected_region_highlight=( "1 3 $ZSH_HIGHLIGHT_STYLES[command]" # tar "14 14 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ( "15 16 $ZSH_HIGHLIGHT_STYLES[command]" # cd "27 29 $ZSH_HIGHLIGHT_STYLES[command]" # tar "36 36 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # ) "40 40 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # { "42 44 $ZSH_HIGHLIGHT_STYLES[command]" # cat "46 46 $ZSH_HIGHLIGHT_STYLES[reserved-word]" # } ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/sudo-command.zsh000066400000000000000000000053411265222726300267300ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$unused_highlight # Tests three codepaths: # * -i (no argument) # * -C3 (pasted argument) # * -u otheruser (non-pasted argument) BUFFER='sudo -C3 -u otheruser -i ls /; sudo ; sudo -u ;' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "6 8 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -C3 "10 11 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u "13 21 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser "23 24 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -i "26 27 $ZSH_HIGHLIGHT_STYLES[command]" # ls "29 29 $ZSH_HIGHLIGHT_STYLES[path]" # / "37 37 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ;, error because empty command "47 47 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ;, error because incomplete command ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/sudo-comment.zsh000066400000000000000000000044421265222726300267550ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$unused_highlight setopt interactive_comments BUFFER='sudo -u # comment' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "6 7 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u "9 17 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # "# comment" - error because argument missed ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/sudo-redirection.zsh000066400000000000000000000052631265222726300276240ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='sudo -u >/tmp otheruser ls; sudo ls; sudo -i ls' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "6 7 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u "9 9 $ZSH_HIGHLIGHT_STYLES[redirection]" # > "10 13 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp "15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser "25 26 $ZSH_HIGHLIGHT_STYLES[command]" # ls "27 27 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "29 32 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "34 35 $ZSH_HIGHLIGHT_STYLES[command]" # ls "36 36 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ; "38 41 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "43 44 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -i "46 47 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/sudo-redirection2.zsh000066400000000000000000000044661265222726300277120ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- BUFFER='sudo >/tmp -u otheruser ls' expected_region_highlight=( "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "6 6 $ZSH_HIGHLIGHT_STYLES[redirection]" # > "7 10 $ZSH_HIGHLIGHT_STYLES[path]" # /tmp "12 13 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u "15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser "25 26 $ZSH_HIGHLIGHT_STYLES[command]" # ls ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/tilde-command-word.zsh000066400000000000000000000042001265222726300300210ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- hash -d D=/usr/bin BUFFER='~D/env foo' expected_region_highlight=( "1 6 $ZSH_HIGHLIGHT_STYLES[command]" # ~D/env [= /usr/bin/env] "8 10 $ZSH_HIGHLIGHT_STYLES[default]" # foo ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/unbackslash.zsh000066400000000000000000000041611265222726300266370ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- ZSH_HIGHLIGHT_STYLES[command]=$unused_highlight BUFFER='\sh' expected_region_highlight=( "1 3 $ZSH_HIGHLIGHT_STYLES[command]" # \sh (runs 'sh', bypassing aliases) ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/unknown-command.zsh000066400000000000000000000040761265222726300274610ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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='azertyuiop' expected_region_highlight=( "1 10 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # azertyuiop ) zsh-syntax-highlighting-0.4.1/highlighters/main/test-data/vanilla-newline.zsh000066400000000000000000000044431265222726300274310ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- PREBUFFER=$'echo foo; echo bar\n\n\n' BUFFER=' echo baz; echo qux' expected_region_highlight=( "2 5 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo "7 9 $ZSH_HIGHLIGHT_STYLES[default]" # baz "10 10 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # semicolon "12 15 $ZSH_HIGHLIGHT_STYLES[builtin]" # echo "17 19 $ZSH_HIGHLIGHT_STYLES[default]" # qux ) zsh-syntax-highlighting-0.4.1/highlighters/pattern/000077500000000000000000000000001265222726300224545ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/pattern/README.md000077700000000000000000000000001265222726300317642../../docs/highlighters/pattern.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/pattern/pattern-highlighter.zsh000066400000000000000000000054171265222726300271620ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- # List of keyword and color pairs. typeset -gA ZSH_HIGHLIGHT_PATTERNS # Whether the pattern highlighter should be called or not. _zsh_highlight_pattern_highlighter_predicate() { _zsh_highlight_buffer_modified } # Pattern syntax highlighting function. _zsh_highlight_pattern_highlighter() { setopt localoptions extendedglob local pattern for pattern in ${(k)ZSH_HIGHLIGHT_PATTERNS}; do _zsh_highlight_pattern_highlighter_loop "$BUFFER" "$pattern" done } _zsh_highlight_pattern_highlighter_loop() { # This does *not* do its job syntactically, sorry. local buf="$1" pat="$2" local -a match mbegin mend local MATCH; integer MBEGIN MEND if [[ "$buf" == (#b)(*)(${~pat})* ]]; then region_highlight+=("$((mbegin[2] - 1)) $mend[2] $ZSH_HIGHLIGHT_PATTERNS[$pat]") "$0" "$match[1]" "$pat"; return $? fi } zsh-syntax-highlighting-0.4.1/highlighters/root/000077500000000000000000000000001265222726300217625ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/root/README.md000077700000000000000000000000001265222726300306002../../docs/highlighters/root.mdustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/highlighters/root/root-highlighter.zsh000066400000000000000000000045041265222726300257720ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2011 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 # ------------------------------------------------------------------------------------------------- # Define default styles. : ${ZSH_HIGHLIGHT_STYLES[root]:=standout} # Whether the root highlighter should be called or not. _zsh_highlight_root_highlighter_predicate() { _zsh_highlight_buffer_modified } # root highlighting function. _zsh_highlight_root_highlighter() { if [[ $(command id -u) -eq 0 ]] { region_highlight+=("0 $#BUFFER $ZSH_HIGHLIGHT_STYLES[root]") } } zsh-syntax-highlighting-0.4.1/images/000077500000000000000000000000001265222726300175635ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/images/preview-smaller.png000066400000000000000000000135361265222726300234170ustar00rootroot00000000000000PNG  IHDRR1 pHYs  tIME  '*#IDATxy\33 ,"" nMQQQ,ŬL+ZvZYsJ u]Zj(E2 1 ΰ"79:f̘iӦU,_< 4矀CCCW^LiC-?WdQZ??ׯڵk322VX ,XࡇŻfjGi6siP;wl3g&Mt!--mΜ9w N.pNw[&ƕh)+ů=94t8Opdťg(nvk-[}Y!DffEt:]Vp :$+<WoDVr)Bd}y FgZvG匡N Qx0|ܕRdŎ)V16}2%%%%%ZT ˧ɄCN컌NļbmcZvgٚ| -`606PD53D߄e$[r6}xX-u6ɣy@- gV(?W_hf oPtW9.mI)E/eut6069..\x3f`>uFC Ka @!0~6QF !RSSl̵Q.]3 .\,j|IeJJǭa';;{ܸq=z0^lOV00l C[p* IrzɓmjfFFF^^BVnnn'O -[\tK={X5 dYV !$IRB֭}w.puuc0Ngwzj ͻNѩSJΝkBs ??\6On,*,,:u"!!mٲelZ9P jp\jn x|G6mZBB$I ǟ|%*3lقcח4L>G.\nݺLۂqj  *Ne B0-ܛH#;_ŋ5ZԖ} XG1N ??T*Newh۶uuu%*SwP\ƨ x:˲Q|[o૬ˉ"~֩dtW_}߿?UVՖ !b/R->s DW7vM +%%Ƶz~D$*:w+QQIhS!R<1#4t}Ϟ,/ZA7zBF(3KJ$Af ,zM؞?j` \)b1t{ךּ\d`Ϟ=c?֭[}Qk xost:dG~7b0̗Gh~oAΒBVzNP<)H`i.I[1;=`0^RDWלY'N`0D<[y*5빫<ډⲊWgH{b>c|d>(8sx~ 9k`EZ5_2/(kNTŮfq`::?`HLt'l)F8x}wnn@Сb8SʶȑF#FFyNѺTC{W$$b$vvȊxVa4 0C;TrEm5ahBL`u#lљ11xlkW{ ׯ /`k-}:;kj$i)e۪Q(4Oz`攗sbI7ټƑ^IZbjV\$Tw8y$mbOhM`&pb-377؎W8iؑITDd7(.Zʕ+'Ow%KX_R$[/!TMT*(7K$Ќ+) ɪc .\ =?sEB)\-h]Bo߾YYY-jժUrrd!44%h&63I'_GeݔCP(3Z-Z 8$!nd*(!G"eiM>,))SNׯ_߸qynDJK1y{ ""f?!ˑFPh!]HYY)fgi99:^%1>T1W-LvQF'MԱ}+E7 .&%%]vmӦM...7_7n'ukW˯+. 9??88py(ww HR7+g5kVd +/GJpBq,Yc[3>vǒC\*dLG9bkv_؞I;w&ta]"EW9r$666;;ܹsv @P33jejj^||+˲D˛LnWO| (" ~ u>|f}֞sfk#CBFFVQ6tdddL!M#M#M#M#M#M#M#M#Mn;RO"#ckT99::z (ЧOFyIi VZ?&n  /JւK7 V#o9%SѾ} PTT4k֬I&eee ooA8sRiIl+YEؔ= }w+Q :AxķSL!;;[PGz->Z#1<;I^9IϿn%j.Ĉo:h4??7n( Q{w޽wކhčA$ԇ8VPe Q5^h4@iiΝ;f͚ÇaHΉGMD}sTOq "QU*zeSN۠ @xJ6m:|C<q(Ž[nϹy#{fq{48K#QƚT tw>mڴ۷ggg/\سgO~~ĉ ,XpM53 .Pp!њrˊ)+DH:c3N-Y&rC(+IVbޓFըt֮]{9__ߤ;w 80//oƌNNN/VZo5\S >1vp C Mv-)Ϩ:TѦ?(hH T!eEeoKZi$XuQ77M6eeeEGGwx뭷AHOOwss3~Eltz2y&K0#9_3`!6WN P7WNM"U*~f ;;=]Y>jǻ>_yueCGlnn JZ.))<==ťE6L1@`"< Hoퟠ& ʋ>cq,~iq-+HF3߻EE^ˤ%$@1%X>~sssKHHذaC6 P?/Jf(M-vmPZ0zKeǒ}qRElm81čϔ1u pC+H L̙3GcC܂pP\SNH*.7_sk׏Pʼnu$"ךu@IQ ^}s7 GVPlƀ2Vy`ٲevvvGٹsg5| OUV/[ws\QS3n~UJC4k{ߊeƨ;9skȐ!:&B0x$BAç8# 1JKԽO;LŹ5WY!QFR o֭QQQ{IJJڵkw: ns NV% C˸pmɣ+j.oH0euXKYW+*QFR hddAJKKΝ \rԩyyy۷oOKKܱc6ԕ2oëQOW}a)tZ\`$=_8!yi px%e`_BD)<OVnу`7(X,QFR ?NLLl۶h44hИ1cBCCFUߍ5]ކI .(%IE4!b!oǹ`N2>FJ*OUvd(!+tʞB-v̝.ϡ4֬C\T;ܯ\uz/Dϣ=DK,/_.nv ]RRRkfmT𺡈*"dPEFX@qq+Dqfe\W*s;'|hѲǦViً.\ɺJf9*e@M:uorrrTTx$)) vgL =hoӮ p?eļǥ>ʼ̞7(+cQORi 7Oڂ=qiAE9'Uz#:.>Gޭ7'Tp``ʀ|7֔C]%Xj*:w\Fs̙Zw055uk֬c8sٲelhK@X W`4x@mO";QJ ň˕frMZEe\ZϱG$@R4תȻw{}>q$QjuJvhݺƍ_vMO:8`y}Gw!PqskgH"P*.\9XMrx9E9uC-=sD\?X͍ޅQ7.?0[k4mL*QƪoF5l@FF444444444444r|? ݺuܣGӧOo޼kEDDoR'Nxxx8 !c!56_nݘ1c ӧϰazY_ yP׭['?wp0@'o ӖY-W_ ,--_Zo;Bߊ7t߾}ƍ8pK/taʕ+}u?zȴÇk5.uq1Ѽ%To߾ ͚5kҤIYYY u7̙3qf5tK0ѡYرcEmE B|"Xݾ}wތZ:v(T;::Jԩw}''2e ٺڻwo?Rf ~`h|Aj|P(~mTEE{!S Lk:Ð &&F|{!@e{5pƈnp^{ķ~y{޽vIA.\hSPLԴieTJ/JE5 bkYf#""A={Tmxt"PBx\fooR1̿jWWWիҞۦUU./_ԩO? 벼lڴI؜Q1` ͨe4%ʹ//+'6l؊+DLEE͛-ZT#⃣3.CR^;)..wT*Ĕ註,bLc <==uej_e)--1N] E_uA۴i-ݻ' PPPЪU+gV0V76JxLdT@W뵳ʯ`<5xB[ğ,޿RwuJ4([vgIsQ9sLw>|xђ&x_WR߾ AAA YF:zѵk׎?>$$$))\V͘1iU~m!*3<^=o606h kA0ރZݩSe˖=T37oީS$uA fΜ+۶y!ClٲEUTT幻ׯ_~'O1b۷RY|gϞurr/?W*?|. uQ77M6eeeEGGwx뭷AHOO1@ sFa0VԪim 3džҢ5W߫Z-_u֟}?pСpe{nwV̏VE $^zATv)**J<ɱcj-SEAAAzڼ㑑k=D0ZT<==srrAƪT}b|xZ`zMa*lMy0+ޒ .+W~n%}&СC4@W=ΟRLKKprJ3],h@EǍtRo߾*ٳ'Nn޼)z{/(quw{A#e9hR2c5<أG3f8::.X >>矯v44wO>d@.,,D;4wy'004i?_RRy&MK@b d[|8]RRRcȵyi׍TqfH/Ԟ̈́u(++裏:t_кu͛7 (li\\\{1cfacuooo3 4H4|7;w<8֭'+Ě*:uT__d]T$+pe3e"Ѿ 2^}Ok 3 F?~U0 ^5۷Ǐ߯_8 88>k֬m-k֬y'jn!hΜ9O?]ti„ Kt./zӦM^Z܋?k֬H+6m-¸qt[n]PPPQQ!zgddDv.wY1fhWߴ^qZ6\c`2|`cתRL""77Z۷o4Ŋk׮?-O~+ ӟ8bĈB b/:MC xEmڴ }XX+*NrršJ**:}t-*##cݺuW\AJF—Fڻa'0 fi+3PQ?t_X} TtтIV0` 4]KD>{NLL4X<**ʴСCug3ȧ~Z[hAAk;۷o}{No1:Tu999EEE>1b111/xS>! C􂙰 6{0F!/>P 6rx_$o4MQQ2*O?tI >۵kgȌ3ɵ{mvڵ۷o>#Xߟph#)Çd\zȑ۷oݧOFiAh?( n0"p&vh*%#;d3Nѭ'X7gxTOzձ#=_ .NPMEϟ 4iҤ;v;*u``Çj㭨MAMTJ<+>.E̍YQJEyyL '+0 7/ۗi.NP}]xqqqݻ|QFM>]?Ʋeju\\W_}%}[a:X)hS@FA,mv 88ㄆҮ@P_|A|RQZE-8 D]v!!!IIIj://oƌNNNJ̪U3Hv#]A@$|`sAh#`3^ka![ rHv>/ΒSl| G^..O?̘Qꂤ~BLdڕvvBd$|@iiEK.NQ%%%W~'>/sDZ?&#˨Q0s&|b0''jDR^/7xPfάwErs cG-b\ kH+Zvqj &LP*js ,ZHL$1ņfWK^0TpV M IDATaH2K3^g?p4PŰhA& ! ~m;Ӿ=]>9:v_ظˋSQs+)) @V5Y\a`YQQ!'0o<77 6X-3 Fq~@yM: Y#gz)DÊDYR/G\Wst$0חh۷~I֎+8^ѣmnXf"%%|)II%MƆ`@@{Μ9T)Z(:BᔡuDhyn<ѵ&@6U&OA3>+LBӦ rtxN Rѻ!TtٲevvvG)~[k#9޹\Lm8Gf%87 L.9@ݲ[x>ҙM7"+*}pp%׸ʏ/Y\bTECCCǎ ̜9St2d)]szQ]fhz苽\؟9.PSѨ{*}Gy9zMeR4~# WlVQ֭[cccٓk.Ӏ56G*g3T9;ũl5s~oy]F.gF'_b#İFFF4tܹʕ+N};vH,ә6"/O OayZjwW?őбg+H7Rk!L'&&mV4 4h̘1aaaF-vzMsliF9YxV1-5T*BuN4~M5LiqF7n\HHHNNo߾*ٳ'Nn޼k. L(!<~/[Yt֝>ŢmFCX8 ME^\ qB\wowb#:88,YX|% wKII|L1,C4xUw3VRtu' hP ǫ[ =!;ܸռGLlG_MާOK ݝ' &Mx9bb#N:7999**J|}=[fO,y:|8vvDDt)]VNx)L8{lV95)Y3mkqF5MyB8p{]v=ar0 "xAvGȖʖaa8 _Qtגr~'L +dwHmQp9qpܠ ?D\iNNѦ s^kgV'}b>^ͬYL@^q6_t"kH+66ܹs5͙3gkٳgYF 8p@OOe˖Iq{Q: &Kڙ>g` LO]zk5M=; ^F ` 4vЮzTGO?A~qu\ǽ֭ucgΰd SY{ECXްD+6*~[_Z\\&33T1(..nnnnN6$oCV盺l$fMEU!w `)Jmi~S&Mڱcرc~UVǏ\E[:8\6LvUBBl=rrwm4jRTvLE/t_' 'm-KI7/NP}]xqqqݻ|QFM>}Ŋ2˖-Sqqq_}Mi~m R@*}fUAA]Sf|ww[ׯR?L˳.$̳Lu8L@TTʕ+Jv9spw< 0k֬I7fz!+,]TF]I4c\NEox34_c<͐%l>_-EJaV:]j]4$$~!@e{RL=-ij 6si)̉7LJ¶ftd3xĥQ^ jq+h]Q15ЬY7n ><""BٳgK(~X??u{d[Ο_rzfoH~uƙ lKM9urzEggG*`_zlsz:tqwAJ)(7=Ԥyznڴ}ǭ>^eӦM h^ }{jAW\͛Gjo_ϯܻW[E]\Vjժw_?{vz6+`TVKt\+kU $$Ж -VwR4sZڟccXglRе9M`OakL2JŸuW׻Z:\P(pPQTVÇ'O|ʕzUVHZ>JHXzmW9crcl۰0~斖.xPfJx{Aڮu]{n-  䂂U qwM ٴiWwwc%umڴy\V߻EϼkH3 sE8qd {Xe|ڂRPZx.[Bϝ,}^X\Q/NCQ;aRVKJJOO7|XhQnn u]M,.68P|pt3gڷ/Q{"+뿷n,jJfǎ*z_窌h?ݺ5666Wk];ōzzM'g^YȘ\{_{6iw_NlDg/7#ky3V"G5ouIU{0*w Xqڴ=)9Ĥrʍb)i*6: 3+**J]ּy6l`8 󭓊Nk۶._N q.''Ug|}ug}}5v|N?Eaٳ9.^1Bϱ 99WӽgnJY~6ux;w~ddVq;dL) ISS1?9sJKrZj<Ҭ]UR$V{|t[Tޒ|ːmzqqoKp5zWzMljejtSzQ2Aj4l)`ޭ$1˖-;rΝ;)$wJJ o J68U>-\2>濞ob*yzCIKA>8ƗgJʩP)hʡtFD7*%L+%qiTlUбc3g ﯰJVh؇\W9kzi v`Gv"Atw(p0\HF\лyhR j#UTuX{{={$%%ڵ[G~/Z k* -ԵzaBe^\BȻGÁ%8g2XP\uO,1  *--v\rԩyyy۷oOKKܱcR%M^~"3=g&Cezڛ0S|+FRu 7)bc['&&mV4 4h̘1aaaF)3N'Mj E ;ou˰ sP\QqJпO ;HGZcK\r*i-?49UOH+6F \qƅ,]۷J:{'7oڵ  )k=<9SehTk=EfT%v{sgJX}ۺ)))cr]:%0kj K5@u˸^9#/9M[\1RSE,Y,_\>Z'u7 }) MUpOo)<|=vۺׁ..UwvGcR^ ==<? soSRto|[lqp۩ӉGmխȖ-m_7ar/>hpZ Rpw 4Q\WrJP1R4uT__䨨(HRR \Aٗwao5 օݻqwvӪݻk41A۵31{Ƥ$'}4^YSE]dڙ3<=[;V;دPP^ߣ*~81<;{Y.T=q#2gDN.һNvDn ZDqcJ/9P⊍j*ڴiS>4o<]Ȣv޽k׮ϟwww6lXyy? mS6]>S'־͚^W'~]<ұ!ƈ|vYMq8Kw^qQDu)fV¬GP+Ѝ^-Kv> p1A,6Н;wF9s_;:{lBnݺXOO+VHq/+sאSvIɌ{w\yKJ.[W+*F,| AX{C ͞o_m!LI9Š#f[&4whFﯰ ْ1<ƒF.ތ 0ԩRÆX\qk)u7nƏMDN 0`@jjy>#k].}2DvWN8y@FF})],.vsP|ɓnvvP.?* :=RgN,Hwosr+N}qㆉ CʾII2JPWT\o:wnɥK5a͚[\P~~mN6tP[yD'q:3Q)hƭ{:g\vaT\H'dY+SN3j* y c d hv.ɘ"LTdꁆW!cĦ-;r/*#c**#c**#c**#c**#c**#c**#c?lvIENDB`zsh-syntax-highlighting-0.4.1/release.md000066400000000000000000000007251265222726300202640ustar00rootroot00000000000000# Release procedure (for developers): - Check open issues and outstanding pull requests - Confirm `make test` passes - check with multiple zsh versions - Update changelog.md - Remove `-dev` suffix from `./.version`; Commit that; Tag it using `git tag $(<.version)`; Increment `./.version` and restore the `-dev` suffix; Commit that. - Push with `git push --tags` - Notify downstreams (OS packages) - anitya should autodetect the tag - Update /topic on IRC zsh-syntax-highlighting-0.4.1/tests/000077500000000000000000000000001265222726300174605ustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/tests/README.md000066400000000000000000000034541265222726300207450ustar00rootroot00000000000000zsh-syntax-highlighting / tests =============================== Utility scripts for testing zsh-syntax-highlighting highlighters. The tests harness expects the highlighter directory to contain a `test-data` directory with test data files. See the [main highlighter](../highlighters/main/test-data) for examples. Each test should define the array parameter `$expected_region_highlight`. The value of that parameter is a list of strings of the form `"$i $j $style"`. or `"$i $j $style $todo"`. Each string specifies the highlighting that `$BUFFER[$i,$j]` should have; that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints. 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. **Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently. **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 current working directory of tests is set to a newly-created empty directory, which is automatically cleaned up after the test exits. Highlighting test ----------------- [`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of the highlighting. Usage: zsh test-highlighting.zsh All tests may be run with make test which will run all highlighting tests and report results in [TAP format][TAP]. [TAP]: http://testanything.org/ Performance test ---------------- [`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the highlighting. Usage: zsh test-perfs.zsh All tests may be run with make perf zsh-syntax-highlighting-0.4.1/tests/tap-colorizer.zsh000077500000000000000000000051221265222726300230030ustar00rootroot00000000000000#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- # Copyright (c) 2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # This is a stdin-to-stdout filter that takes TAP output (such as 'make test') # on stdin and passes it, colorized, to stdout. emulate -LR zsh if [[ ! -t 1 ]] ; then exec cat fi while read -r line; do case $line in # comment (filename header) or plan (#* | <->..<->) print -nP %F{blue} ;; # XPASS (ok*# TODO*) print -nP %F{red} ;; # XFAIL (not ok*# TODO*) print -nP %F{yellow} ;; # FAIL (not ok*) print -nP %F{red} ;; # PASS (ok*) print -nP %F{green} ;; esac print -nr - "$line" print -nP %f echo "" # newline done zsh-syntax-highlighting-0.4.1/tests/test-highlighting.zsh000077500000000000000000000131061265222726300236340ustar00rootroot00000000000000#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # 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 } # Check the highlighter is valid. [[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { echo >&2 "Bail out! Could not find highlighter '$1'." exit 2 } # Check the highlighter has test data. [[ -d ${0:h:h}/highlighters/$1/test-data ]] || { echo >&2 "Bail out! Highlighter '$1' has no test data." exit 2 } # Load the main script. . ${0:h:h}/zsh-syntax-highlighting.zsh # Activate the highlighter. ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) # Runs a highlighting test # $1: data file run_test_internal() { local -a highlight_zone local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use local tests_tempdir="$1"; shift local srcdir="$PWD" builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! cd failed: $?"; return 1 } echo "# ${1:t:r}" # Load the data and prepare checking it. PREBUFFER= BUFFER= ; . "$srcdir"/"$1" # 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; } # 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 -A observed_result for ((i=1; i<=${#region_highlight}; i++)); do highlight_zone=${(z)region_highlight[$i]} integer start=$highlight_zone[1] end=$highlight_zone[2] if (( start < end )) # region_highlight ranges are half-open then (( --end )) # convert to closed range, like expected_region_highlight (( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed for j in {$start..$end}; do observed_result[$j]=$highlight_zone[3] done else # noop range; ignore. fi done # Then we compare the observed result with the expected one. echo "1..${#expected_region_highlight}" for ((i=1; i<=${#expected_region_highlight}; i++)); do local todo= highlight_zone=${(z)expected_region_highlight[$i]} [[ -n "$highlight_zone[4]" ]] && todo=" # TODO $highlight_zone[4]" for j in {$highlight_zone[1]..$highlight_zone[2]}; do if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then echo "not ok $i '$BUFFER[$highlight_zone[1],$highlight_zone[2]]' [$highlight_zone[1],$highlight_zone[2]]: expected '$highlight_zone[3]', observed '$observed_result[$j]'.$todo" continue 2 fi done echo "ok $i$todo" done } run_test() { # Do not combine the declaration and initialization: «local x="$(false)"» does not set $?. local __tests_tempdir __tests_tempdir="$(mktemp -d)" && [[ -d $__tests_tempdir ]] || { echo >&2 "Bail out! mktemp failed"; return 1 } typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on { (run_test_internal "$__tests_tempdir" "$@") } always { rm -rf -- "$__tests_tempdir" } } # Process each test data file in test data directory. integer something_failed=0 for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do run_test "$data_file" | tee >(${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 )) (( $pipestatus[1] )) && exit 2 done exit $something_failed zsh-syntax-highlighting-0.4.1/tests/test-perfs.zsh000077500000000000000000000076601265222726300223160ustar00rootroot00000000000000#!/usr/bin/env zsh # ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- # 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 } # Check the highlighter is valid. [[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { echo >&2 "Bail out! Could not find highlighter '$1'." exit 2 } # Check the highlighter has test data. [[ -d ${0:h:h}/highlighters/$1/test-data ]] || { echo >&2 "Bail out! Highlighter '$1' has no test data." exit 2 } # Load the main script. . ${0:h:h}/zsh-syntax-highlighting.zsh # Activate the highlighter. ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) # Runs a highlighting test # $1: data file run_test_internal() { local -a highlight_zone local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use local tests_tempdir="$1"; shift local srcdir="$PWD" builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! cd failed: $?"; return 1 } echo -n "# ${1:t:r}: " # Load the data and prepare checking it. PREBUFFER= BUFFER= ; . "$srcdir"/"$1" # 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; } # Measure the time taken by _zsh_highlight. TIMEFMT="%*Es" time (BUFFER="$BUFFER" && _zsh_highlight) } run_test() { # Do not combine the declaration and initialization: «local x="$(false)"» does not set $?. local __tests_tempdir __tests_tempdir="$(mktemp -d)" && [[ -d $__tests_tempdir ]] || { echo >&2 "Bail out! mktemp failed"; return 1 } typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on { (run_test_internal "$__tests_tempdir" "$@") } always { rm -rf -- "$__tests_tempdir" } } # Process each test data file in test data directory. for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do run_test "$data_file" (( $pipestatus[1] )) && exit 2 done exit 0 zsh-syntax-highlighting-0.4.1/zsh-syntax-highlighting.plugin.zsh000077700000000000000000000000001265222726300324502zsh-syntax-highlighting.zshustar00rootroot00000000000000zsh-syntax-highlighting-0.4.1/zsh-syntax-highlighting.zsh000066400000000000000000000261521265222726300236450ustar00rootroot00000000000000# ------------------------------------------------------------------------------------------------- # Copyright (c) 2010-2015 zsh-syntax-highlighting contributors # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted # provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of # conditions and the following disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors # may be used to endorse or promote products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------------------------- # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- if [[ -o function_argzero ]]; then # $0 is reliable ZSH_HIGHLIGHT_VERSION=$(<"${0:A:h}"/.version) ZSH_HIGHLIGHT_REVISION=$(<"${0:A:h}"/.revision-hash) if [[ $ZSH_HIGHLIGHT_REVISION == \$Format:* ]]; then # When running from a source tree without 'make install', $ZSH_HIGHLIGHT_REVISION # would be set to '$Format:%H$' literally. That's an invalid value, and obtaining # the valid value (via `git rev-parse HEAD`, as Makefile does) might be costly, so: ZSH_HIGHLIGHT_REVISION=HEAD fi else # $0 is unreliable, so the call to _zsh_highlight_load_highlighters will fail. # TODO: If 'zmodload zsh/parameter' is available, ${funcsourcetrace[1]%:*} might serve as a substitute? # TODO: also check POSIX_ARGZERO, but not it's not available in older zsh echo "zsh-syntax-highlighting: error: not compatible with NO_FUNCTION_ARGZERO" >&2 return 1 fi # ------------------------------------------------------------------------------------------------- # Core highlighting update system # ------------------------------------------------------------------------------------------------- # Array declaring active highlighters names. typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS # Update ZLE buffer syntax highlighting. # # Invokes each highlighter that needs updating. # This function is supposed to be called whenever the ZLE state changes. _zsh_highlight() { # Store the previous command return code to restore it whatever happens. local ret=$? setopt localoptions warncreateglobal setopt localoptions noksharrays local REPLY # don't leak $REPLY into global scope # Do not highlight if there are more than 300 chars in the buffer. It's most # likely a pasted command or a huge list of files in that case.. [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret # Do not highlight if there are pending inputs (copy/paste). [[ $PENDING -gt 0 ]] && return $ret # Reset region highlight to build it from scratch typeset -ga region_highlight region_highlight=(); { local cache_place local -a region_highlight_copy # Select which highlighters in ZSH_HIGHLIGHT_HIGHLIGHTERS need to be invoked. local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do # eval cache place for current highlighter and prepare it cache_place="_zsh_highlight_${highlighter}_highlighter_cache" typeset -ga ${cache_place} # If highlighter needs to be invoked if "_zsh_highlight_${highlighter}_highlighter_predicate"; then # save a copy, and cleanup region_highlight region_highlight_copy=("${region_highlight[@]}") region_highlight=() # Execute highlighter and save result { "_zsh_highlight_${highlighter}_highlighter" } always { eval "${cache_place}=(\"\${region_highlight[@]}\")" } # Restore saved region_highlight region_highlight=("${region_highlight_copy[@]}") fi # Use value form cache if any cached eval "region_highlight+=(\"\${${cache_place}[@]}\")" done # Re-apply zle_highlight settings () { if (( REGION_ACTIVE )) ; then # zle_highlight[region] defaults to 'standout' if unspecified local region="${${zle_highlight[(r)region:*]#region:}:-standout}" integer start end if (( MARK > CURSOR )) ; then start=$CURSOR end=$MARK else start=$MARK end=$CURSOR fi region_highlight+=("$start $end $region") fi } # YANK_ACTIVE is only available in zsh-5.1.1 and newer (( $+YANK_ACTIVE )) && () { if (( YANK_ACTIVE )) ; then # zle_highlight[paste] defaults to 'standout' if unspecified local paste="${${zle_highlight[(r)paste:*]#paste:}:-standout}" integer start end if (( YANK_END > YANK_START )) ; then start=$YANK_START end=$YANK_END else start=$YANK_END end=$YANK_START fi region_highlight+=("$start $end $paste") fi } return $ret } always { typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER="$BUFFER" typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR } } # ------------------------------------------------------------------------------------------------- # API/utility functions for highlighters # ------------------------------------------------------------------------------------------------- # Array used by highlighters to declare user overridable styles. typeset -gA ZSH_HIGHLIGHT_STYLES # Whether the command line buffer has been modified or not. # # Returns 0 if the buffer has changed since _zsh_highlight was last called. _zsh_highlight_buffer_modified() { [[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]] } # Whether the cursor has moved or not. # # Returns 0 if the cursor has moved since _zsh_highlight was last called. _zsh_highlight_cursor_moved() { [[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR)) } # ------------------------------------------------------------------------------------------------- # Setup functions # ------------------------------------------------------------------------------------------------- # Helper for _zsh_highlight_bind_widgets # $1 is name of widget to call _zsh_highlight_call_widget() { builtin zle "$@" && _zsh_highlight } # Rebind all ZLE widgets to make them invoke _zsh_highlights. _zsh_highlight_bind_widgets() { setopt localoptions noksharrays # Load ZSH module zsh/zleparameter, needed to override user defined widgets. zmodload zsh/zleparameter 2>/dev/null || { echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 return 1 } # Override ZLE widgets to make them invoke _zsh_highlight. local cur_widget for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do case $widgets[$cur_widget] in # Already rebound event: do nothing. user:$cur_widget|user:_zsh_highlight_widget_*);; # User defined widget: override and rebind old one with prefix "orig-". user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \ _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; # Completion widget: override and rebind old one with prefix "orig-". completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; # Builtin widget: override and make it call the builtin ".widget". builtin) eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget .$cur_widget -- \"\$@\" }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; # Default: unhandled case. *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; esac done } # Load highlighters from directory. # # Arguments: # 1) Path to the highlighters directory. _zsh_highlight_load_highlighters() { setopt localoptions noksharrays # Check the directory exists. [[ -d "$1" ]] || { echo "zsh-syntax-highlighting: highlighters directory '$1' not found." >&2 return 1 } # Load highlighters from highlighters directory and check they define required functions. local highlighter highlighter_dir for highlighter_dir ($1/*/); do highlighter="${highlighter_dir:t}" [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] && { . "$highlighter_dir/${highlighter}-highlighter.zsh" type "_zsh_highlight_${highlighter}_highlighter" &> /dev/null && type "_zsh_highlight_${highlighter}_highlighter_predicate" &> /dev/null || { echo "zsh-syntax-highlighting: '${highlighter}' highlighter should define both required functions '_zsh_highlight_${highlighter}_highlighter' and '_zsh_highlight_${highlighter}_highlighter_predicate' in '${highlighter_dir}/${highlighter}-highlighter.zsh'." >&2 } } done } # ------------------------------------------------------------------------------------------------- # Setup # ------------------------------------------------------------------------------------------------- # Try binding widgets. _zsh_highlight_bind_widgets || { echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2 return 1 } # Resolve highlighters directory location. _zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || { echo 'zsh-syntax-highlighting: failed loading highlighters, exiting.' >&2 return 1 } # Reset scratch variables when commandline is done. _zsh_highlight_preexec_hook() { typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER= typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR= } autoload -U add-zsh-hook add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { echo 'zsh-syntax-highlighting: failed loading add-zsh-hook.' >&2 } # Initialize the array of active highlighters if needed. [[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true