Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fee52920ae | ||
|
|
58b0047c81 | ||
|
|
a73b33fc13 | ||
|
|
c687bddea3 | ||
|
|
c30301d474 | ||
|
|
0a7035170a | ||
|
|
85500ec151 | ||
|
|
bb9c407c95 | ||
|
|
6f7bf8c0f4 | ||
|
|
72b1abd17d | ||
|
|
3576df29aa | ||
|
|
bde1c83af1 | ||
|
|
4604deb652 | ||
|
|
f48f5400c1 | ||
|
|
379ab0d34e | ||
|
|
766b350a7d | ||
|
|
fe4e893ce5 | ||
|
|
e0bb30a153 | ||
|
|
728784649f | ||
|
|
9a3c7d1960 | ||
|
|
c538d6b357 | ||
|
|
9c56c624e9 | ||
|
|
43386376d8 | ||
|
|
984b4acd78 | ||
|
|
75d62b9657 | ||
|
|
94191f0731 | ||
|
|
2883c9582d | ||
|
|
83c3f96109 | ||
|
|
7aeadfe01b | ||
|
|
56c793d96a | ||
|
|
e138cfd765 | ||
|
|
07fd773d7e | ||
|
|
5cd1fb26c0 | ||
|
|
faed2fa49e | ||
|
|
69203b1a1d | ||
|
|
800158745a | ||
|
|
7b4598a764 | ||
|
|
52a2ef644b | ||
|
|
6488284814 | ||
|
|
f657406159 | ||
|
|
8b728522de | ||
|
|
79e8c2dd48 | ||
|
|
4ec821b2b1 | ||
|
|
219184f046 | ||
|
|
3fdaec3d4a | ||
|
|
6732783d46 | ||
|
|
0788514cbd | ||
|
|
8a43bd2cd9 | ||
|
|
98366ade11 | ||
|
|
78ad649d47 | ||
|
|
69fcb40275 | ||
|
|
f4164ac86c | ||
|
|
9c7a1109c8 | ||
|
|
dd12dde93a | ||
|
|
cb5589db73 | ||
|
|
35c4bb7bdc | ||
|
|
040df93c01 | ||
|
|
86cd337446 | ||
|
|
c43dc8bd44 | ||
|
|
66eb801358 | ||
|
|
b0cc02ed86 | ||
|
|
4ec0c6d7a7 | ||
|
|
908c4fe150 | ||
|
|
1467eae86d | ||
|
|
9e80fe8f02 | ||
|
|
001e6cb404 | ||
|
|
22fa215e05 | ||
|
|
845361ef3d | ||
|
|
4594d8b7ec | ||
|
|
5fb4cb2f72 | ||
|
|
f7cb4741d6 | ||
|
|
81c8d78d12 | ||
|
|
8767e0ef66 | ||
|
|
b056f592f2 | ||
|
|
e0a7ddb6ec | ||
|
|
416934202e | ||
|
|
627eb71940 | ||
|
|
00862cf4fa | ||
|
|
aab1b8f50f | ||
|
|
4068413dfe | ||
|
|
404d498e1d | ||
|
|
05ab9f7342 | ||
|
|
0d3a5dadea | ||
|
|
51102bf83f | ||
|
|
186536705b | ||
|
|
547b8be304 | ||
|
|
80587e5419 | ||
|
|
c46b8d169e | ||
|
|
a8afbdf2f5 | ||
|
|
6d93ea07fd | ||
|
|
4f5a0fe60b | ||
|
|
e5c2a88db0 | ||
|
|
0e31d6e1a2 | ||
|
|
555e142e66 | ||
|
|
e13c5a1611 | ||
|
|
8515b7e0c5 | ||
|
|
dc701501e5 | ||
|
|
9310d8ae71 | ||
|
|
b3ceea8511 | ||
|
|
a0b5bc6c71 | ||
|
|
d330b49b33 | ||
|
|
f78919d941 | ||
|
|
eaffd88793 | ||
|
|
546a5288e2 | ||
|
|
8e7c26f489 | ||
|
|
7f41967a17 | ||
|
|
13a8db1d71 | ||
|
|
51aed8a765 | ||
|
|
42495cc5d6 | ||
|
|
ea81e3df6e | ||
|
|
c2b9327b07 | ||
|
|
52ece975c3 | ||
|
|
7ee9df915d | ||
|
|
85b3446897 | ||
|
|
b9b67b9f78 | ||
|
|
359d48bf78 | ||
|
|
ff4d402e9a | ||
|
|
384be15b13 | ||
|
|
23cacb12fe | ||
|
|
667495bfb7 | ||
|
|
2c5acaefa9 | ||
|
|
0c8c4b73f8 | ||
|
|
a723f504a5 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.revision-hash export-subst
|
||||
1
.revision-hash
Normal file
1
.revision-hash
Normal file
@@ -0,0 +1 @@
|
||||
$Format:%H$
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
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
|
||||
|
||||
31
Makefile
Normal file
31
Makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
NAME=zsh-syntax-highlighting
|
||||
|
||||
INSTALL?=install -c
|
||||
PREFIX?=/usr/local
|
||||
SHARE_DIR=$(DESTDIR)$(PREFIX)/share/$(NAME)
|
||||
|
||||
# Have the default target do nothing.
|
||||
all:
|
||||
@ :
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(SHARE_DIR)
|
||||
cp -r .version zsh-syntax-highlighting.zsh highlighters $(SHARE_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
|
||||
|
||||
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
|
||||
|
||||
.PHONY: all install test
|
||||
29
README.md
29
README.md
@@ -13,13 +13,16 @@ How to install
|
||||
|
||||
* Arch Linux: [community/zsh-syntax-highlighting](https://www.archlinux.org/packages/zsh-syntax-highlighting) / [AUR/zsh-syntax-highlighting-git](https://aur.archlinux.org/packages/zsh-syntax-highlighting-git)
|
||||
* Gentoo: [mv overlay](http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting)
|
||||
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting](https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh-syntax-highlighting.rb)
|
||||
|
||||
### In your ~/.zshrc
|
||||
|
||||
* Download the script or clone this repository:
|
||||
* Clone this repository:
|
||||
|
||||
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
|
||||
(or [download a snapshot](https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz))
|
||||
|
||||
* Source the script **at the end** of `~/.zshrc`:
|
||||
|
||||
source /path/to/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
@@ -33,10 +36,9 @@ How to install
|
||||
|
||||
* Download the script or clone this repository in [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) plugins directory:
|
||||
|
||||
cd ~/.oh-my-zsh/custom/plugins
|
||||
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
|
||||
|
||||
* Activate the plugin in `~/.zshrc` (in **last** position):
|
||||
* Activate the plugin in `~/.zshrc`:
|
||||
|
||||
plugins=( [plugins...] zsh-syntax-highlighting)
|
||||
|
||||
@@ -44,6 +46,25 @@ How to install
|
||||
|
||||
source ~/.zshrc
|
||||
|
||||
Note that `zsh-syntax-highlighting` must be the last plugin sourced,
|
||||
so make it the last element of the `$plugins` array.
|
||||
|
||||
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
|
||||
------------
|
||||
|
||||
96
changelog.md
Normal file
96
changelog.md
Normal file
@@ -0,0 +1,96 @@
|
||||
# Changes in version 0.3.0
|
||||
|
||||
|
||||
## Added highlighting of:
|
||||
|
||||
- suffix aliases (requires zsh 5.1.1 or newer):
|
||||
|
||||
alias -s png=display
|
||||
foo.png
|
||||
|
||||
- prefix redirections:
|
||||
|
||||
<foo.txt cat
|
||||
|
||||
- redirection operators:
|
||||
|
||||
echo > foo.txt
|
||||
|
||||
- arithmetic evaluations:
|
||||
|
||||
(( 42 ))
|
||||
|
||||
- $'' strings, including \x/\octal/\u/\U escapes
|
||||
|
||||
: $'foo\u0040bar'
|
||||
|
||||
- multiline strings:
|
||||
|
||||
% echo "line 1
|
||||
line 2"
|
||||
|
||||
- string literals that haven't been finished:
|
||||
|
||||
% echo "Hello, world
|
||||
|
||||
- command words that involve tilde expansion:
|
||||
|
||||
% ~/bin/foo
|
||||
|
||||
|
||||
## Fixed highlighting of:
|
||||
|
||||
- quoted command words:
|
||||
|
||||
% \ls
|
||||
|
||||
- backslash escapes in "" strings:
|
||||
|
||||
% echo "\x41"
|
||||
|
||||
- noglob after command separator:
|
||||
|
||||
% :; noglob echo *
|
||||
|
||||
- glob after command separator, when the first command starts with 'noglob':
|
||||
|
||||
% noglob true; echo *
|
||||
|
||||
- the region (vi visual mode / set-mark-command) (issue #165)
|
||||
|
||||
- redirection and command separators that would be highlighted as `path_approx`
|
||||
|
||||
% echo foo;‸
|
||||
% echo <‸
|
||||
|
||||
(where `‸` represents the cursor location)
|
||||
|
||||
- escaped globbing (outside quotes)
|
||||
|
||||
% echo \*
|
||||
|
||||
|
||||
## Other changes:
|
||||
|
||||
- implemented compatibility with zsh's paste highlighting (issue #175)
|
||||
|
||||
- `$?` propagated correctly to wrapped widgets
|
||||
|
||||
- don't leak $REPLY into global scope
|
||||
|
||||
|
||||
## Developer-visible changes:
|
||||
|
||||
- added makefile with `install` and `test` targets
|
||||
|
||||
- set `warn_create_global` internally
|
||||
|
||||
- document release process
|
||||
|
||||
|
||||
|
||||
|
||||
# Version 0.2.1
|
||||
|
||||
(Start of changelog.)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,8 +30,8 @@
|
||||
BUFFER='echo ({x}]'
|
||||
|
||||
expected_region_highlight=(
|
||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # (
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # )
|
||||
"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]" # )
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,10 +30,10 @@
|
||||
BUFFER='echo $(echo ${(z)array})'
|
||||
|
||||
expected_region_highlight=(
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # (
|
||||
"13 13 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
||||
"14 14 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # (
|
||||
"16 16 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # )
|
||||
"22 22 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
||||
"23 23 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # )
|
||||
"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]" # )
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,5 +30,5 @@
|
||||
BUFFER='echo "foo ( bar"'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 15 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing
|
||||
"1 16 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,8 +30,8 @@
|
||||
BUFFER='echo ({x})'
|
||||
|
||||
expected_region_highlight=(
|
||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # (
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # )
|
||||
"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]" # )
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,7 +30,7 @@
|
||||
BUFFER='echo ({x}'
|
||||
|
||||
expected_region_highlight=(
|
||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # (
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # (
|
||||
"7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -31,7 +30,7 @@
|
||||
BUFFER='echo {x})'
|
||||
|
||||
expected_region_highlight=(
|
||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # {
|
||||
"7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # }
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # )
|
||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # {
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # }
|
||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # )
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -25,6 +25,7 @@ This highlighter defines the following styles:
|
||||
* `unknown-token` - unknown tokens / errors
|
||||
* `reserved-word` - shell reserved words
|
||||
* `alias` - aliases
|
||||
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
||||
* `builtin` - shell builtin commands
|
||||
* `function` - functions
|
||||
* `command` - commands
|
||||
@@ -34,20 +35,26 @@ This highlighter defines the following styles:
|
||||
* `path` - paths
|
||||
* `path_prefix` - path prefixes
|
||||
* `path_approx` - approximated paths
|
||||
* `globbing` - globbing expressions
|
||||
* `history-expansion` - history expansion expressions
|
||||
* `single-hyphen-option` - single hyphen options
|
||||
* `double-hyphen-option` - double hyphen options
|
||||
* `back-quoted-argument` - backquoted expressions
|
||||
* `single-quoted-argument` - single quoted arguments
|
||||
* `double-quoted-argument` - double quoted arguments
|
||||
* `dollar-double-quoted-argument` - dollar double quoted arguments
|
||||
* `back-double-quoted-argument` - back double quoted arguments
|
||||
* `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` - dollar double quoted arguments ($foo inside "")
|
||||
* `back-double-quoted-argument` - back double quoted arguments (\x inside "")
|
||||
* `back-dollar-quoted-argument` - back dollar quoted arguments (\x inside $'')
|
||||
* `assign` - variable assignments
|
||||
* `redirection` - redirection operators (`<`, `>`, etc)
|
||||
* `default` - parts of the buffer that do not match anything
|
||||
|
||||
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'
|
||||
|
||||
@@ -57,4 +64,5 @@ To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for
|
||||
# To disable highlighting of globbing expressions
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='none'
|
||||
|
||||
The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135).
|
||||
The syntax for declaring styles is documented in [the `zshzle(1)` manual
|
||||
page](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135).
|
||||
|
||||
228
highlighters/main/main-highlighter.zsh
Executable file → Normal file
228
highlighters/main/main-highlighter.zsh
Executable file → Normal file
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# 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
|
||||
@@ -34,6 +33,7 @@
|
||||
: ${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}
|
||||
@@ -50,9 +50,12 @@
|
||||
: ${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}
|
||||
|
||||
# Whether the highlighter should be called or not.
|
||||
_zsh_highlight_main_highlighter_predicate()
|
||||
@@ -60,15 +63,32 @@ _zsh_highlight_main_highlighter_predicate()
|
||||
_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")
|
||||
}
|
||||
|
||||
# Main syntax highlighting function.
|
||||
_zsh_highlight_main_highlighter()
|
||||
{
|
||||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual
|
||||
local start_pos=0 end_pos highlight_glob=true new_expression=true arg style sudo=false sudo_arg=false
|
||||
local redirection=false # true when we've seen a redirection operator before seeing the command word
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
||||
typeset -a ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS
|
||||
local buf="$PREBUFFER$BUFFER"
|
||||
region_highlight=()
|
||||
|
||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||
@@ -82,12 +102,36 @@ _zsh_highlight_main_highlighter()
|
||||
$ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
||||
)
|
||||
|
||||
for arg in ${(z)BUFFER}; do
|
||||
local substr_color=0
|
||||
for arg in ${(z)buf}; do
|
||||
# substr_color 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 substr_color=0
|
||||
local style_override=""
|
||||
[[ $start_pos -eq 0 && $arg = 'noglob' ]] && highlight_glob=false
|
||||
((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]##[[:space:]]#}}))
|
||||
((end_pos=$start_pos+${#arg}))
|
||||
if $new_expression && [[ $arg = 'noglob' ]]; then
|
||||
highlight_glob=false
|
||||
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
|
||||
|
||||
# Parse the sudo command line
|
||||
if $sudo; then
|
||||
case "$arg" in
|
||||
@@ -99,12 +143,12 @@ _zsh_highlight_main_highlighter()
|
||||
sudo_arg=false
|
||||
else
|
||||
sudo=false
|
||||
new_expression=true
|
||||
new_expression=true; highlight_glob=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if $new_expression; then
|
||||
if $new_expression && ! $redirection; then # $arg is the command word
|
||||
new_expression=false
|
||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[precommand]
|
||||
@@ -112,9 +156,14 @@ _zsh_highlight_main_highlighter()
|
||||
style=$ZSH_HIGHLIGHT_STYLES[precommand]
|
||||
sudo=true
|
||||
else
|
||||
res=$(LC_ALL=C builtin type -w $arg 2>/dev/null)
|
||||
_zsh_highlight_main_highlighter_expand_path $arg
|
||||
local expanded_arg="$REPLY"
|
||||
local res="$(LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null)"
|
||||
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_FOLLOWED_BY_COMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS+=($arg)
|
||||
@@ -125,78 +174,123 @@ _zsh_highlight_main_highlighter()
|
||||
*': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];;
|
||||
*) if _zsh_highlight_main_highlighter_check_assign; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[assign]
|
||||
new_expression=true
|
||||
elif _zsh_highlight_main_highlighter_check_path; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
||||
if [[ $arg[-1] != '(' ]]; then
|
||||
# assignment to a scalar parameter.
|
||||
# (For array assignments, the command doesn't start until the ")" token.)
|
||||
new_expression=true; highlight_glob=true
|
||||
fi
|
||||
elif [[ $arg[0,1] == $histchars[0,1] || $arg[0,1] == $histchars[2,2] ]]; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
||||
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
||||
redirection=true
|
||||
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
|
||||
substr_color=1
|
||||
else
|
||||
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
|
||||
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
|
||||
else # $arg is the file target of a prefix redirection, or a non-command word
|
||||
if $redirection; then
|
||||
redirection=false
|
||||
new_expression=true; highlight_glob=true
|
||||
fi
|
||||
case $arg in
|
||||
'--'*) 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]
|
||||
region_highlight+=("$start_pos $end_pos $style")
|
||||
"'"*) 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
|
||||
substr_color=1
|
||||
;;
|
||||
'`'*'`') style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
|
||||
*"*"*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
|
||||
*) if _zsh_highlight_main_highlighter_check_path; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
||||
\$\'*) 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
|
||||
substr_color=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
|
||||
style=$ZSH_HIGHLIGHT_STYLES[commandseparator]
|
||||
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[redirection]
|
||||
else
|
||||
style=$ZSH_HIGHLIGHT_STYLES[default]
|
||||
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]
|
||||
[[ $substr_color = 0 ]] && region_highlight+=("$start_pos $end_pos $style")
|
||||
[[ $substr_color = 0 ]] && _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && new_expression=true
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] && highlight_glob=true
|
||||
start_pos=$end_pos
|
||||
done
|
||||
}
|
||||
|
||||
# Check if the argument is variable assignment
|
||||
# Check if $arg is variable assignment
|
||||
_zsh_highlight_main_highlighter_check_assign()
|
||||
{
|
||||
setopt localoptions extended_glob
|
||||
[[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])=* ]]
|
||||
[[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]]
|
||||
}
|
||||
|
||||
# Check if the argument is a path.
|
||||
# Check if $arg is a path.
|
||||
_zsh_highlight_main_highlighter_check_path()
|
||||
{
|
||||
setopt localoptions nonomatch
|
||||
local expanded_path; : ${expanded_path:=${(Q)~arg}}
|
||||
_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 ]]; then
|
||||
local -a tmp
|
||||
# got a path prefix?
|
||||
tmp=( ${expanded_path}*(N) )
|
||||
(( $#tmp > 0 )) && style_override=path_prefix && return 0
|
||||
# or maybe an approximate path?
|
||||
tmp=( (#a1)${expanded_path}*(N) )
|
||||
(( $#tmp > 0 )) && style_override=path_approx && return 0
|
||||
fi
|
||||
|
||||
# It's not a path.
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -204,37 +298,87 @@ _zsh_highlight_main_highlighter_check_path()
|
||||
_zsh_highlight_main_highlighter_highlight_string()
|
||||
{
|
||||
setopt localoptions noksharrays
|
||||
local i j k style varflag
|
||||
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]
|
||||
(( varflag = 1))
|
||||
# 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
|
||||
else
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
"\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]
|
||||
for (( c = i + 1 ; c < end_pos - start_pos ; c += 1 )); do
|
||||
[[ "$arg[$c]" != ([0-9,xX,a-f,A-F]) ]] && break
|
||||
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 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" =~ "^(0*(x|X)[0-9,a-f,A-F]{1,2})" || "$AA" =~ "^(0[0-7]{1,3})" ]];then
|
||||
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
|
||||
(( varflag = 0 )) # End of variable
|
||||
;;
|
||||
([^a-zA-Z0-9_]))
|
||||
(( varflag = 0 )) # End of variable
|
||||
continue
|
||||
;;
|
||||
*) [[ $varflag -eq 0 ]] && continue ;;
|
||||
*) continue ;;
|
||||
|
||||
esac
|
||||
region_highlight+=("$j $k $style")
|
||||
_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}}
|
||||
}
|
||||
|
||||
51
highlighters/main/test-data/alias.zsh
Normal file
51
highlighters/main/test-data/alias.zsh
Normal file
@@ -0,0 +1,51 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
39
highlighters/main/test-data/arithmetic-evaluation.zsh
Normal file
39
highlighters/main/test-data/arithmetic-evaluation.zsh
Normal file
@@ -0,0 +1,39 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]" # ((
|
||||
)
|
||||
35
highlighters/main/test-data/assign-append.zsh
Normal file
35
highlighters/main/test-data/assign-append.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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+=(
|
||||
)
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -28,8 +27,10 @@
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
BUFFER='A=1'
|
||||
ZSH_HIGHLIGHT_STYLES[assign]=$unused_highlight
|
||||
BUFFER='A=1 b=("foo" bar)'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 3 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1
|
||||
"8 12 $ZSH_HIGHLIGHT_STYLES[double-quoted-argument]" # "foo"
|
||||
)
|
||||
|
||||
35
highlighters/main/test-data/back-quoted-argument.zsh
Normal file
35
highlighters/main/test-data/back-quoted-argument.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]"
|
||||
)
|
||||
35
highlighters/main/test-data/backslash-continuation.zsh
Normal file
35
highlighters/main/test-data/backslash-continuation.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
37
highlighters/main/test-data/commandseparator.zsh
Normal file
37
highlighters/main/test-data/commandseparator.zsh
Normal file
@@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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'
|
||||
|
||||
expected_region_highlight=(
|
||||
"2 2 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ;
|
||||
"4 6 $ZSH_HIGHLIGHT_STYLES[builtin]" # pwd
|
||||
)
|
||||
36
highlighters/main/test-data/dollar-quoted.zsh
Normal file
36
highlighters/main/test-data/dollar-quoted.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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'
|
||||
)
|
||||
41
highlighters/main/test-data/dollar-quoted2.zsh
Normal file
41
highlighters/main/test-data/dollar-quoted2.zsh
Normal file
@@ -0,0 +1,41 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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'
|
||||
)
|
||||
38
highlighters/main/test-data/dollar-quoted3.zsh
Normal file
38
highlighters/main/test-data/dollar-quoted3.zsh
Normal file
@@ -0,0 +1,38 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
35
highlighters/main/test-data/double-hyphen-option.zsh
Normal file
35
highlighters/main/test-data/double-hyphen-option.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
45
highlighters/main/test-data/double-quoted.zsh
Normal file
45
highlighters/main/test-data/double-quoted.zsh
Normal file
@@ -0,0 +1,45 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]" # :"
|
||||
)
|
||||
37
highlighters/main/test-data/double-quoted2.zsh
Normal file
37
highlighters/main/test-data/double-quoted2.zsh
Normal file
@@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# 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
|
||||
)
|
||||
39
highlighters/main/test-data/double-quoted3.zsh
Normal file
39
highlighters/main/test-data/double-quoted3.zsh
Normal file
@@ -0,0 +1,39 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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=': "$" "$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
|
||||
)
|
||||
36
highlighters/main/test-data/empty-command.zsh
Normal file
36
highlighters/main/test-data/empty-command.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# without the trailing space, it's highlighted as path_approx (issue #187, issue #204)
|
||||
BUFFER='echo; ; '
|
||||
|
||||
expected_region_highlight=(
|
||||
"5 5 $ZSH_HIGHLIGHT_STYLES[commandseparator]" # ;
|
||||
"7 7 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # ;
|
||||
)
|
||||
47
highlighters/main/test-data/function.zsh
Normal file
47
highlighters/main/test-data/function.zsh
Normal file
@@ -0,0 +1,47 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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.
|
||||
38
highlighters/main/test-data/glob.zsh
Normal file
38
highlighters/main/test-data/glob.zsh
Normal file
@@ -0,0 +1,38 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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\?
|
||||
)
|
||||
36
highlighters/main/test-data/hashed-command.zsh
Normal file
36
highlighters/main/test-data/hashed-command.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]"
|
||||
)
|
||||
36
highlighters/main/test-data/history-expansion.zsh
Normal file
36
highlighters/main/test-data/history-expansion.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
34
highlighters/main/test-data/history-expansion2.zsh
Normal file
34
highlighters/main/test-data/history-expansion2.zsh
Normal file
@@ -0,0 +1,34 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
36
highlighters/main/test-data/multiline-string.zsh
Normal file
36
highlighters/main/test-data/multiline-string.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]" # './'
|
||||
)
|
||||
35
highlighters/main/test-data/multiline-string2.zsh
Normal file
35
highlighters/main/test-data/multiline-string2.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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"'
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
34
highlighters/main/test-data/noglob1.zsh
Normal file
34
highlighters/main/test-data/noglob1.zsh
Normal file
@@ -0,0 +1,34 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]" # *
|
||||
)
|
||||
35
highlighters/main/test-data/noglob2.zsh
Normal file
35
highlighters/main/test-data/noglob2.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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]" # *
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -34,5 +33,5 @@ BUFFER='ls ~D/path-tilde-named.zsh'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls
|
||||
"4 23 $ZSH_HIGHLIGHT_STYLES[path]" # ~D/path-tilde-named.zsh
|
||||
"4 26 $ZSH_HIGHLIGHT_STYLES[path]" # ~D/path-tilde-named.zsh
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
37
highlighters/main/test-data/path_prefix.zsh
Normal file
37
highlighters/main/test-data/path_prefix.zsh
Normal file
@@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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 [[ -e /bin/sh ]].
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix]=$unused_highlight
|
||||
BUFFER='ls /bin/s'
|
||||
|
||||
expected_region_highlight=(
|
||||
"4 9 $ZSH_HIGHLIGHT_STYLES[path_prefix]" # /bin/s
|
||||
)
|
||||
38
highlighters/main/test-data/prefix-redirection.zsh
Normal file
38
highlighters/main/test-data/prefix-redirection.zsh
Normal file
@@ -0,0 +1,38 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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 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
|
||||
"23 25 $ZSH_HIGHLIGHT_STYLES[default]" # foo
|
||||
)
|
||||
37
highlighters/main/test-data/redirection.zsh
Normal file
37
highlighters/main/test-data/redirection.zsh
Normal file
@@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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='<<<foo echo >>&!bar'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 3 $ZSH_HIGHLIGHT_STYLES[redirection]" # <<<
|
||||
"13 16 $ZSH_HIGHLIGHT_STYLES[redirection]" # >>&!
|
||||
)
|
||||
36
highlighters/main/test-data/reserved-word.zsh
Normal file
36
highlighters/main/test-data/reserved-word.zsh
Normal file
@@ -0,0 +1,36 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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"
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -34,6 +33,6 @@ expected_region_highlight=(
|
||||
"1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps
|
||||
"4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux
|
||||
"8 8 $ZSH_HIGHLIGHT_STYLES[default]" # |
|
||||
"9 12 $ZSH_HIGHLIGHT_STYLES[command]" # grep
|
||||
"14 17 $ZSH_HIGHLIGHT_STYLES[default]" # java
|
||||
"10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep
|
||||
"15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2013 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
@@ -28,6 +27,7 @@
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=$unused_highlight
|
||||
BUFFER='sudo -u otheruser ls /'
|
||||
|
||||
expected_region_highlight=(
|
||||
|
||||
37
highlighters/main/test-data/tilde-command-word.zsh
Normal file
37
highlighters/main/test-data/tilde-command-word.zsh
Normal file
@@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
35
highlighters/main/test-data/unbackslash.zsh
Normal file
35
highlighters/main/test-data/unbackslash.zsh
Normal file
@@ -0,0 +1,35 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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)
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
39
highlighters/main/test-data/vanilla-newline.zsh
Normal file
39
highlighters/main/test-data/vanilla-newline.zsh
Normal file
@@ -0,0 +1,39 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# 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
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
|
||||
11
release.md
Normal file
11
release.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Release procedure (for developers):
|
||||
|
||||
- Check open issues and outstanding pull requests
|
||||
- Confirm `make test` passes
|
||||
- check with multiple zsh versions
|
||||
- Update changelog.md
|
||||
- Update ./.version
|
||||
- `git tag $(<.version) && git push --tags`
|
||||
- `perl -pi -e 's/$/-dev/' ./.version`
|
||||
- Notify downstreams (OS packages)
|
||||
- anitya should autodetect the tag
|
||||
@@ -5,6 +5,13 @@ Utility scripts for testing zsh-syntax-highlighting highlighters.
|
||||
|
||||
The tests expect 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 `"$i $j $style"` strings.
|
||||
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.
|
||||
|
||||
_Note_: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently.
|
||||
|
||||
|
||||
highlighting test
|
||||
-----------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# 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
|
||||
@@ -49,6 +49,9 @@
|
||||
|
||||
local -a errors highlight_zone
|
||||
local -A observed_result
|
||||
local -A save_ZSH_HIGHLIGHT_STYLES
|
||||
integer something_failed=0
|
||||
local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use
|
||||
|
||||
# Load the main script.
|
||||
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
||||
@@ -56,17 +59,21 @@ local -A observed_result
|
||||
# Activate the highlighter.
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
||||
|
||||
# Cache a pristine set of styles.
|
||||
save_ZSH_HIGHLIGHT_STYLES=( "${(@kv)ZSH_HIGHLIGHT_STYLES}" )
|
||||
|
||||
# Process each test data file in test data directory.
|
||||
for data_file in ${0:h:h}/highlighters/$1/test-data/*; do
|
||||
for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
|
||||
|
||||
# Load the data and prepare checking it.
|
||||
BUFFER= ; expected_region_highlight=(); errors=()
|
||||
PREBUFFER= BUFFER= ; expected_region_highlight=(); errors=()
|
||||
echo -n "* ${data_file:t:r}: "
|
||||
ZSH_HIGHLIGHT_STYLES=( "${(@kv)save_ZSH_HIGHLIGHT_STYLES}" )
|
||||
. $data_file
|
||||
|
||||
# Check the data declares $BUFFER.
|
||||
if [[ ${#BUFFER} -eq 0 ]]; then
|
||||
errors+=("'BUFFER' is not declared or blank.")
|
||||
# Check the data declares $PREBUFFER or $BUFFER.
|
||||
if [[ ${#PREBUFFER} -eq 0 && ${#BUFFER} -eq 0 ]]; then
|
||||
errors+=("Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank")
|
||||
else
|
||||
|
||||
# Check the data declares $expected_region_highlight.
|
||||
@@ -83,9 +90,17 @@ for data_file in ${0:h:h}/highlighters/$1/test-data/*; do
|
||||
observed_result=()
|
||||
for i in {1..${#region_highlight}}; do
|
||||
highlight_zone=${(z)region_highlight[$i]}
|
||||
for j in {$highlight_zone[1]..$highlight_zone[2]}; do
|
||||
observed_result[$j]=$highlight_zone[3]
|
||||
done
|
||||
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.
|
||||
@@ -107,9 +122,12 @@ for data_file in ${0:h:h}/highlighters/$1/test-data/*; do
|
||||
echo "OK"
|
||||
else
|
||||
echo "KO"
|
||||
(( something_failed=1 ))
|
||||
for error in $errors; do
|
||||
echo " - $error"
|
||||
done
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
exit $something_failed
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env zsh
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# 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
|
||||
@@ -29,6 +28,24 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
if [[ -o function_argzero ]]; then
|
||||
# $0 is reliable
|
||||
ZSH_HIGHLIGHT_VERSION=$(<"$0:h"/.version)
|
||||
ZSH_HIGHLIGHT_REVISION=$(<"$0: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:
|
||||
unset ZSH_HIGHLIGHT_REVISION
|
||||
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 FUNCTION_ARGZERO" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Core highlighting update system
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
@@ -42,11 +59,12 @@ typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS
|
||||
# This function is supposed to be called whenever the ZLE state changes.
|
||||
_zsh_highlight()
|
||||
{
|
||||
setopt localoptions nowarncreateglobal
|
||||
|
||||
# Store the previous command return code to restore it whatever happens.
|
||||
local ret=$?
|
||||
|
||||
setopt localoptions warncreateglobal
|
||||
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
|
||||
@@ -55,6 +73,7 @@ _zsh_highlight()
|
||||
[[ $PENDING -gt 0 ]] && return $ret
|
||||
|
||||
# Reset region highlight to build it from scratch
|
||||
typeset -ga region_highlight
|
||||
region_highlight=();
|
||||
|
||||
{
|
||||
@@ -92,10 +111,41 @@ _zsh_highlight()
|
||||
|
||||
done
|
||||
|
||||
} always {
|
||||
_ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER
|
||||
_ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR
|
||||
# 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +189,7 @@ _zsh_highlight_bind_widgets()
|
||||
|
||||
# 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|yank*)}; do
|
||||
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.
|
||||
@@ -211,8 +261,8 @@ _zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/
|
||||
# Reset scratch variables when commandline is done.
|
||||
_zsh_highlight_preexec_hook()
|
||||
{
|
||||
_ZSH_HIGHLIGHT_PRIOR_BUFFER=
|
||||
_ZSH_HIGHLIGHT_PRIOR_CURSOR=
|
||||
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 || {
|
||||
|
||||
Reference in New Issue
Block a user