Compare commits
255 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db085e4661 | ||
|
|
9bb3db7fd2 | ||
|
|
bb27265aee | ||
|
|
71bd576af8 | ||
|
|
d59ce0fbd0 | ||
|
|
e82e2d042d | ||
|
|
0b5b3dcc0c | ||
|
|
f8cd0b55b3 | ||
|
|
1e82d8c83e | ||
|
|
dd0cf649d1 | ||
|
|
65071902d3 | ||
|
|
143b25eb98 | ||
|
|
1386f1213e | ||
|
|
754cefe018 | ||
|
|
75ba3d87e3 | ||
|
|
b2c910a85e | ||
|
|
122dc46439 | ||
|
|
b828f45da6 | ||
|
|
caa749d030 | ||
|
|
c5ce001467 | ||
|
|
5459ebcc4e | ||
|
|
2cd73fcbde | ||
|
|
643717ccaf | ||
|
|
caeca0bf6b | ||
|
|
56b4433461 | ||
|
|
0ddb1a8d51 | ||
|
|
c10808ad5f | ||
|
|
b392045e6f | ||
|
|
c7caf57ca8 | ||
|
|
1a9264bc66 | ||
|
|
f6a22fa842 | ||
|
|
6e0e950154 | ||
|
|
dffe304567 | ||
|
|
f0e6a8ef5c | ||
|
|
0e1bb14452 | ||
|
|
894127b221 | ||
|
|
ebef4e5569 | ||
|
|
993a07fc7f | ||
|
|
e8517244f7 | ||
|
|
205bc7ea19 | ||
|
|
5eb494852e | ||
|
|
75c0eb0717 | ||
|
|
046cb03a12 | ||
|
|
1715f39a46 | ||
|
|
2ebfa6a598 | ||
|
|
aac09942b8 | ||
|
|
62c5575848 | ||
|
|
4cf464f843 | ||
|
|
6d5372a937 | ||
|
|
e9cad1493f | ||
|
|
79b6e7e05f | ||
|
|
3944a44ffe | ||
|
|
34674d7860 | ||
|
|
e4d1db1e2c | ||
|
|
c14fcad3b0 | ||
|
|
239c720dec | ||
|
|
7cc6226477 | ||
|
|
cba4a1bc2e | ||
|
|
637e1c702e | ||
|
|
2d60a47cc4 | ||
|
|
00a5fd11eb | ||
|
|
cdd7f899cb | ||
|
|
cb33cc0081 | ||
|
|
9ce3540d74 | ||
|
|
d62baa50f4 | ||
|
|
59cb9a560d | ||
|
|
7b863fb413 | ||
|
|
8a1bd7c8b6 | ||
|
|
daf0d94bae | ||
|
|
c28312b9d3 | ||
|
|
d9a7963970 | ||
|
|
810c2dcede | ||
|
|
075c852924 | ||
|
|
fb929edc30 | ||
|
|
91d2eeaf23 | ||
|
|
f6471dbec3 | ||
|
|
f6f7a91818 | ||
|
|
6fd92e1bbd | ||
|
|
792c065acb | ||
|
|
0f11d80968 | ||
|
|
00c0c76550 | ||
|
|
870bccf8ff | ||
|
|
a238647df9 | ||
|
|
f8b1470314 | ||
|
|
ade4b28d2d | ||
|
|
8211a95421 | ||
|
|
d4df626c03 | ||
|
|
8f5d74d219 | ||
|
|
700c0e18fe | ||
|
|
a50647e77b | ||
|
|
b253a8b86a | ||
|
|
4dd4797ae0 | ||
|
|
5171ec524f | ||
|
|
ea3ae74164 | ||
|
|
41b8a74692 | ||
|
|
3a4b212c7d | ||
|
|
0582ea1910 | ||
|
|
e65ebf0466 | ||
|
|
06710f3780 | ||
|
|
343ec1061f | ||
|
|
b08d508cd8 | ||
|
|
16d818a21f | ||
|
|
f1b9fbbaf0 | ||
|
|
8d32609a7b | ||
|
|
f5d1be7ec2 | ||
|
|
415e762ab2 | ||
|
|
ccb1da4ae8 | ||
|
|
96eb2e31a1 | ||
|
|
291634ecfe | ||
|
|
96e6cbe22f | ||
|
|
2a30d4fb5a | ||
|
|
90fec4d658 | ||
|
|
f563780236 | ||
|
|
b8c93afd34 | ||
|
|
2aca4e2c02 | ||
|
|
7678a8a227 | ||
|
|
5d139fcd94 | ||
|
|
d1802e388e | ||
|
|
aecfd61bbd | ||
|
|
2904e0f986 | ||
|
|
d5d2f22013 | ||
|
|
8eaa41431d | ||
|
|
e4f24f8901 | ||
|
|
1000da306a | ||
|
|
b44964c545 | ||
|
|
f54d829f03 | ||
|
|
9e9885253a | ||
|
|
3e7745ef30 | ||
|
|
b0af27f25f | ||
|
|
bd9094cc61 | ||
|
|
c7229a000a | ||
|
|
f2726d0464 | ||
|
|
8184266338 | ||
|
|
83ac855ceb | ||
|
|
3f930fb0c1 | ||
|
|
5545fb9ab2 | ||
|
|
a6eb966d96 | ||
|
|
c67372e96c | ||
|
|
29ca0bc6c8 | ||
|
|
08839bbd87 | ||
|
|
e2dddb91c6 | ||
|
|
cfef4f3ae0 | ||
|
|
48dd47931a | ||
|
|
3d81c83132 | ||
|
|
3c5f63d959 | ||
|
|
5a44d9f32a | ||
|
|
ea7c165b59 | ||
|
|
90a92b2bb8 | ||
|
|
fdf23e06c7 | ||
|
|
10171731f3 | ||
|
|
dfc41123d7 | ||
|
|
d6defe715a | ||
|
|
3ff5bec82e | ||
|
|
c4bb260a30 | ||
|
|
9bdeb4aa4a | ||
|
|
63852df983 | ||
|
|
66021cf0f7 | ||
|
|
0f627fdf60 | ||
|
|
bdb4e8b70e | ||
|
|
e6eea1f9b7 | ||
|
|
99389327ae | ||
|
|
e165f18c75 | ||
|
|
d237a60c9b | ||
|
|
2e65bb6d7d | ||
|
|
61c1cfe99f | ||
|
|
ea2f1060f6 | ||
|
|
e79ce6afd0 | ||
|
|
fb69f4ca81 | ||
|
|
1024ae8177 | ||
|
|
5720d87052 | ||
|
|
2339ee33b9 | ||
|
|
61945185ff | ||
|
|
936bc251a8 | ||
|
|
c699ce9a26 | ||
|
|
6e1a221699 | ||
|
|
9ceb7c6e7c | ||
|
|
b454b596ed | ||
|
|
e815d4579b | ||
|
|
3174e375f4 | ||
|
|
f56e3fad23 | ||
|
|
62e2d05f91 | ||
|
|
2cc2583f8f | ||
|
|
e15781c900 | ||
|
|
20d250d618 | ||
|
|
c73153c6e8 | ||
|
|
63bcd85dfa | ||
|
|
4bbd2a3bc6 | ||
|
|
241d3a92e8 | ||
|
|
6243c99f41 | ||
|
|
8f7e9b2af4 | ||
|
|
f63f07417d | ||
|
|
2331072c06 | ||
|
|
9e036e0b0c | ||
|
|
74c7ffc9b5 | ||
|
|
8feb06a022 | ||
|
|
fdf682a2f9 | ||
|
|
f564d11a41 | ||
|
|
8072651b6c | ||
|
|
9931990b92 | ||
|
|
525ba90932 | ||
|
|
9134cdf8d6 | ||
|
|
e94dc89606 | ||
|
|
f996d83975 | ||
|
|
54e1828d5c | ||
|
|
c5878ae632 | ||
|
|
498cc7641f | ||
|
|
81267ca313 | ||
|
|
bfd44f5c3f | ||
|
|
3ca93f864f | ||
|
|
a4525a0826 | ||
|
|
e58e45273f | ||
|
|
37b6f5052f | ||
|
|
a3c1757e47 | ||
|
|
b00be5f741 | ||
|
|
b85e313bc9 | ||
|
|
41d90cb5ed | ||
|
|
34df84a7dd | ||
|
|
1a752da1c2 | ||
|
|
8e3578240c | ||
|
|
edfc7dfd9b | ||
|
|
9880276756 | ||
|
|
027f522300 | ||
|
|
619fcad067 | ||
|
|
932e29a0c7 | ||
|
|
ec04a20681 | ||
|
|
cb8d68d00a | ||
|
|
04dd78cb00 | ||
|
|
4eb8a19133 | ||
|
|
b1f36d9c5f | ||
|
|
08edf8db7f | ||
|
|
6629a1f432 | ||
|
|
b7592e581d | ||
|
|
926c36c1fb | ||
|
|
4952325051 | ||
|
|
d5a4a6e195 | ||
|
|
e209cbe61a | ||
|
|
8d4c6355e6 | ||
|
|
56ba7f082d | ||
|
|
2cbb3fb24e | ||
|
|
f265ef0b9a | ||
|
|
d0fb0df4ff | ||
|
|
f665eec230 | ||
|
|
a868b6942e | ||
|
|
b5249f17ab | ||
|
|
d2594c1157 | ||
|
|
66ae59eccc | ||
|
|
1651137f5c | ||
|
|
d4ab7e51d2 | ||
|
|
38477f2a3d | ||
|
|
d98622dcd0 | ||
|
|
04fd6bbf53 | ||
|
|
30c6e70394 | ||
|
|
74a27de70d | ||
|
|
85e62a8171 | ||
|
|
aed99f6a3e |
@@ -7,3 +7,9 @@ end_of_line = lf
|
|||||||
tab_width = 2
|
tab_width = 2
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
tab_width = 8
|
||||||
|
indent_size = 8
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
|||||||
75
.github/workflows/test.yml
vendored
Normal file
75
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: Tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- '**.png'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- '**.png'
|
||||||
|
schedule:
|
||||||
|
- cron: '29 7 * * 1'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- master
|
||||||
|
- 5.9
|
||||||
|
- 5.8.1
|
||||||
|
- 5.8
|
||||||
|
- 5.7.1
|
||||||
|
- 5.7
|
||||||
|
- 5.6.2
|
||||||
|
- 5.6.1
|
||||||
|
- 5.6
|
||||||
|
- 5.5.1
|
||||||
|
- 5.5
|
||||||
|
- 5.4.2
|
||||||
|
- 5.4.1
|
||||||
|
- 5.4
|
||||||
|
- 5.3.1
|
||||||
|
- 5.3
|
||||||
|
- 5.2
|
||||||
|
- 5.1.1
|
||||||
|
- 5.1
|
||||||
|
- 5.0.8
|
||||||
|
- 5.0.7
|
||||||
|
- 5.0.6
|
||||||
|
- 5.0.5
|
||||||
|
- 5.0.4
|
||||||
|
- 5.0.3
|
||||||
|
- 5.0.2
|
||||||
|
- 5.0.1
|
||||||
|
- 5.0.0
|
||||||
|
- 4.3.17
|
||||||
|
- 4.3.16
|
||||||
|
- 4.3.15
|
||||||
|
- 4.3.14
|
||||||
|
- 4.3.13
|
||||||
|
- 4.3.12
|
||||||
|
- 4.3.11
|
||||||
|
container:
|
||||||
|
image: ghcr.io/zsh-users/zsh:${{ matrix.version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: install_packages bsdmainutils make procps
|
||||||
|
- run: make test
|
||||||
|
|
||||||
|
notify:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: failure() && (github.repository_owner == 'zsh-users')
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Notify IRC
|
||||||
|
uses: Gottox/irc-message-action@v2
|
||||||
|
with:
|
||||||
|
channel: '#zsh-syntax-highlighting'
|
||||||
|
nickname: zsyh-gh-bot
|
||||||
|
message: '${{ github.ref }} failed tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
|
||||||
55
.travis.yml
55
.travis.yml
@@ -1,55 +0,0 @@
|
|||||||
language: generic
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
env:
|
|
||||||
- ZSH=master
|
|
||||||
- ZSH=5.7.1
|
|
||||||
- ZSH=5.7
|
|
||||||
- ZSH=5.6.2
|
|
||||||
- ZSH=5.6.1
|
|
||||||
- ZSH=5.6
|
|
||||||
- ZSH=5.5.1
|
|
||||||
- ZSH=5.5
|
|
||||||
- ZSH=5.4.2
|
|
||||||
- ZSH=5.4.1
|
|
||||||
- ZSH=5.4
|
|
||||||
- ZSH=5.3.1
|
|
||||||
- ZSH=5.3
|
|
||||||
- ZSH=5.2
|
|
||||||
- ZSH=5.1.1
|
|
||||||
- ZSH=5.1
|
|
||||||
- ZSH=5.0.8
|
|
||||||
- ZSH=5.0.7
|
|
||||||
- ZSH=5.0.6
|
|
||||||
- ZSH=5.0.5
|
|
||||||
- ZSH=5.0.4
|
|
||||||
- ZSH=5.0.3
|
|
||||||
- ZSH=5.0.2
|
|
||||||
- ZSH=5.0.1
|
|
||||||
- ZSH=5.0.0
|
|
||||||
- ZSH=4.3.17
|
|
||||||
- ZSH=4.3.16
|
|
||||||
- ZSH=4.3.15
|
|
||||||
- ZSH=4.3.14
|
|
||||||
- ZSH=4.3.13
|
|
||||||
- ZSH=4.3.12
|
|
||||||
- ZSH=4.3.11
|
|
||||||
|
|
||||||
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps && make test'
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
webhooks:
|
|
||||||
urls:
|
|
||||||
- https://webhooks.gitter.im/e/367e241cdea60cb2070b
|
|
||||||
on_success: change
|
|
||||||
on_failure: always
|
|
||||||
on_start: never
|
|
||||||
irc:
|
|
||||||
channels:
|
|
||||||
- "chat.freenode.net#zsh-syntax-highlighting"
|
|
||||||
on_success: change
|
|
||||||
on_failure: always
|
|
||||||
on_start: never
|
|
||||||
use_notice: true
|
|
||||||
template:
|
|
||||||
- "%{repository}/%{branch}#%{build_number}: %{message} Changes : %{compare_url} | Build : %{build_url}"
|
|
||||||
18
HACKING.md
18
HACKING.md
@@ -67,6 +67,22 @@ expected_region_highlight=(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Memos and commas
|
||||||
|
----------------
|
||||||
|
|
||||||
|
We append to `region_highlight` as follows:
|
||||||
|
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
region_highlight+=("$start $end $spec, memo=zsh-syntax-highlighting")
|
||||||
|
```
|
||||||
|
|
||||||
|
That comma is required to cause zsh 5.8 and older to ignore the memo without
|
||||||
|
ignoring the `$spec`. It's a hack, but given that no further 5.8.x patch
|
||||||
|
releases are planned, it's been deemed acceptable. See issue #418 and the
|
||||||
|
cross-referenced issues.
|
||||||
|
|
||||||
|
|
||||||
Miscellany
|
Miscellany
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@@ -79,5 +95,5 @@ zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-hi
|
|||||||
IRC channel
|
IRC channel
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
We're on #zsh-syntax-highlighting on freenode.
|
We're on #zsh-syntax-highlighting on Libera.Chat.
|
||||||
|
|
||||||
|
|||||||
70
INSTALL.md
70
INSTALL.md
@@ -3,31 +3,67 @@ How to install
|
|||||||
|
|
||||||
### Using packages
|
### Using packages
|
||||||
|
|
||||||
|
First, install the package:
|
||||||
|
|
||||||
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
|
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
|
||||||
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository])
|
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository])
|
||||||
* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository])
|
* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository])
|
||||||
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port])
|
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port])
|
||||||
* Gentoo: [mv overlay][gentoo-overlay]
|
* Gentoo: [app-shells/zsh-syntax-highlighting][gentoo-repository]
|
||||||
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
|
* Mac OS X / Homebrew: `brew install zsh-syntax-highlighting` ([formula][brew-package])
|
||||||
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
|
* NetBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][netbsd-port])
|
||||||
* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
* OpenBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][openbsd-port])
|
||||||
* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
||||||
|
* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
|
||||||
|
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
|
||||||
* Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package]
|
* Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package]
|
||||||
|
|
||||||
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
|
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
|
||||||
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
|
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
|
||||||
|
[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/z/zsh-syntax-highlighting.rb
|
||||||
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
|
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
|
||||||
[freebsd-port]: http://www.freshports.org/textproc/zsh-syntax-highlighting/
|
|
||||||
[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting
|
|
||||||
[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-syntax-highlighting.rb
|
|
||||||
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
|
|
||||||
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
|
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
|
||||||
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
|
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
|
||||||
[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
|
[freebsd-port]: https://www.freshports.org/textproc/zsh-syntax-highlighting/
|
||||||
|
[gentoo-repository]: https://packages.gentoo.org/packages/app-shells/zsh-syntax-highlighting
|
||||||
|
[netbsd-port]: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/shells/zsh-syntax-highlighting/
|
||||||
|
[obs-repository]: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
|
||||||
|
[openbsd-port]: https://cvsweb.openbsd.org/ports/shells/zsh-syntax-highlighting/
|
||||||
|
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
|
||||||
[void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
|
[void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
|
||||||
|
|
||||||
See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
|
See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
|
||||||
|
|
||||||
|
Second, enable zsh-syntax-highlighting by sourcing the script. Running this command on the terminal will add the source line to the end of your .zshrc:
|
||||||
|
|
||||||
|
* On most Linux distributions (except perhaps NixOS):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
|
* NetBSD and OpenBSD:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
echo "source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
|
* Mac OS X / Homebrew:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
|
Then restart zsh (such as by opening a new instance of your terminal emulator).
|
||||||
|
|
||||||
|
Alternatively, add the `source` command manually **at the end** of your `.zshrc`:
|
||||||
|
|
||||||
|
* On most Linux distributions (except perhaps NixOS):
|
||||||
|
`source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`
|
||||||
|
* NetBSD and OpenBSD:
|
||||||
|
`source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`
|
||||||
|
|
||||||
|
Then restart zsh.
|
||||||
|
|
||||||
### In your ~/.zshrc
|
### In your ~/.zshrc
|
||||||
|
|
||||||
@@ -71,6 +107,12 @@ This list is incomplete as there are too many
|
|||||||
Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in
|
Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in
|
||||||
your `.zshrc`.
|
your `.zshrc`.
|
||||||
|
|
||||||
|
#### [Fig](https://fig.io)
|
||||||
|
|
||||||
|
Click the `Install Plugin` button on the [Fig plugin page][fig-plugin].
|
||||||
|
|
||||||
|
[fig-plugin]: https://fig.io/plugins/other/zsh-syntax-highlighting
|
||||||
|
|
||||||
#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
|
#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
|
||||||
|
|
||||||
1. Clone this repository in oh-my-zsh's plugins directory:
|
1. Clone this repository in oh-my-zsh's plugins directory:
|
||||||
@@ -98,15 +140,15 @@ Zsh-syntax-highlighting is included with Prezto. See the
|
|||||||
|
|
||||||
Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
|
Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
|
||||||
|
|
||||||
|
#### [zinit](https://github.com/zdharma-continuum/zinit)
|
||||||
|
|
||||||
|
Add `zinit light zsh-users/zsh-syntax-highlighting` to the end of your
|
||||||
|
`.zshrc`.
|
||||||
|
|
||||||
#### [zplug](https://github.com/zplug/zplug)
|
#### [zplug](https://github.com/zplug/zplug)
|
||||||
|
|
||||||
Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`.
|
Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`.
|
||||||
|
|
||||||
#### [zplugin](https://github.com/psprint/zplugin)
|
|
||||||
|
|
||||||
Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your
|
|
||||||
`.zshrc`.
|
|
||||||
|
|
||||||
|
|
||||||
### System-wide installation
|
### System-wide installation
|
||||||
|
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -41,7 +41,7 @@ test:
|
|||||||
for test in highlighters/*; do \
|
for test in highlighters/*; do \
|
||||||
if [ -d $$test/test-data ]; then \
|
if [ -d $$test/test-data ]; then \
|
||||||
echo "Running test $${test##*/}"; \
|
echo "Running test $${test##*/}"; \
|
||||||
$(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
|
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
|
||||||
: $$(( result |= $$? )); \
|
: $$(( result |= $$? )); \
|
||||||
fi \
|
fi \
|
||||||
done; \
|
done; \
|
||||||
|
|||||||
35
README.md
35
README.md
@@ -1,12 +1,12 @@
|
|||||||
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
|
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status]
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
**[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].**
|
**[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].**
|
||||||
|
|
||||||
*Requirements: zsh 4.3.11+.*
|
*Requirements: zsh 4.3.11+.*
|
||||||
|
|
||||||
[fish]: http://www.fishshell.com/
|
[fish]: https://fishshell.com/
|
||||||
[zsh]: http://www.zsh.org/
|
[zsh]: https://www.zsh.org/
|
||||||
|
|
||||||
This package provides syntax highlighting for the shell zsh. It enables
|
This package provides syntax highlighting for the shell zsh. It enables
|
||||||
highlighting of commands whilst they are typed at a zsh prompt into an
|
highlighting of commands whilst they are typed at a zsh prompt into an
|
||||||
@@ -27,6 +27,11 @@ Before: [](images/before3.png)
|
|||||||
<br/>
|
<br/>
|
||||||
After: [](images/after3.png)
|
After: [](images/after3.png)
|
||||||
|
|
||||||
|
Before: [](images/before4-smaller.png)
|
||||||
|
<br/>
|
||||||
|
After: [](images/after4-smaller.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
How to install
|
How to install
|
||||||
--------------
|
--------------
|
||||||
@@ -39,11 +44,23 @@ FAQ
|
|||||||
|
|
||||||
### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file?
|
### 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
|
zsh-syntax-highlighting works by hooking into the Zsh Line Editor (ZLE) and
|
||||||
custom widgets have been created (i.e., after all `zle -N` calls and after
|
computing syntax highlighting for the command-line buffer as it stands at the
|
||||||
running `compinit`). Widgets created later will work, but will not update the
|
time z-sy-h's hook is invoked.
|
||||||
|
|
||||||
|
In zsh 5.2 and older,
|
||||||
|
`zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must
|
||||||
|
be sourced after all custom widgets have been created (i.e., after all `zle -N`
|
||||||
|
calls and after running `compinit`) in order to be able to wrap all of them.
|
||||||
|
Widgets created after z-sy-h is sourced will work, but will not update the
|
||||||
syntax highlighting.
|
syntax highlighting.
|
||||||
|
|
||||||
|
In zsh newer than 5.8 (not including 5.8 itself),
|
||||||
|
zsh-syntax-highlighting uses the `add-zle-hook-widget` facility to install
|
||||||
|
a `zle-line-pre-redraw` hook. Hooks are run in order of registration,
|
||||||
|
therefore, z-sy-h must be sourced (and register its hook) after anything else
|
||||||
|
that adds hooks that modify the command-line buffer.
|
||||||
|
|
||||||
### Does syntax highlighting work during incremental history search?
|
### Does syntax highlighting work during incremental history search?
|
||||||
|
|
||||||
Highlighting the command line during an incremental history search (by default bound to
|
Highlighting the command line during an incremental history search (by default bound to
|
||||||
@@ -56,7 +73,7 @@ enough information to allow computing the highlighting correctly.)
|
|||||||
|
|
||||||
See issues [#288][i288] and [#415][i415] for details.
|
See issues [#288][i288] and [#415][i415] for details.
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
|
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
|
||||||
[i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415
|
[i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415
|
||||||
|
|
||||||
@@ -76,5 +93,5 @@ Syntax highlighting is done by pluggable highlighter scripts. See the
|
|||||||
[documentation on highlighters](docs/highlighters.md) for details and
|
[documentation on highlighters](docs/highlighters.md) for details and
|
||||||
configuration settings.
|
configuration settings.
|
||||||
|
|
||||||
[build-status-image]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting.svg?branch=master
|
[build-status]: https://github.com/zsh-users/zsh-syntax-highlighting/actions
|
||||||
[build-status-travis]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting
|
[build-status-image]: https://github.com/zsh-users/zsh-syntax-highlighting/workflows/Tests/badge.svg
|
||||||
|
|||||||
248
changelog.md
248
changelog.md
@@ -1,6 +1,236 @@
|
|||||||
# Changes in version 0.7.0
|
# Changes in 0.8.0
|
||||||
|
|
||||||
**Version 0.7.0 has not been released. This changelog is a work in progress.**
|
This is a stable bugfix and feature release. Major new features and changes include:
|
||||||
|
|
||||||
|
|
||||||
|
## Changes fixed as part of the switch to zle-line-pre-redraw
|
||||||
|
|
||||||
|
The changes in this section were fixed by switching to a `zle-line-pre-redraw`-based
|
||||||
|
implementation.
|
||||||
|
|
||||||
|
Note: The new implementation will only be used on future zsh releases,
|
||||||
|
numbered 5.8.1.1 and newer, due to interoperability issues with other plugins
|
||||||
|
(issues #418 and #579). The underlying zsh feature has been available since
|
||||||
|
zsh 5.3.
|
||||||
|
|
||||||
|
Whilst under development, the new implementation was known as the
|
||||||
|
"feature/redrawhook" topic branch.
|
||||||
|
|
||||||
|
- Fixed: Highlighting not triggered after popping a buffer from the buffer stack
|
||||||
|
(using the `push-line` widget, default binding: `M-q`)
|
||||||
|
[#40]
|
||||||
|
|
||||||
|
- Fixed: Invoking completion when there were no matches removed highlighting
|
||||||
|
[#90, #470]
|
||||||
|
|
||||||
|
- Fixed: Two successive deletes followed by a yank only yanked the latest
|
||||||
|
delete, rather than both of them
|
||||||
|
[#150, #151, #160; cf. #183]
|
||||||
|
|
||||||
|
- Presumed fixed: Completing `$(xsel)` results in an error message from `xsel`,
|
||||||
|
with pre-2017 versions of `xsel`. (For 2017 vintage and newer, see the issue
|
||||||
|
for details.)
|
||||||
|
[#154]
|
||||||
|
|
||||||
|
- Fixed: When the standard `bracketed-paste-magic` widget is in use, pastes were slow
|
||||||
|
[#295]
|
||||||
|
|
||||||
|
- Fixed: No way to prevent a widget from being wrapped
|
||||||
|
[#324]
|
||||||
|
|
||||||
|
- Fixed: No highlighting while cycling menu completion
|
||||||
|
[#375]
|
||||||
|
|
||||||
|
- Fixed: Does not coexist with the `IGNORE_EOF` option
|
||||||
|
[#377]
|
||||||
|
|
||||||
|
- Fixed: The `undefined-key` widget was wrapped
|
||||||
|
[#421]
|
||||||
|
|
||||||
|
- Fixed: Does not coexist with the standard `surround` family of widgets
|
||||||
|
[#520]
|
||||||
|
|
||||||
|
- Fixed: First completed filename doesn't get `path` highlighting
|
||||||
|
[#632]
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes
|
||||||
|
|
||||||
|
- Add issue #712 to the previous release's changelog (hereinafter).
|
||||||
|
|
||||||
|
- Fix highlighting when using an alias twice inside another alias
|
||||||
|
[#769, #775]
|
||||||
|
|
||||||
|
- Remove lint warning for `env` followed by a pipe
|
||||||
|
[#797]
|
||||||
|
|
||||||
|
- Recognize `proxychains` as a precommand
|
||||||
|
[#814, #914]
|
||||||
|
|
||||||
|
- Honor shwordsplit when expanding parameters
|
||||||
|
[#687, #818]
|
||||||
|
|
||||||
|
- Skip highlighting when keys are still pending in more cases
|
||||||
|
[#835]
|
||||||
|
|
||||||
|
- Recognize `grc` as a precommand
|
||||||
|
|
||||||
|
- Recognize `torsocks` and `torift` as precommands
|
||||||
|
[#898]
|
||||||
|
|
||||||
|
- Recognize `cpulimit` as a precommand
|
||||||
|
[#897]
|
||||||
|
|
||||||
|
- Recognize `ktrace` as a precommand
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in 0.8.0-alpha1-pre-redrawhook
|
||||||
|
|
||||||
|
## Notice about an improbable-but-not-impossible forward incompatibility
|
||||||
|
|
||||||
|
Everyone can probably skip this section.
|
||||||
|
|
||||||
|
The `master` branch of zsh-syntax-highlighting uses a zsh feature that has not
|
||||||
|
yet appeared in a zsh release: the `memo=` feature, added to zsh in commit
|
||||||
|
zsh-5.8-172-gdd6e702ee (after zsh 5.8, before zsh 5.9). In the unlikely event
|
||||||
|
that this zsh feature should change in an incompatible way before the next
|
||||||
|
stable zsh release, set `zsh_highlight__memo_feature=0` in your .zshrc files to
|
||||||
|
disable use of the new feature.
|
||||||
|
|
||||||
|
z-sy-h dogfoods the new, unreleased zsh feature because that feature was
|
||||||
|
added to zsh at z-sy-h's initiative. The new feature is used in the fix
|
||||||
|
to issue #418.
|
||||||
|
|
||||||
|
|
||||||
|
## Incompatible changes:
|
||||||
|
|
||||||
|
- An unsuccessful completion (a <kbd>⮀ Tab</kbd> press that doesn't change the
|
||||||
|
command line) no longer causes highlighting to be lost. Visual feedback can
|
||||||
|
alternatively be achieved by setting the `format` zstyle under the `warnings`
|
||||||
|
tag, for example,
|
||||||
|
|
||||||
|
zstyle ':completion:*:warnings' format '%F{red}No matches%f'
|
||||||
|
|
||||||
|
Refer to the [description of the `format` style in `zshcompsys(1)`]
|
||||||
|
[zshcompsys-Standard-Styles-format].
|
||||||
|
|
||||||
|
(#90, part of #245 (feature/redrawhook))
|
||||||
|
|
||||||
|
[zshcompsys-Standard-Styles]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Standard-Styles
|
||||||
|
[zshcompsys-Standard-Styles-format]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#index-format_002c-completion-style
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes:
|
||||||
|
|
||||||
|
- Document `$ZSH_HIGHLIGHT_MAXLENGTH`.
|
||||||
|
[#698]
|
||||||
|
|
||||||
|
- Optimize highlighting unquoted words (words that are not in single quotes, double quotes, backticks, or dollar-single-quotes)
|
||||||
|
[#730]
|
||||||
|
|
||||||
|
- Redirection operators (e.g., `<` and `>`) are now highlighted by default
|
||||||
|
[#646]
|
||||||
|
|
||||||
|
- Propertly terminate `noglob` scope in try/always blocks
|
||||||
|
[#577]
|
||||||
|
|
||||||
|
- Don't error out when `KSH_ARRAYS` is set in the calling scope
|
||||||
|
[#622, #689]
|
||||||
|
|
||||||
|
- Literal semicolons in array assignments (`foo=( bar ; baz )`) are now
|
||||||
|
highlighted as errors.
|
||||||
|
[3ca93f864fb6]
|
||||||
|
|
||||||
|
- Command separators in array assignments (`foo=( bar | baz )`) are now
|
||||||
|
highlighted as errors.
|
||||||
|
[#651, 81267ca3130c]
|
||||||
|
|
||||||
|
- Support parameter elision in command position (e.g., `$foo ls` where `$foo` is unset or empty)
|
||||||
|
[#667]
|
||||||
|
|
||||||
|
- Don't consider the filename in `sudo -e /path/to/file` to be a command position
|
||||||
|
[#678]
|
||||||
|
|
||||||
|
- Don't look up absolute directory names in $cdpath
|
||||||
|
[2cc2583f8f12, part of #669]
|
||||||
|
|
||||||
|
- Fix `exec 2>&1;` being highlighted as an error.
|
||||||
|
[#676]
|
||||||
|
|
||||||
|
- Fix `: $(<*)` being highlighted as globbing.
|
||||||
|
[#582]
|
||||||
|
|
||||||
|
- Fix `cat < *` being highlighting as globbing when the `MULTIOS` option is unset.
|
||||||
|
[#583]
|
||||||
|
|
||||||
|
- Fix `echo >&2` highlighting the `2` as a filename if a file by that name happened to exist
|
||||||
|
[#694, part of #645]
|
||||||
|
|
||||||
|
- Fix `echo >&-` highlighting the `-` as a filename if a file by that name happened to exist
|
||||||
|
[part of #645]
|
||||||
|
|
||||||
|
- Fix `echo >&p` highlighting the `p` as a filename if a file by that name happened to exist
|
||||||
|
[part of #645]
|
||||||
|
|
||||||
|
- Fix wrong highlighting of unquoted parameter expansions under zsh 5.2 and older
|
||||||
|
[e165f18c758e]
|
||||||
|
|
||||||
|
- Highlight global aliases
|
||||||
|
[#700]
|
||||||
|
|
||||||
|
- Highlight `: =nosuchcommand' as an error (when the `EQUALS` option hasn't been unset).
|
||||||
|
[#430]
|
||||||
|
|
||||||
|
- Highlight reserved word after assignments as errors (e.g., `foo=bar (ls;)`)
|
||||||
|
[#461]
|
||||||
|
|
||||||
|
- Correctly highlight `[[ foo && bar || baz ]]`.
|
||||||
|
|
||||||
|
- Highlight non-executable files in command position correctly (e.g., `% /etc/passwd`)
|
||||||
|
[#202, #669]
|
||||||
|
|
||||||
|
- Highlight directories in command position correctly, including `AUTO_CD` support
|
||||||
|
[#669]
|
||||||
|
|
||||||
|
- Recognize `env` as a precommand (e.g., `env FOO=bar ls`)
|
||||||
|
|
||||||
|
- Recognize `ionice` as a precommand
|
||||||
|
|
||||||
|
- Recognize `strace` as a precommand
|
||||||
|
|
||||||
|
- Fix an error message on stderr before every prompt when the `WARN_NESTED_VAR` zsh option is set:
|
||||||
|
`_zsh_highlight_main__precmd_hook:1: array parameter _zsh_highlight_main__command_type_cache set in enclosing scope in function _zsh_highlight_main__precmd_hook`
|
||||||
|
[#727, #731, #732, #733]
|
||||||
|
|
||||||
|
- Fix highlighting of alias whose definitions use a simple command terminator
|
||||||
|
(such as `;`, `|`, `&&`) before a newline
|
||||||
|
[#677; had regressed in 0.7.0]
|
||||||
|
|
||||||
|
- Highlight arithmetic expansions (e.g., `$(( 42 ))`)
|
||||||
|
[#607 #649 #704]
|
||||||
|
|
||||||
|
- Highlight the parentheses of array assignments as reserved words (`foo=( bar )`).
|
||||||
|
The `assign` style remains supported and has precedence.
|
||||||
|
[#585]
|
||||||
|
|
||||||
|
- Fix interoperability issue with other plugins that use highlighting. The fix
|
||||||
|
requires zsh 5.8.0.3 or newer. (zsh 5.8.0.2-dev from the `master` branch,
|
||||||
|
revision zsh-5.8-172-gdd6e702ee or newer is also fine.)
|
||||||
|
[#418, https://github.com/okapia/zsh-viexchange/issues/1]
|
||||||
|
|
||||||
|
- Improve performance of the `brackets` highlighter.
|
||||||
|
|
||||||
|
- Fix highlighting of pre-command redirections (e.g., the `$fn` in `<$fn cat`)
|
||||||
|
[#712]
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in version 0.7.1
|
||||||
|
|
||||||
|
- Remove out-of-date information from the 0.7.0 changelog.
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in version 0.7.0
|
||||||
|
|
||||||
This is a stable bugfix and feature release. Major new features and changes include:
|
This is a stable bugfix and feature release. Major new features and changes include:
|
||||||
|
|
||||||
@@ -32,7 +262,7 @@ This is a stable bugfix and feature release. Major new features and changes inc
|
|||||||
|
|
||||||
- Highlight numeric globs (e.g., `echo /lib<->`)
|
- Highlight numeric globs (e.g., `echo /lib<->`)
|
||||||
|
|
||||||
- Assorted improvement to aliases highlighting
|
- Assorted improvements to aliases highlighting
|
||||||
(e.g.,
|
(e.g.,
|
||||||
`alias sudo_u='sudo -u'; sudo_u jrandom ls`,
|
`alias sudo_u='sudo -u'; sudo_u jrandom ls`,
|
||||||
`alias x=y y=z z=nosuchcommand; x`,
|
`alias x=y y=z z=nosuchcommand; x`,
|
||||||
@@ -70,13 +300,7 @@ Known issues include:
|
|||||||
before a newline will incorrectly be highlighted as an error. See issue #677
|
before a newline will incorrectly be highlighted as an error. See issue #677
|
||||||
for examples and workarounds.
|
for examples and workarounds.
|
||||||
[#677]
|
[#677]
|
||||||
|
[UPDATE: Fixed in 0.8.0]
|
||||||
- Use of a simple parameter expansion (`${foo}` with nothing but a parameter
|
|
||||||
name inside the braces) in command position, when the value of the parameter
|
|
||||||
looks like an assignment (such as after `foo='bar=$(ls)'`), may result in
|
|
||||||
incorrect highlighting and "BUG" messages. As a workaround, the expansion
|
|
||||||
may be nested (`${${foo}}`).
|
|
||||||
[#670]
|
|
||||||
|
|
||||||
|
|
||||||
# Changes in version 0.6.0
|
# Changes in version 0.6.0
|
||||||
@@ -94,7 +318,7 @@ This is a stable release, featuring bugfixes and minor improvements.
|
|||||||
- The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting].
|
- The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting].
|
||||||
(79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support)
|
(79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support)
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|
||||||
- Possible history expansions in double-quoted strings.
|
- Possible history expansions in double-quoted strings.
|
||||||
(76ea9e1df316)
|
(76ea9e1df316)
|
||||||
@@ -540,7 +764,7 @@ in this area.
|
|||||||
|
|
||||||
## Developer-visible changes:
|
## Developer-visible changes:
|
||||||
|
|
||||||
- Test harness converted to [TAP](http://testanything.org/tap-specification.html) format
|
- Test harness converted to [TAP](https://testanything.org/tap-specification.html) format
|
||||||
(d99aa58aaaef, et seq)
|
(d99aa58aaaef, et seq)
|
||||||
|
|
||||||
- Run each test in a separate subprocess, isolating them from each other
|
- Run each test in a separate subprocess, isolating them from each other
|
||||||
|
|||||||
@@ -3,34 +3,51 @@ zsh-syntax-highlighting / highlighters
|
|||||||
|
|
||||||
Syntax highlighting is done by pluggable highlighters:
|
Syntax highlighting is done by pluggable highlighters:
|
||||||
|
|
||||||
* `main` - the base highlighter, and the only one [active by default][1].
|
* `main` - the base highlighter, and the only one [active by default][main].
|
||||||
* `brackets` - [matches brackets][2] and parenthesis.
|
* `brackets` - [matches brackets][brackets] and parenthesis.
|
||||||
* `pattern` - matches [user-defined patterns][3].
|
* `pattern` - matches [user-defined patterns][pattern].
|
||||||
* `cursor` - matches [the cursor position][4].
|
* `regexp` - matches [user-defined regular expressions][regexp].
|
||||||
* `root` - highlights the whole command line [if the current user is root][5].
|
* `cursor` - matches [the cursor position][cursor].
|
||||||
* `line` - applied to [the whole command line][6].
|
* `root` - highlights the whole command line [if the current user is root][root].
|
||||||
|
* `line` - applied to [the whole command line][line].
|
||||||
|
|
||||||
[1]: highlighters/main.md
|
[main]: highlighters/main.md
|
||||||
[2]: highlighters/brackets.md
|
[brackets]: highlighters/brackets.md
|
||||||
[3]: highlighters/pattern.md
|
[pattern]: highlighters/pattern.md
|
||||||
[4]: highlighters/cursor.md
|
[regexp]: highlighters/regexp.md
|
||||||
[5]: highlighters/root.md
|
[cursor]: highlighters/cursor.md
|
||||||
[6]: highlighters/line.md
|
[root]: highlighters/root.md
|
||||||
|
[line]: highlighters/line.md
|
||||||
|
|
||||||
|
|
||||||
|
Highlighter-independent settings
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
By default, all command lines are highlighted. However, it is possible to
|
||||||
|
prevent command lines longer than a fixed number of characters from being
|
||||||
|
highlighted by setting the variable `${ZSH_HIGHLIGHT_MAXLENGTH}` to the maximum
|
||||||
|
length (in characters) of command lines to be highlighter. This is useful when
|
||||||
|
editing very long command lines (for example, with the [`fned`][fned] utility
|
||||||
|
function). Example:
|
||||||
|
|
||||||
|
[fned]: https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#index-zed
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
ZSH_HIGHLIGHT_MAXLENGTH=512
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
How to activate highlighters
|
How to activate highlighters
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in
|
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array.
|
||||||
`~/.zshrc`, for example:
|
By default `ZSH_HIGHLIGHT_HIGHLIGHTERS` is `(main)`. For example to activate
|
||||||
|
`brackets`, `pattern`, and `cursor` highlighters, in `~/.zshrc` do:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(brackets pattern cursor)
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main`
|
|
||||||
highlighter is active.
|
|
||||||
|
|
||||||
|
|
||||||
How to tweak highlighters
|
How to tweak highlighters
|
||||||
-------------------------
|
-------------------------
|
||||||
@@ -42,7 +59,7 @@ same as the syntax of "types of highlighting" of the zsh builtin
|
|||||||
`$zle_highlight` array, which is documented in [the `zshzle(1)` manual
|
`$zle_highlight` array, which is documented in [the `zshzle(1)` manual
|
||||||
page][zshzle-Character-Highlighting].
|
page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|
||||||
Some highlighters support additional configuration parameters; see each
|
Some highlighters support additional configuration parameters; see each
|
||||||
highlighter's documentation for details and examples.
|
highlighter's documentation for details and examples.
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of
|
|||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
manual page][zshzle-Character-Highlighting].
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of
|
|||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
manual page][zshzle-Character-Highlighting].
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of
|
|||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
manual page][zshzle-Character-Highlighting].
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ This highlighter defines the following styles:
|
|||||||
* `reserved-word` - shell reserved words (`if`, `for`)
|
* `reserved-word` - shell reserved words (`if`, `for`)
|
||||||
* `alias` - aliases
|
* `alias` - aliases
|
||||||
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
||||||
|
* `global-alias` - global aliases
|
||||||
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
|
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
|
||||||
* `function` - function names
|
* `function` - function names
|
||||||
* `command` - command names
|
* `command` - command names
|
||||||
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
||||||
* `commandseparator` - command separation tokens (`;`, `&&`)
|
* `commandseparator` - command separation tokens (`;`, `&&`)
|
||||||
* `hashed-command` - hashed commands
|
* `hashed-command` - hashed commands
|
||||||
|
* `autodirectory` - a directory name in command position when the `AUTO_CD` option is set
|
||||||
* `path` - existing filenames
|
* `path` - existing filenames
|
||||||
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
|
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
|
||||||
* `path_prefix` - prefixes of existing filenames
|
* `path_prefix` - prefixes of existing filenames
|
||||||
@@ -40,6 +42,7 @@ This highlighter defines the following styles:
|
|||||||
* `command-substitution-delimiter-quoted` - a quoted command substitution delimiters (`"$(` and `)"`)
|
* `command-substitution-delimiter-quoted` - a quoted command substitution delimiters (`"$(` and `)"`)
|
||||||
* `process-substitution` - process substitutions (`<(echo foo)`)
|
* `process-substitution` - process substitutions (`<(echo foo)`)
|
||||||
* `process-substitution-delimiter` - process substitution delimiters (`<(` and `)`)
|
* `process-substitution-delimiter` - process substitution delimiters (`<(` and `)`)
|
||||||
|
* `arithmetic-expansion` - arithmetic expansion `$(( 42 ))`)
|
||||||
* `single-hyphen-option` - single-hyphen options (`-o`)
|
* `single-hyphen-option` - single-hyphen options (`-o`)
|
||||||
* `double-hyphen-option` - double-hyphen options (`--option`)
|
* `double-hyphen-option` - double-hyphen options (`--option`)
|
||||||
* `back-quoted-argument` - backtick command substitution (`` `foo` ``)
|
* `back-quoted-argument` - backtick command substitution (`` `foo` ``)
|
||||||
@@ -58,7 +61,9 @@ This highlighter defines the following styles:
|
|||||||
* `assign` - parameter assignments (`x=foo` and `x=( )`)
|
* `assign` - parameter assignments (`x=foo` and `x=( )`)
|
||||||
* `redirection` - redirection operators (`<`, `>`, etc)
|
* `redirection` - redirection operators (`<`, `>`, etc)
|
||||||
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
|
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
|
||||||
* `named-fd` - named file descriptor (`echo foo {fd}>&2`)
|
* `comment` - elided parameters in command position (`$x ls` when `$x` is unset or empty)
|
||||||
|
* `named-fd` - named file descriptor (the `fd` in `echo foo {fd}>&2`)
|
||||||
|
* `numeric-fd` - numeric file descriptor (the `2` in `echo foo {fd}>&2`)
|
||||||
* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command).
|
* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command).
|
||||||
* `default` - everything else
|
* `default` - everything else
|
||||||
|
|
||||||
@@ -111,6 +116,6 @@ of that (new) kind will be highlighted by the style `arg0_$kind`,
|
|||||||
where `$kind` is the output of `type -w` on the new kind of command word. If that
|
where `$kind` is the output of `type -w` on the new kind of command word. If that
|
||||||
style is not defined, then the style `arg0` will be used instead.
|
style is not defined, then the style `arg0` will be used instead.
|
||||||
|
|
||||||
[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
|
[zshmisc-Simple-Commands-And-Pipelines]: https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of
|
|||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
manual page][zshzle-Character-Highlighting].
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -11,12 +11,45 @@ To use this highlighter, associate regular expressions with styles in the
|
|||||||
`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`:
|
`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
typeset -A ZSH_HIGHLIGHT_PATTERNS
|
typeset -A ZSH_HIGHLIGHT_REGEXP
|
||||||
|
ZSH_HIGHLIGHT_REGEXP+=('^rm .*' fg=red,bold)
|
||||||
|
```
|
||||||
|
|
||||||
|
This will highlight lines that start with a call to the `rm` command.
|
||||||
|
|
||||||
|
The regular expressions flavour used is [PCRE][pcresyntax] when the
|
||||||
|
`RE_MATCH_PCRE` option is set and POSIX Extended Regular Expressions (ERE),
|
||||||
|
as implemented by the platform's C library, otherwise. For details on the
|
||||||
|
latter, see [the `zsh/regex` module's documentation][MAN_ZSH_REGEX] and the
|
||||||
|
`regcomp(3)` and `re_format(7)` manual pages on your system.
|
||||||
|
|
||||||
|
For instance, to highlight `sudo` only as a complete word, i.e., `sudo cmd`,
|
||||||
|
but not `sudoedit`, one might use:
|
||||||
|
|
||||||
|
* When the `RE_MATCH_PCRE` is set:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
typeset -A ZSH_HIGHLIGHT_REGEXP
|
||||||
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
|
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
|
||||||
```
|
```
|
||||||
|
|
||||||
This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not
|
* When the `RE_MATCH_PCRE` is unset, on platforms with GNU `libc` (e.g., many GNU/Linux distributions):
|
||||||
"sudoedit"
|
|
||||||
|
```zsh
|
||||||
|
typeset -A ZSH_HIGHLIGHT_REGEXP
|
||||||
|
ZSH_HIGHLIGHT_REGEXP+=('\<sudo\>' fg=123,bold)
|
||||||
|
```
|
||||||
|
|
||||||
|
* When the `RE_MATCH_PCRE` is unset, on BSD-based platforms (e.g., macOS):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
typeset -A ZSH_HIGHLIGHT_REGEXP
|
||||||
|
ZSH_HIGHLIGHT_REGEXP+=('[[:<:]]sudo[[:>:]]' fg=123,bold)
|
||||||
|
```
|
||||||
|
|
||||||
|
Note, however, that PCRE and POSIX ERE have a large common subset:
|
||||||
|
for instance, the regular expressions `[abc]`, `a*`, and `(a|b)` have the same
|
||||||
|
meaning in both flavours.
|
||||||
|
|
||||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
@@ -25,6 +58,8 @@ manual page][zshzle-Character-Highlighting].
|
|||||||
See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~`
|
See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~`
|
||||||
in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions]
|
in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions]
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
[perlretut]: http://perldoc.perl.org/perlretut.html
|
[perlretut]: https://perldoc.perl.org/perlretut
|
||||||
[zshmisc-Conditional-Expressions]: http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html#Conditional-Expressions
|
[zshmisc-Conditional-Expressions]: https://zsh.sourceforge.io/Doc/Release/Conditional-Expressions.html#Conditional-Expressions
|
||||||
|
[MAN_ZSH_REGEX]: https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-zsh_002fregex-Module
|
||||||
|
[pcresyntax]: https://www.pcre.org/original/doc/html/pcresyntax.html
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ The syntax for values is the same as the syntax of "types of highlighting" of
|
|||||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
manual page][zshzle-Character-Highlighting].
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ _zsh_highlight_highlighter_brackets_paint()
|
|||||||
local -A levelpos lastoflevel matching
|
local -A levelpos lastoflevel matching
|
||||||
|
|
||||||
# Find all brackets and remember which one is matching
|
# Find all brackets and remember which one is matching
|
||||||
for (( pos = 1; pos <= buflen; pos++ )) ; do
|
pos=0
|
||||||
char=$BUFFER[pos]
|
for char in ${(s..)BUFFER} ; do
|
||||||
|
(( ++pos ))
|
||||||
case $char in
|
case $char in
|
||||||
["([{"])
|
["([{"])
|
||||||
levelpos[$pos]=$((++level))
|
levelpos[$pos]=$((++level))
|
||||||
|
|||||||
@@ -33,8 +33,10 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
|
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
|
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[global-alias]:=fg=cyan}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[autodirectory]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
||||||
@@ -56,9 +58,10 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[back-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[back-dollar-quoted-argument]:=fg=cyan}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[numeric-fd]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
|
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
|
||||||
|
|
||||||
# Whether the highlighter should be called or not.
|
# Whether the highlighter should be called or not.
|
||||||
@@ -73,7 +76,7 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
integer start=$1 end=$2
|
integer start=$1 end=$2
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
if (( in_alias )); then
|
if (( $#in_alias )); then
|
||||||
[[ $1 == unknown-token ]] && alias_style=unknown-token
|
[[ $1 == unknown-token ]] && alias_style=unknown-token
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@@ -105,13 +108,19 @@ _zsh_highlight_main_calculate_fallback() {
|
|||||||
local -A fallback_of; fallback_of=(
|
local -A fallback_of; fallback_of=(
|
||||||
alias arg0
|
alias arg0
|
||||||
suffix-alias arg0
|
suffix-alias arg0
|
||||||
|
global-alias dollar-double-quoted-argument
|
||||||
builtin arg0
|
builtin arg0
|
||||||
function arg0
|
function arg0
|
||||||
command arg0
|
command arg0
|
||||||
precommand arg0
|
precommand arg0
|
||||||
hashed-command arg0
|
hashed-command arg0
|
||||||
|
autodirectory arg0
|
||||||
arg0_\* arg0
|
arg0_\* arg0
|
||||||
|
|
||||||
|
# TODO: Maybe these? —
|
||||||
|
# named-fd file-descriptor
|
||||||
|
# numeric-fd file-descriptor
|
||||||
|
|
||||||
path_prefix path
|
path_prefix path
|
||||||
# The path separator fallback won't ever be used, due to the optimisation
|
# The path separator fallback won't ever be used, due to the optimisation
|
||||||
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
||||||
@@ -173,7 +182,9 @@ _zsh_highlight_main__type() {
|
|||||||
if (( $+aliases[(e)$1] )); then
|
if (( $+aliases[(e)$1] )); then
|
||||||
may_cache=0
|
may_cache=0
|
||||||
fi
|
fi
|
||||||
if (( $+aliases[(e)$1] )) && (( aliases_allowed )); then
|
if (( ${+galiases[(e)$1]} )) && (( aliases_allowed )); then
|
||||||
|
REPLY='global alias'
|
||||||
|
elif (( $+aliases[(e)$1] )) && (( aliases_allowed )); then
|
||||||
REPLY=alias
|
REPLY=alias
|
||||||
elif [[ $1 == *.* && -n ${1%.*} ]] && (( $+saliases[(e)${1##*.}] )); then
|
elif [[ $1 == *.* && -n ${1%.*} ]] && (( $+saliases[(e)${1##*.}] )); then
|
||||||
REPLY='suffix alias'
|
REPLY='suffix alias'
|
||||||
@@ -262,6 +273,18 @@ _zsh_highlight_main__resolve_alias() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return true iff $1 is a global alias
|
||||||
|
_zsh_highlight_main__is_global_alias() {
|
||||||
|
if zmodload -e zsh/parameter; then
|
||||||
|
(( ${+galiases[$arg]} ))
|
||||||
|
elif [[ $arg == '='* ]]; then
|
||||||
|
# avoid running into «alias -L '=foo'» erroring out with 'bad assignment'
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
alias -L -g -- "$1" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check that the top of $braces_stack has the expected value. If it does, set
|
# Check that the top of $braces_stack has the expected value. If it does, set
|
||||||
# the style according to $2; otherwise, set style=unknown-token.
|
# the style according to $2; otherwise, set style=unknown-token.
|
||||||
#
|
#
|
||||||
@@ -306,9 +329,13 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
# $flags_sans_argument is a set of letters, corresponding to the option letters
|
# $flags_sans_argument is a set of letters, corresponding to the option letters
|
||||||
# that wouldn't be followed by a colon in a getopts specification.
|
# that wouldn't be followed by a colon in a getopts specification.
|
||||||
local flags_sans_argument
|
local flags_sans_argument
|
||||||
# $precommand_options maps precommand name to values of $flags_with_argument and
|
# $flags_solo is a set of letters, corresponding to option letters that, if
|
||||||
# $flags_sans_argument for that precommand, joined by a colon. (The value is NOT
|
# present, mean the precommand will not be acting as a precommand, i.e., will
|
||||||
# a getopt(3) spec, although it resembles one.)
|
# not be followed by a :start: word.
|
||||||
|
local flags_solo
|
||||||
|
# $precommand_options maps precommand name to values of $flags_with_argument,
|
||||||
|
# $flags_sans_argument, and flags_solo for that precommand, joined by a
|
||||||
|
# colon. (The value is NOT a getopt(3) spec, although it resembles one.)
|
||||||
#
|
#
|
||||||
# Currently, setting $flags_sans_argument is only important for commands that
|
# Currently, setting $flags_sans_argument is only important for commands that
|
||||||
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
|
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
|
||||||
@@ -322,30 +349,35 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
'noglob' ''
|
'noglob' ''
|
||||||
# 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands.
|
# 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands.
|
||||||
|
|
||||||
|
# miscellaneous commands
|
||||||
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
||||||
'nice' n: # as of current POSIX spec
|
'nice' n: # as of current POSIX spec
|
||||||
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
||||||
# Argumentless flags that can't be followed by a command: -e -h -K -k -V -v
|
# Not listed: -h, which has two different meanings.
|
||||||
'sudo' Cgprtu:AEHPSbilns # as of sudo 1.8.21p2
|
'sudo' Cgprtu:AEHPSbilns:eKkVv # as of sudo 1.8.21p2
|
||||||
'stdbuf' ioe:
|
'stdbuf' ioe:
|
||||||
'eatmydata' ''
|
'eatmydata' ''
|
||||||
'catchsegv' ''
|
'catchsegv' ''
|
||||||
'nohup' ''
|
'nohup' ''
|
||||||
'setsid' :wc
|
'setsid' :wc
|
||||||
# As of OpenSSH 8.1p1; -k is deliberately left out since it may not be followed by a command
|
'env' u:i
|
||||||
'ssh-agent' aEPt:csDd
|
'ionice' cn:t:pPu # util-linux 2.33.1-0.1
|
||||||
# suckless-tools v44
|
'strace' IbeaosXPpEuOS:ACdfhikqrtTvVxyDc # strace 4.26-0.2
|
||||||
# Argumentless flags that can't be followed by a command: -v
|
'proxychains' f:q # proxychains 4.4.0
|
||||||
'tabbed' gnprtTuU:cdfhs
|
'torsocks' idq:upaP # Torsocks 2.3.0
|
||||||
|
'torify' idq:upaP # Torsocks 2.3.0
|
||||||
# moreutils 0.62-1
|
'ssh-agent' aEPt:csDd:k # As of OpenSSH 8.1p1
|
||||||
'chronic' :ev
|
'tabbed' gnprtTuU:cdfhs:v # suckless-tools v44
|
||||||
'ifne' :n
|
'chronic' :ev # moreutils 0.62-1
|
||||||
|
'ifne' :n # moreutils 0.62-1
|
||||||
|
'grc' :se # grc - a "generic colouriser" (that's their spelling, not mine)
|
||||||
|
'cpulimit' elp:ivz # cpulimit 0.2
|
||||||
|
'ktrace' fgpt:aBCcdiT
|
||||||
)
|
)
|
||||||
# Commands that would need to skip one positional argument:
|
# Commands that would need to skip one positional argument:
|
||||||
# flock
|
# flock
|
||||||
# ssh
|
# ssh
|
||||||
|
# _wanted (skip two)
|
||||||
|
|
||||||
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
||||||
local right_brace_is_recognised_everywhere=false
|
local right_brace_is_recognised_everywhere=false
|
||||||
@@ -359,6 +391,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
|
|
||||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||||
'|' '||' ';' '&' '&&'
|
'|' '||' ';' '&' '&&'
|
||||||
|
$'\n' # ${(z)} returns ';' but we convert it to $'\n'
|
||||||
'|&'
|
'|&'
|
||||||
'&!' '&|'
|
'&!' '&|'
|
||||||
# ### 'case' syntax, but followed by a pattern, not by a command
|
# ### 'case' syntax, but followed by a pattern, not by a command
|
||||||
@@ -402,6 +435,63 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Try to expand $1, if it's possible to do so safely.
|
||||||
|
#
|
||||||
|
# Uses two parameters from the caller: $parameter_name_pattern and $res.
|
||||||
|
#
|
||||||
|
# If expansion was done, set $reply to the expansion and return true.
|
||||||
|
# Otherwise, return false.
|
||||||
|
_zsh_highlight_main_highlighter__try_expand_parameter()
|
||||||
|
{
|
||||||
|
local arg="$1"
|
||||||
|
unset reply
|
||||||
|
{
|
||||||
|
# ### For now, expand just '$foo' or '${foo}', possibly with braces, but with
|
||||||
|
# ### no other features of the parameter expansion syntax. (No ${(x)foo},
|
||||||
|
# ### no ${foo[x]}, no ${foo:-x}.)
|
||||||
|
{
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
|
local parameter_name
|
||||||
|
local -a words
|
||||||
|
if [[ $arg[1] != '$' ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
|
||||||
|
parameter_name=${${arg:2}%?}
|
||||||
|
else
|
||||||
|
parameter_name=${arg:1}
|
||||||
|
fi
|
||||||
|
if [[ $res == none ]] &&
|
||||||
|
[[ ${parameter_name} =~ ^${~parameter_name_pattern}$ ]] &&
|
||||||
|
[[ ${(tP)MATCH} != *special* ]]
|
||||||
|
then
|
||||||
|
# Set $arg and update $res.
|
||||||
|
case ${(tP)MATCH} in
|
||||||
|
(*array*|*assoc*)
|
||||||
|
words=( ${(P)MATCH} )
|
||||||
|
;;
|
||||||
|
("")
|
||||||
|
# not set
|
||||||
|
words=( )
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
# scalar, presumably
|
||||||
|
if [[ $zsyh_user_options[shwordsplit] == on ]]; then
|
||||||
|
words=( ${(P)=MATCH} )
|
||||||
|
else
|
||||||
|
words=( ${(P)MATCH} )
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
reply=( "${words[@]}" )
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# $1 is the offset of $4 from the parent buffer. Added to the returned highlights.
|
# $1 is the offset of $4 from the parent buffer. Added to the returned highlights.
|
||||||
# $2 is the initial braces_stack (for a closing paren).
|
# $2 is the initial braces_stack (for a closing paren).
|
||||||
# $3 is 1 if $4 contains the end of $BUFFER, else 0.
|
# $3 is 1 if $4 contains the end of $BUFFER, else 0.
|
||||||
@@ -413,17 +503,18 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
_zsh_highlight_main_highlighter_highlight_list()
|
_zsh_highlight_main_highlighter_highlight_list()
|
||||||
{
|
{
|
||||||
integer start_pos end_pos=0 buf_offset=$1 has_end=$3
|
integer start_pos end_pos=0 buf_offset=$1 has_end=$3
|
||||||
# alias_style is the style to apply to an alias once in_alias=0
|
# alias_style is the style to apply to an alias once $#in_alias == 0
|
||||||
# Usually 'alias' but set to 'unknown-token' if any word expanded from
|
# Usually 'alias' but set to 'unknown-token' if any word expanded from
|
||||||
# the alias would be highlighted as unknown-token
|
# the alias would be highlighted as unknown-token
|
||||||
# param_style is analogous for parameter expansions
|
# param_style is analogous for parameter expansions
|
||||||
local alias_style param_style arg buf=$4 highlight_glob=true style
|
local alias_style param_style last_arg arg buf=$4 highlight_glob=true saw_assignment=false style
|
||||||
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
||||||
# in_alias is equal to the number of shifts needed until arg=args[1] pops an
|
# in_alias is an array of integers with each element equal to the number
|
||||||
# arg from BUFFER and not added by an alias.
|
# of shifts needed until arg=args[1] pops an arg from the next level up
|
||||||
|
# alias or from BUFFER.
|
||||||
# in_param is analogous for parameter expansions
|
# in_param is analogous for parameter expansions
|
||||||
integer in_alias=0 in_param=0 len=$#buf
|
integer in_param=0 len=$#buf
|
||||||
local -a match mbegin mend list_highlights
|
local -a in_alias match mbegin mend list_highlights
|
||||||
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
|
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
|
||||||
local -A seen_alias
|
local -A seen_alias
|
||||||
# Pattern for parameter names
|
# Pattern for parameter names
|
||||||
@@ -434,7 +525,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# "Q" for square
|
# "Q" for square
|
||||||
# "Y" for curly
|
# "Y" for curly
|
||||||
# "T" for [[ ]]
|
# "T" for [[ ]]
|
||||||
# "S" for $( )
|
# "S" for $( ), =( ), <( ), >( )
|
||||||
# "D" for do/done
|
# "D" for do/done
|
||||||
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
||||||
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
|
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
|
||||||
@@ -452,6 +543,9 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# - :sudo_arg: The argument to a precommand's leading-dash option,
|
# - :sudo_arg: The argument to a precommand's leading-dash option,
|
||||||
# when given as a separate word; i.e., "foo" in "-u foo" (two
|
# when given as a separate word; i.e., "foo" in "-u foo" (two
|
||||||
# words) but not in "-ufoo" (one word).
|
# words) but not in "-ufoo" (one word).
|
||||||
|
# Note: :sudo_opt: and :sudo_arg: are used for any precommand
|
||||||
|
# declared in ${precommand_options}, not just for sudo(8).
|
||||||
|
# The naming is historical.
|
||||||
# - :regular: "Not a command word", and command delimiters are permitted.
|
# - :regular: "Not a command word", and command delimiters are permitted.
|
||||||
# Mainly used to detect premature termination of commands.
|
# Mainly used to detect premature termination of commands.
|
||||||
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
|
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
|
||||||
@@ -480,6 +574,13 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# $in_redirection. The value of $next_word from the iteration that processed
|
# $in_redirection. The value of $next_word from the iteration that processed
|
||||||
# the operator is discarded.
|
# the operator is discarded.
|
||||||
#
|
#
|
||||||
|
# $in_redirection is currently used for:
|
||||||
|
# - comments
|
||||||
|
# - aliases
|
||||||
|
# - redirections
|
||||||
|
# - parameter elision in command position
|
||||||
|
# - 'repeat' loops
|
||||||
|
#
|
||||||
local this_word next_word=':start::start_of_pipeline:'
|
local this_word next_word=':start::start_of_pipeline:'
|
||||||
integer in_redirection
|
integer in_redirection
|
||||||
# Processing buffer
|
# Processing buffer
|
||||||
@@ -490,15 +591,34 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
else
|
else
|
||||||
args=(${(z)buf})
|
args=(${(z)buf})
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Special case: $(<*) isn't globbing.
|
||||||
|
if [[ $braces_stack == 'S' ]] && (( $+args[3] && ! $+args[4] )) && [[ $args[3] == $'\x29' ]] &&
|
||||||
|
[[ $args[1] == *'<'* ]] && _zsh_highlight_main__is_redirection $args[1]; then
|
||||||
|
highlight_glob=false
|
||||||
|
fi
|
||||||
|
|
||||||
while (( $#args )); do
|
while (( $#args )); do
|
||||||
|
last_arg=$arg
|
||||||
arg=$args[1]
|
arg=$args[1]
|
||||||
shift args
|
shift args
|
||||||
if (( in_alias )); then
|
if (( $#in_alias )); then
|
||||||
(( in_alias-- ))
|
(( in_alias[1]-- ))
|
||||||
if (( in_alias == 0 )); then
|
# Remove leading 0 entries
|
||||||
|
in_alias=($in_alias[$in_alias[(i)<1->],-1])
|
||||||
|
if (( $#in_alias == 0 )); then
|
||||||
seen_alias=()
|
seen_alias=()
|
||||||
# start_pos and end_pos are of the alias (previous $arg) here
|
# start_pos and end_pos are of the alias (previous $arg) here
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||||
|
else
|
||||||
|
# We can't unset keys that contain special characters (] \ and some others).
|
||||||
|
# More details: https://www.zsh.org/workers/43269
|
||||||
|
(){
|
||||||
|
local alias_name
|
||||||
|
for alias_name in ${(k)seen_alias[(R)<$#in_alias->]}; do
|
||||||
|
seen_alias=("${(@kv)seen_alias[(I)^$alias_name]}")
|
||||||
|
done
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if (( in_param )); then
|
if (( in_param )); then
|
||||||
@@ -514,7 +634,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
if (( in_redirection == 0 )); then
|
if (( in_redirection == 0 )); then
|
||||||
this_word=$next_word
|
this_word=$next_word
|
||||||
next_word=':regular:'
|
next_word=':regular:'
|
||||||
else
|
elif (( !in_param )); then
|
||||||
# Stall $next_word.
|
# Stall $next_word.
|
||||||
(( --in_redirection ))
|
(( --in_redirection ))
|
||||||
fi
|
fi
|
||||||
@@ -524,6 +644,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# $style how to highlight $arg
|
# $style how to highlight $arg
|
||||||
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
|
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
|
||||||
# $highlight_glob boolean flag for "'noglob' is in effect"
|
# $highlight_glob boolean flag for "'noglob' is in effect"
|
||||||
|
# $saw_assignment boolean flag for "was preceded by an assignment"
|
||||||
#
|
#
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
if [[ $this_word == *':start:'* ]]; then
|
if [[ $this_word == *':start:'* ]]; then
|
||||||
@@ -533,14 +654,19 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( in_alias == 0 && in_param == 0 )); then
|
if (( $#in_alias == 0 && in_param == 0 )); then
|
||||||
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
|
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
|
||||||
[[ "$proc_buf" = (#b)(#s)(([ $'\t']|\\$'\n')#)* ]]
|
[[ "$proc_buf" = (#b)(#s)(''([ $'\t']|[\\]$'\n')#)(?|)* ]]
|
||||||
# The first, outer parenthesis
|
# The first, outer parenthesis
|
||||||
integer offset="${#match[1]}"
|
integer offset="${#match[1]}"
|
||||||
(( start_pos = end_pos + offset ))
|
(( start_pos = end_pos + offset ))
|
||||||
(( end_pos = start_pos + $#arg ))
|
(( end_pos = start_pos + $#arg ))
|
||||||
|
|
||||||
|
# The zsh lexer considers ';' and newline to be the same token, so
|
||||||
|
# ${(z)} converts all newlines to semicolons. Convert them back here to
|
||||||
|
# make later processing simpler.
|
||||||
|
[[ $arg == ';' && ${match[3]} == $'\n' ]] && arg=$'\n'
|
||||||
|
|
||||||
# Compute the new $proc_buf. We advance it
|
# Compute the new $proc_buf. We advance it
|
||||||
# (chop off characters from the beginning)
|
# (chop off characters from the beginning)
|
||||||
# beyond what end_pos points to, by skipping
|
# beyond what end_pos points to, by skipping
|
||||||
@@ -584,11 +710,10 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
if [[ $res == "alias" ]]; then
|
if [[ $res == "alias" ]]; then
|
||||||
# Mark insane aliases as unknown-token (cf. #263).
|
# Mark insane aliases as unknown-token (cf. #263).
|
||||||
if [[ $arg == ?*=* ]]; then
|
if [[ $arg == ?*=* ]]; then
|
||||||
(( in_alias == 0 )) && in_alias=1
|
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
seen_alias[$arg]=1
|
seen_alias[$arg]=$#in_alias
|
||||||
_zsh_highlight_main__resolve_alias $arg
|
_zsh_highlight_main__resolve_alias $arg
|
||||||
local -a alias_args
|
local -a alias_args
|
||||||
# Elision is desired in case alias x=''
|
# Elision is desired in case alias x=''
|
||||||
@@ -598,15 +723,15 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
alias_args=(${(z)REPLY})
|
alias_args=(${(z)REPLY})
|
||||||
fi
|
fi
|
||||||
args=( $alias_args $args )
|
args=( $alias_args $args )
|
||||||
if (( in_alias == 0 )); then
|
if (( $#in_alias == 0 )); then
|
||||||
alias_style=alias
|
alias_style=alias
|
||||||
# Add one because we will in_alias-- on the next loop iteration so
|
|
||||||
# this iteration should be considered in in_alias as well
|
|
||||||
(( in_alias += $#alias_args + 1 ))
|
|
||||||
else
|
else
|
||||||
# This arg is already included in the count, so no need to + 1.
|
# Transfer the count of this arg to the new element about to be appended.
|
||||||
(( in_alias += $#alias_args ))
|
(( in_alias[1]-- ))
|
||||||
fi
|
fi
|
||||||
|
# Add one because we will in_alias[1]-- on the next loop iteration so
|
||||||
|
# this iteration should be considered in in_alias as well
|
||||||
|
in_alias=( $(($#alias_args + 1)) $in_alias )
|
||||||
(( in_redirection++ )) # Stall this arg
|
(( in_redirection++ )) # Stall this arg
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
@@ -619,7 +744,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# Analyse the current word.
|
# Analyse the current word.
|
||||||
if _zsh_highlight_main__is_redirection $arg ; then
|
if _zsh_highlight_main__is_redirection $arg ; then
|
||||||
if (( in_redirection == 1 )); then
|
if (( in_redirection == 1 )); then
|
||||||
# The condition excludes the case that BUFFER='{foo}>&2' and we're on the '>&'.
|
# Two consecutive redirection operators is an error.
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
||||||
else
|
else
|
||||||
in_redirection=2
|
in_redirection=2
|
||||||
@@ -634,38 +759,19 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Expand parameters.
|
# Expand parameters.
|
||||||
#
|
if (( ! in_param )) && _zsh_highlight_main_highlighter__try_expand_parameter "$arg"; then
|
||||||
# ### For now, expand just '$foo' or '${foo}', possibly with braces, but with
|
|
||||||
# ### no other features of the parameter expansion syntax. (No ${(x)foo},
|
|
||||||
# ### no ${foo[x]}, no ${foo:-x}.)
|
|
||||||
() {
|
|
||||||
# That's not entirely correct --- if the parameter's value happens to be a reserved
|
# That's not entirely correct --- if the parameter's value happens to be a reserved
|
||||||
# word, the parameter expansion will be highlighted as a reserved word --- but that
|
# word, the parameter expansion will be highlighted as a reserved word --- but that
|
||||||
# incorrectness is outweighed by the usability improvement of permitting the use of
|
# incorrectness is outweighed by the usability improvement of permitting the use of
|
||||||
# parameters that refer to commands, functions, and builtins.
|
# parameters that refer to commands, functions, and builtins.
|
||||||
local -a match mbegin mend
|
() {
|
||||||
local MATCH; integer MBEGIN MEND
|
local -a words; words=( "${reply[@]}" )
|
||||||
local parameter_name
|
if (( $#words == 0 )) && (( ! in_redirection )); then
|
||||||
local -a words
|
# Parameter elision is happening
|
||||||
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
|
(( ++in_redirection ))
|
||||||
parameter_name=${${arg:2}%?}
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos comment
|
||||||
elif [[ $arg[1] == '$' ]]; then
|
continue
|
||||||
parameter_name=${arg:1}
|
else
|
||||||
fi
|
|
||||||
if [[ $res == none ]] && zmodload -e zsh/parameter &&
|
|
||||||
[[ ${parameter_name} =~ ^${~parameter_name_pattern}$ ]] &&
|
|
||||||
(( ${+parameters[(e)${MATCH}]} )) && [[ ${parameters[(e)$MATCH]} != *special* ]]
|
|
||||||
then
|
|
||||||
# Set $arg.
|
|
||||||
case ${(tP)MATCH} in
|
|
||||||
(*array*|*assoc*)
|
|
||||||
words=( ${(P)MATCH} )
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
# scalar, presumably
|
|
||||||
words=( ${(P)MATCH} )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
(( in_param = 1 + $#words ))
|
(( in_param = 1 + $#words ))
|
||||||
args=( $words $args )
|
args=( $words $args )
|
||||||
arg=$args[1]
|
arg=$args[1]
|
||||||
@@ -673,19 +779,30 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
res=$REPLY
|
res=$REPLY
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse the sudo command line
|
# Parse the sudo command line
|
||||||
if (( ! in_redirection )); then
|
if (( ! in_redirection )); then
|
||||||
if [[ $this_word == *':sudo_opt:'* ]]; then
|
if [[ $this_word == *':sudo_opt:'* ]]; then
|
||||||
if [[ -n $flags_with_argument ]] &&
|
if [[ -n $flags_with_argument ]] &&
|
||||||
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] ||
|
{
|
||||||
[[ $arg == '-'[$flags_with_argument] ]] }; then
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]]
|
||||||
|
else [[ $arg == '-'[$flags_with_argument] ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
# Flag that requires an argument
|
# Flag that requires an argument
|
||||||
this_word=${this_word//:start:/}
|
this_word=${this_word//:start:/}
|
||||||
next_word=':sudo_arg:'
|
next_word=':sudo_arg:'
|
||||||
elif [[ -n $flags_with_argument ]] &&
|
elif [[ -n $flags_with_argument ]] &&
|
||||||
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] ||
|
{
|
||||||
[[ $arg == '-'[$flags_with_argument]* ]] }; then
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]]
|
||||||
|
else [[ $arg == '-'[$flags_with_argument]* ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
# Argument attached in the same word
|
# Argument attached in the same word
|
||||||
this_word=${this_word//:start:/}
|
this_word=${this_word//:start:/}
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
@@ -696,6 +813,17 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
this_word=':sudo_opt:'
|
this_word=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
|
elif [[ -n $flags_solo ]] &&
|
||||||
|
{
|
||||||
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_solo]* ]]
|
||||||
|
else [[ $arg == '-'[$flags_solo]* ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
|
# Solo flags
|
||||||
|
this_word=':sudo_opt:'
|
||||||
|
next_word=':regular:' # no :start:, nor :sudo_opt: since we don't know whether the solo flag takes an argument or not
|
||||||
elif [[ $arg == '-'* ]]; then
|
elif [[ $arg == '-'* ]]; then
|
||||||
# Unknown flag. We don't know whether it takes an argument or not,
|
# Unknown flag. We don't know whether it takes an argument or not,
|
||||||
# so modify $next_word as we do for flags that require no argument.
|
# so modify $next_word as we do for flags that require no argument.
|
||||||
@@ -720,42 +848,91 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# The Great Fork: is this a command word? Is this a non-command word?
|
# The Great Fork: is this a command word? Is this a non-command word?
|
||||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] &&
|
||||||
|
[[ $braces_stack != *T* || $arg != ('||'|'&&') ]]; then
|
||||||
|
|
||||||
|
# First, determine the style of the command separator itself.
|
||||||
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
|
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
|
||||||
# Missing closing square bracket(s)
|
# Missing closing square bracket(s)
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
|
elif $in_array_assignment; then
|
||||||
|
case $arg in
|
||||||
|
# Literal newlines are just fine.
|
||||||
|
($'\n') style=commandseparator;;
|
||||||
|
# Semicolons are parsed the same way as literal newlines. Nevertheless,
|
||||||
|
# highlight them as errors since they're probably unintended. Compare
|
||||||
|
# issue #691.
|
||||||
|
(';') style=unknown-token;;
|
||||||
|
# Other command separators aren't allowed.
|
||||||
|
(*) style=unknown-token;;
|
||||||
|
esac
|
||||||
elif [[ $this_word == *':regular:'* ]]; then
|
elif [[ $this_word == *':regular:'* ]]; then
|
||||||
# This highlights empty commands (semicolon follows nothing) as an error.
|
style=commandseparator
|
||||||
# Zsh accepts them, though.
|
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
|
||||||
|
style=commandseparator
|
||||||
|
elif [[ $this_word == *':start:'* ]] && [[ $arg == ';' ]] && (( $#in_alias )); then
|
||||||
style=commandseparator
|
style=commandseparator
|
||||||
else
|
else
|
||||||
|
# Empty commands (semicolon follows nothing) are valid syntax.
|
||||||
|
# However, in interactive use they are likely to be erroneous;
|
||||||
|
# therefore, we highlight them as errors.
|
||||||
|
#
|
||||||
|
# Alias definitions are exempted from this check to allow multiline aliases
|
||||||
|
# with explicit (redundant) semicolons: «alias foo=$'bar;\nbaz'» (issue #677).
|
||||||
|
#
|
||||||
|
# See also #691 about possibly changing the style used here.
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
fi
|
fi
|
||||||
if [[ $arg == ';' ]] && $in_array_assignment; then
|
|
||||||
|
# Second, determine the style of next_word.
|
||||||
|
if [[ $arg == $'\n' ]] && $in_array_assignment; then
|
||||||
# literal newline inside an array assignment
|
# literal newline inside an array assignment
|
||||||
next_word=':regular:'
|
next_word=':regular:'
|
||||||
|
elif [[ $arg == ';' ]] && $in_array_assignment; then
|
||||||
|
# literal semicolon inside an array assignment
|
||||||
|
next_word=':regular:'
|
||||||
else
|
else
|
||||||
next_word=':start:'
|
next_word=':start:'
|
||||||
highlight_glob=true
|
highlight_glob=true
|
||||||
|
saw_assignment=false
|
||||||
|
(){
|
||||||
|
local alias_name
|
||||||
|
for alias_name in ${(k)seen_alias[(R)<$#in_alias->]}; do
|
||||||
|
# We can't unset keys that contain special characters (] \ and some others).
|
||||||
|
# More details: https://www.zsh.org/workers/43269
|
||||||
|
seen_alias=("${(@kv)seen_alias[(I)^$alias_name]}")
|
||||||
|
done
|
||||||
|
}
|
||||||
if [[ $arg != '|' && $arg != '|&' ]]; then
|
if [[ $arg != '|' && $arg != '|&' ]]; then
|
||||||
next_word+=':start_of_pipeline:'
|
next_word+=':start_of_pipeline:'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
|
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
|
||||||
# try-always construct
|
# try-always construct
|
||||||
style=reserved-word # de facto a reserved word, although not de jure
|
style=reserved-word # de facto a reserved word, although not de jure
|
||||||
next_word=':start:' # only left brace is allowed, apparently
|
highlight_glob=true
|
||||||
|
saw_assignment=false
|
||||||
|
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
|
||||||
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
|
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
|
||||||
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
|
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
|
||||||
style=precommand
|
style=precommand
|
||||||
flags_with_argument=${precommand_options[$arg]%:*}
|
() {
|
||||||
flags_sans_argument=${precommand_options[$arg]#*:}
|
set -- "${(@s.:.)precommand_options[$arg]}"
|
||||||
|
flags_with_argument=$1
|
||||||
|
flags_sans_argument=$2
|
||||||
|
flags_solo=$3
|
||||||
|
}
|
||||||
next_word=${next_word//:regular:/}
|
next_word=${next_word//:regular:/}
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
|
if [[ $arg == 'exec' || $arg == 'env' ]]; then
|
||||||
|
# To allow "exec 2>&1;" and "env | grep" where there's no command word
|
||||||
|
next_word+=':regular:'
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
case $res in
|
case $res in
|
||||||
reserved) # reserved word
|
(reserved) # reserved word
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
# Match braces and handle special cases.
|
# Match braces and handle special cases.
|
||||||
case $arg in
|
case $arg in
|
||||||
@@ -831,20 +1008,30 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
if $saw_assignment && [[ $style != unknown-token ]]; then
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
'suffix alias') style=suffix-alias;;
|
('suffix alias')
|
||||||
alias) :;;
|
style=suffix-alias
|
||||||
builtin) style=builtin
|
;;
|
||||||
|
('global alias')
|
||||||
|
style=global-alias
|
||||||
|
;;
|
||||||
|
(alias) :;;
|
||||||
|
(builtin) style=builtin
|
||||||
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
|
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
|
||||||
;;
|
;;
|
||||||
function) style=function;;
|
(function) style=function;;
|
||||||
command) style=command;;
|
(command) style=command;;
|
||||||
hashed) style=hashed-command;;
|
(hashed) style=hashed-command;;
|
||||||
none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
|
(none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
|
||||||
local i=$(( arg[(i)=] + 1 ))
|
local i=$(( arg[(i)=] + 1 ))
|
||||||
|
saw_assignment=true
|
||||||
if [[ $arg[i] == '(' ]]; then
|
if [[ $arg[i] == '(' ]]; then
|
||||||
in_array_assignment=true
|
in_array_assignment=true
|
||||||
|
_zsh_highlight_main_add_region_highlight start_pos+i-1 start_pos+i reserved-word
|
||||||
else
|
else
|
||||||
# assignment to a scalar parameter.
|
# assignment to a scalar parameter.
|
||||||
# (For array assignments, the command doesn't start until the ")" token.)
|
# (For array assignments, the command doesn't start until the ")" token.)
|
||||||
@@ -868,6 +1055,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
[[ $arg[0,1] == $histchars[2,2] ]]; then
|
[[ $arg[0,1] == $histchars[2,2] ]]; then
|
||||||
style=history-expansion
|
style=history-expansion
|
||||||
elif (( ! in_param )) &&
|
elif (( ! in_param )) &&
|
||||||
|
! $saw_assignment &&
|
||||||
[[ $arg[1,2] == '((' ]]; then
|
[[ $arg[1,2] == '((' ]]; then
|
||||||
# Arithmetic evaluation.
|
# Arithmetic evaluation.
|
||||||
#
|
#
|
||||||
@@ -888,6 +1076,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# anonymous function
|
# anonymous function
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
elif (( ! in_param )) &&
|
elif (( ! in_param )) &&
|
||||||
|
! $saw_assignment &&
|
||||||
[[ $arg == $'\x28' ]]; then
|
[[ $arg == $'\x28' ]]; then
|
||||||
# subshell
|
# subshell
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
@@ -902,14 +1091,14 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
_zsh_highlight_main__stack_pop 'R' reserved-word
|
_zsh_highlight_main__stack_pop 'R' reserved-word
|
||||||
else
|
else
|
||||||
if _zsh_highlight_main_highlighter_check_path $arg; then
|
if _zsh_highlight_main_highlighter_check_path $arg 1; then
|
||||||
style=$REPLY
|
style=$REPLY
|
||||||
else
|
else
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
|
(*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -917,13 +1106,18 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
|
||||||
next_word=':start::start_of_pipeline:'
|
next_word=':start::start_of_pipeline:'
|
||||||
fi
|
fi
|
||||||
|
elif _zsh_highlight_main__is_global_alias "$arg"; then # $arg is a global alias that isn't in command position
|
||||||
|
style=global-alias
|
||||||
else # $arg is a non-command word
|
else # $arg is a non-command word
|
||||||
case $arg in
|
case $arg in
|
||||||
$'\x29') # subshell or end of array assignment
|
($'\x29')
|
||||||
|
# subshell or end of array assignment
|
||||||
if $in_array_assignment; then
|
if $in_array_assignment; then
|
||||||
style=assign
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos reserved-word
|
||||||
in_array_assignment=false
|
in_array_assignment=false
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
|
continue
|
||||||
elif (( in_redirection )); then
|
elif (( in_redirection )); then
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
else
|
else
|
||||||
@@ -933,8 +1127,10 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
_zsh_highlight_main__stack_pop 'R' reserved-word
|
_zsh_highlight_main__stack_pop 'R' reserved-word
|
||||||
fi;;
|
fi
|
||||||
$'\x28\x29') # possibly a function definition
|
;;
|
||||||
|
($'\x28\x29')
|
||||||
|
# possibly a function definition
|
||||||
if (( in_redirection )) || $in_array_assignment; then
|
if (( in_redirection )) || $in_array_assignment; then
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
else
|
else
|
||||||
@@ -945,7 +1141,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
style=reserved-word
|
style=reserved-word
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) if false; then
|
(*) if false; then
|
||||||
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
|
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
|
||||||
# Parsing rule: {
|
# Parsing rule: {
|
||||||
#
|
#
|
||||||
@@ -974,7 +1170,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
done
|
done
|
||||||
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
(( $#in_alias )) && in_alias=() _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||||
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
|
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
|
||||||
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
|
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
|
||||||
REPLY=$(( end_pos + ${#match[1]} - 1 ))
|
REPLY=$(( end_pos + ${#match[1]} - 1 ))
|
||||||
@@ -1006,12 +1202,32 @@ _zsh_highlight_main_highlighter_highlight_path_separators()
|
|||||||
# Check if $1 is a path.
|
# Check if $1 is a path.
|
||||||
# If yes, return 0 and in $REPLY the style to use.
|
# If yes, return 0 and in $REPLY the style to use.
|
||||||
# Else, return non-zero (and the contents of $REPLY is undefined).
|
# Else, return non-zero (and the contents of $REPLY is undefined).
|
||||||
|
#
|
||||||
|
# $2 should be non-zero iff we're in command position.
|
||||||
_zsh_highlight_main_highlighter_check_path()
|
_zsh_highlight_main_highlighter_check_path()
|
||||||
{
|
{
|
||||||
_zsh_highlight_main_highlighter_expand_path "$1"
|
_zsh_highlight_main_highlighter_expand_path "$1"
|
||||||
local expanded_path="$REPLY" tmp_path
|
local expanded_path="$REPLY" tmp_path
|
||||||
|
integer in_command_position=$2
|
||||||
|
|
||||||
|
if [[ $zsyh_user_options[autocd] == on ]]; then
|
||||||
|
integer autocd=1
|
||||||
|
else
|
||||||
|
integer autocd=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( in_command_position )); then
|
||||||
|
# ### Currently, this value is never returned: either it's overwritten
|
||||||
|
# ### below, or the return code is non-zero
|
||||||
|
REPLY=arg0
|
||||||
|
else
|
||||||
REPLY=path
|
REPLY=path
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${1[1]} == '=' && $1 == ??* && ${1[2]} != $'\x28' && $zsyh_user_options[equals] == 'on' && $expanded_path[1] != '/' ]]; then
|
||||||
|
REPLY=unknown-token # will error out if executed
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -z $expanded_path ]] && return 1
|
[[ -z $expanded_path ]] && return 1
|
||||||
|
|
||||||
@@ -1028,24 +1244,56 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
tmp_path=$tmp_path:h
|
tmp_path=$tmp_path:h
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -L $expanded_path ]] && return 0
|
if (( in_command_position )); then
|
||||||
[[ -e $expanded_path ]] && return 0
|
if [[ -x $expanded_path ]]; then
|
||||||
|
if (( autocd )); then
|
||||||
|
if [[ -d $expanded_path ]]; then
|
||||||
|
REPLY=autodirectory
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
elif [[ ! -d $expanded_path ]]; then
|
||||||
|
# ### This seems unreachable for the current callers
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -L $expanded_path || -e $expanded_path ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Search the path in CDPATH
|
# Search the path in CDPATH
|
||||||
|
if [[ $expanded_path != /* ]] && (( autocd || ! in_command_position )); then
|
||||||
|
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
|
||||||
local cdpath_dir
|
local cdpath_dir
|
||||||
for cdpath_dir in $cdpath ; do
|
for cdpath_dir in $cdpath ; do
|
||||||
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
|
if [[ -d "$cdpath_dir/$expanded_path" && -x "$cdpath_dir/$expanded_path" ]]; then
|
||||||
|
if (( in_command_position && autocd )); then
|
||||||
|
REPLY=autodirectory
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# If dirname($1) doesn't exist, neither does $1.
|
# If dirname($1) doesn't exist, neither does $1.
|
||||||
[[ ! -d ${expanded_path:h} ]] && return 1
|
[[ ! -d ${expanded_path:h} ]] && return 1
|
||||||
|
|
||||||
# If this word ends the buffer, check if it's the prefix of a valid path.
|
# If this word ends the buffer, check if it's the prefix of a valid path.
|
||||||
if (( has_end && (len == end_pos) )) &&
|
if (( has_end && (len == end_pos) )) &&
|
||||||
|
(( ! $#in_alias )) &&
|
||||||
[[ $WIDGET != zle-line-finish ]]; then
|
[[ $WIDGET != zle-line-finish ]]; then
|
||||||
|
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
|
||||||
local -a tmp
|
local -a tmp
|
||||||
|
if (( in_command_position )); then
|
||||||
|
# We include directories even when autocd is enabled, because those
|
||||||
|
# directories might contain executable files: e.g., BUFFER="/bi" en route
|
||||||
|
# to typing "/bin/sh".
|
||||||
|
tmp=( ${expanded_path}*(N-*,N-/) )
|
||||||
|
else
|
||||||
tmp=( ${expanded_path}*(N) )
|
tmp=( ${expanded_path}*(N) )
|
||||||
(( $#tmp > 0 )) && REPLY=path_prefix && return 0
|
fi
|
||||||
|
(( ${+tmp[1]} )) && REPLY=path_prefix && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# It's not a path.
|
# It's not a path.
|
||||||
@@ -1055,6 +1303,8 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
# Highlight an argument and possibly special chars in quotes starting at $1 in $arg
|
# Highlight an argument and possibly special chars in quotes starting at $1 in $arg
|
||||||
# This command will at least highlight $1 to end_pos with the default style
|
# This command will at least highlight $1 to end_pos with the default style
|
||||||
# If $2 is set to 0, the argument cannot be highlighted as an option.
|
# If $2 is set to 0, the argument cannot be highlighted as an option.
|
||||||
|
#
|
||||||
|
# This function currently assumes it's never called for the command word.
|
||||||
_zsh_highlight_main_highlighter_highlight_argument()
|
_zsh_highlight_main_highlighter_highlight_argument()
|
||||||
{
|
{
|
||||||
local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
|
local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
|
||||||
@@ -1096,8 +1346,12 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for (( ; i <= $#arg ; i += 1 )); do
|
# This loop is a hot path. Keep it fast!
|
||||||
|
(( --i ))
|
||||||
|
while (( ++i <= $#arg )); do
|
||||||
|
i=${arg[(ib.i.)[\\\'\"\`\$\<\>\*\?]]}
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
|
"") break;;
|
||||||
"\\") (( i += 1 )); continue;;
|
"\\") (( i += 1 )); continue;;
|
||||||
"'")
|
"'")
|
||||||
_zsh_highlight_main_highlighter_highlight_single_quote $i
|
_zsh_highlight_main_highlighter_highlight_single_quote $i
|
||||||
@@ -1124,6 +1378,12 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
highlights+=($reply)
|
highlights+=($reply)
|
||||||
continue
|
continue
|
||||||
elif [[ $arg[i+1] == $'\x28' ]]; then
|
elif [[ $arg[i+1] == $'\x28' ]]; then
|
||||||
|
if [[ $arg[i+2] == $'\x28' ]] && _zsh_highlight_main_highlighter_highlight_arithmetic $i; then
|
||||||
|
# Arithmetic expansion
|
||||||
|
(( i = REPLY ))
|
||||||
|
highlights+=($reply)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
start=$i
|
start=$i
|
||||||
(( i += 2 ))
|
(( i += 2 ))
|
||||||
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
||||||
@@ -1139,7 +1399,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
while [[ $arg[i+1] == [\^=~#+] ]]; do
|
while [[ $arg[i+1] == [=~#+'^'] ]]; do
|
||||||
(( i += 1 ))
|
(( i += 1 ))
|
||||||
done
|
done
|
||||||
if [[ $arg[i+1] == [*@#?$!-] ]]; then
|
if [[ $arg[i+1] == [*@#?$!-] ]]; then
|
||||||
@@ -1164,7 +1424,9 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
fi
|
fi
|
||||||
;|
|
;|
|
||||||
*)
|
*)
|
||||||
if $highlight_glob && [[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then
|
if $highlight_glob &&
|
||||||
|
[[ $zsyh_user_options[multios] == on || $in_redirection -eq 0 ]] &&
|
||||||
|
[[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then
|
||||||
highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing)
|
highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing)
|
||||||
(( i += $#MATCH - 1 ))
|
(( i += $#MATCH - 1 ))
|
||||||
path_eligible=0
|
path_eligible=0
|
||||||
@@ -1175,11 +1437,20 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,-1]; then
|
if (( path_eligible )); then
|
||||||
|
if (( in_redirection )) && [[ $last_arg == *['<>']['&'] && $arg[$1,-1] == (<0->|p|-) ]]; then
|
||||||
|
if [[ $arg[$1,-1] == (p|-) ]]; then
|
||||||
|
base_style=redirection
|
||||||
|
else
|
||||||
|
base_style=numeric-fd
|
||||||
|
fi
|
||||||
|
# This function is currently never called for the command word, so $2 is hard-coded as 0.
|
||||||
|
elif _zsh_highlight_main_highlighter_check_path $arg[$1,-1] 0; then
|
||||||
base_style=$REPLY
|
base_style=$REPLY
|
||||||
_zsh_highlight_main_highlighter_highlight_path_separators $base_style
|
_zsh_highlight_main_highlighter_highlight_path_separators $base_style
|
||||||
highlights+=($reply)
|
highlights+=($reply)
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
highlights=($(( start_pos + $1 - 1 )) $end_pos $base_style $highlights)
|
highlights=($(( start_pos + $1 - 1 )) $end_pos $base_style $highlights)
|
||||||
_zsh_highlight_main_add_many_region_highlights $highlights
|
_zsh_highlight_main_add_many_region_highlights $highlights
|
||||||
@@ -1231,14 +1502,14 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
|||||||
(( j = i + start_pos - 1 ))
|
(( j = i + start_pos - 1 ))
|
||||||
(( k = j + 1 ))
|
(( k = j + 1 ))
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
'"') break;;
|
('"') break;;
|
||||||
'`') saved_reply=($reply)
|
('`') saved_reply=($reply)
|
||||||
_zsh_highlight_main_highlighter_highlight_backtick $i
|
_zsh_highlight_main_highlighter_highlight_backtick $i
|
||||||
(( i = REPLY ))
|
(( i = REPLY ))
|
||||||
reply=($saved_reply $reply)
|
reply=($saved_reply $reply)
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
'$' ) style=dollar-double-quoted-argument
|
('$') style=dollar-double-quoted-argument
|
||||||
# Look for an alphanumeric parameter name.
|
# Look for an alphanumeric parameter name.
|
||||||
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
|
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
|
||||||
(( k += $#MATCH )) # highlight the parameter name
|
(( k += $#MATCH )) # highlight the parameter name
|
||||||
@@ -1255,9 +1526,16 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
|||||||
(( k += 1 )) # highlight both dollar signs
|
(( k += 1 )) # highlight both dollar signs
|
||||||
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
||||||
elif [[ $arg[i+1] == $'\x28' ]]; then
|
elif [[ $arg[i+1] == $'\x28' ]]; then
|
||||||
|
saved_reply=($reply)
|
||||||
|
if [[ $arg[i+2] == $'\x28' ]] && _zsh_highlight_main_highlighter_highlight_arithmetic $i; then
|
||||||
|
# Arithmetic expansion
|
||||||
|
(( i = REPLY ))
|
||||||
|
reply=($saved_reply $reply)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
breaks+=( $last_break $(( start_pos + i - 1 )) )
|
breaks+=( $last_break $(( start_pos + i - 1 )) )
|
||||||
(( i += 2 ))
|
(( i += 2 ))
|
||||||
saved_reply=($reply)
|
|
||||||
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
||||||
ret=$?
|
ret=$?
|
||||||
(( i += REPLY ))
|
(( i += REPLY ))
|
||||||
@@ -1438,6 +1716,96 @@ _zsh_highlight_main_highlighter_highlight_backtick()
|
|||||||
REPLY=$i
|
REPLY=$i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Highlight special chars inside arithmetic expansions
|
||||||
|
_zsh_highlight_main_highlighter_highlight_arithmetic()
|
||||||
|
{
|
||||||
|
local -a saved_reply
|
||||||
|
local style
|
||||||
|
integer i j k paren_depth ret
|
||||||
|
reply=()
|
||||||
|
|
||||||
|
for (( i = $1 + 3 ; i <= end_pos - start_pos ; i += 1 )) ; do
|
||||||
|
(( j = i + start_pos - 1 ))
|
||||||
|
(( k = j + 1 ))
|
||||||
|
case "$arg[$i]" in
|
||||||
|
[\'\"\\@{}])
|
||||||
|
style=unknown-token
|
||||||
|
;;
|
||||||
|
'(')
|
||||||
|
(( paren_depth++ ))
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
')')
|
||||||
|
if (( paren_depth )); then
|
||||||
|
(( paren_depth-- ))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
[[ $arg[i+1] == ')' ]] && { (( i++ )); break; }
|
||||||
|
# Special case ) at the end of the buffer to avoid flashing command substitution for a character
|
||||||
|
(( has_end && (len == k) )) && break
|
||||||
|
# This is a single paren and there are no open parens, so this isn't an arithmetic expansion
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
'`')
|
||||||
|
saved_reply=($reply)
|
||||||
|
_zsh_highlight_main_highlighter_highlight_backtick $i
|
||||||
|
(( i = REPLY ))
|
||||||
|
reply=($saved_reply $reply)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
'$' )
|
||||||
|
if [[ $arg[i+1] == $'\x28' ]]; then
|
||||||
|
saved_reply=($reply)
|
||||||
|
if [[ $arg[i+2] == $'\x28' ]] && _zsh_highlight_main_highlighter_highlight_arithmetic $i; then
|
||||||
|
# Arithmetic expansion
|
||||||
|
(( i = REPLY ))
|
||||||
|
reply=($saved_reply $reply)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
(( i += 2 ))
|
||||||
|
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
|
||||||
|
ret=$?
|
||||||
|
(( i += REPLY ))
|
||||||
|
reply=(
|
||||||
|
$saved_reply
|
||||||
|
$j $(( start_pos + i )) command-substitution-quoted
|
||||||
|
$j $(( j + 2 )) command-substitution-delimiter-quoted
|
||||||
|
$reply
|
||||||
|
)
|
||||||
|
if (( ret == 0 )); then
|
||||||
|
reply+=($(( start_pos + i - 1 )) $(( start_pos + i )) command-substitution-delimiter)
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
($histchars[1]) # ! - may be a history expansion
|
||||||
|
if [[ $arg[i+1] != ('='|$'\x28'|$'\x7b'|[[:blank:]]) ]]; then
|
||||||
|
style=history-expansion
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
reply+=($j $k $style)
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $arg[i] != ')' ]]; then
|
||||||
|
# If unclosed, i points past the end
|
||||||
|
(( i-- ))
|
||||||
|
fi
|
||||||
|
style=arithmetic-expansion
|
||||||
|
reply=($(( start_pos + $1 - 1)) $(( start_pos + i )) arithmetic-expansion $reply)
|
||||||
|
REPLY=$i
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Called with a single positional argument.
|
# Called with a single positional argument.
|
||||||
# Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value.
|
# Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value.
|
||||||
#
|
#
|
||||||
@@ -1457,6 +1825,13 @@ _zsh_highlight_main_highlighter_expand_path()
|
|||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
_zsh_highlight_main__precmd_hook() {
|
_zsh_highlight_main__precmd_hook() {
|
||||||
|
# Unset the WARN_NESTED_VAR option, taking care not to error if the option
|
||||||
|
# doesn't exist (zsh older than zsh-5.3.1-test-2).
|
||||||
|
setopt localoptions
|
||||||
|
if eval '[[ -o warnnestedvar ]]' 2>/dev/null; then
|
||||||
|
unsetopt warnnestedvar
|
||||||
|
fi
|
||||||
|
|
||||||
_zsh_highlight_main__command_type_cache=()
|
_zsh_highlight_main__command_type_cache=()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,5 +31,5 @@
|
|||||||
BUFFER=$'/'
|
BUFFER=$'/'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 path' # /
|
'1 1 path_prefix' # /
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt autocd
|
||||||
|
BUFFER=$'/'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 autodirectory' # /
|
||||||
|
)
|
||||||
@@ -28,8 +28,10 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BUFFER=$'/bin'
|
BUFFER=$'/bin; /bin'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 4 path' # /bin
|
'1 4 unknown-token' # /bin (in middle)
|
||||||
|
'5 5 commandseparator' # ;
|
||||||
|
'7 10 path_prefix' # /bin (at end)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt autocd
|
||||||
|
BUFFER=$'/bin; /bin'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 autodirectory' # /bin (in middle)
|
||||||
|
'5 5 commandseparator' # ;
|
||||||
|
'7 10 autodirectory' # /bin (at end)
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/alias-brackets.zsh
Normal file
41
highlighters/main/test-data/alias-brackets.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2021 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Have to use cat here as it must be a command that exists.
|
||||||
|
# Otherwise, the test would fail with the first token being recognized
|
||||||
|
# as an "unknown-token".
|
||||||
|
alias ]=cat
|
||||||
|
|
||||||
|
BUFFER='] /'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # ]
|
||||||
|
'3 3 path' # /
|
||||||
|
)
|
||||||
@@ -27,11 +27,11 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# see alias-comment2.zsh
|
# see alias-comment2.zsh and comment-followed.zsh
|
||||||
setopt interactivecomments
|
setopt interactivecomments
|
||||||
alias x=$'# foo\npwd'
|
alias x=$'# foo\npwd'
|
||||||
BUFFER='x'
|
BUFFER='x'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 alias "issue #616"' # x
|
'1 1 alias' # x
|
||||||
)
|
)
|
||||||
|
|||||||
43
highlighters/main/test-data/alias-in-cmdsubst.zsh
Normal file
43
highlighters/main/test-data/alias-in-cmdsubst.zsh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2019 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias p='print -r --'
|
||||||
|
|
||||||
|
BUFFER=$'s=$(p foo)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 10 assign' # s=$(p foo)
|
||||||
|
'3 10 default' # $(p foo)
|
||||||
|
'3 10 command-substitution-unquoted' # $(p foo)
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 5 alias' # p
|
||||||
|
'7 9 default' # foo
|
||||||
|
'10 10 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
||||||
@@ -28,12 +28,16 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function b() {} # beware of ALIAS_FUNC_DEF
|
||||||
alias a=b b=c c=b
|
alias a=b b=c c=b
|
||||||
|
|
||||||
BUFFER='a foo; :'
|
BUFFER='a foo; :'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 unknown-token' # a (invalid alias loop)
|
# An alias is ineligible for expansion whilst it's being expanded.
|
||||||
|
# Therefore, the "b" in the expansion of the alias "c" is not considered
|
||||||
|
# as an alias.
|
||||||
|
'1 1 alias' # a
|
||||||
'3 5 default' # foo
|
'3 5 default' # foo
|
||||||
'6 6 commandseparator' # ;
|
'6 6 commandseparator' # ;
|
||||||
'8 8 builtin' # :
|
'8 8 builtin' # :
|
||||||
|
|||||||
39
highlighters/main/test-data/alias-reuse1.zsh
Normal file
39
highlighters/main/test-data/alias-reuse1.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias a=: b='a | a'
|
||||||
|
|
||||||
|
BUFFER='b | b'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # b
|
||||||
|
'3 3 commandseparator' # |
|
||||||
|
'5 5 alias' # b
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/alias-reuse2.zsh
Normal file
39
highlighters/main/test-data/alias-reuse2.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias a=: b='a && a'
|
||||||
|
|
||||||
|
BUFFER='b && b'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # b
|
||||||
|
'3 4 commandseparator' # &&
|
||||||
|
'6 6 alias' # b
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/alias-reuse3.zsh
Normal file
39
highlighters/main/test-data/alias-reuse3.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias a=: b='a; a'
|
||||||
|
|
||||||
|
BUFFER='b; b'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # b
|
||||||
|
'2 2 commandseparator' # ;
|
||||||
|
'4 4 alias' # b
|
||||||
|
)
|
||||||
42
highlighters/main/test-data/alias-reuse4.zsh
Normal file
42
highlighters/main/test-data/alias-reuse4.zsh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias a=: b='a $(a)'
|
||||||
|
|
||||||
|
BUFFER='b $(b)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # b
|
||||||
|
'3 6 default' # $(b)
|
||||||
|
'3 6 command-substitution-unquoted' # $(b)
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 5 alias' # b
|
||||||
|
'6 6 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
||||||
43
highlighters/main/test-data/alias-reuse5.zsh
Normal file
43
highlighters/main/test-data/alias-reuse5.zsh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias a=: b='a < <(a)'
|
||||||
|
|
||||||
|
BUFFER='b < <(b)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # b
|
||||||
|
'3 3 redirection' # <
|
||||||
|
'5 8 default' # <(b)
|
||||||
|
'5 8 process-substitution' # <(b)
|
||||||
|
'5 6 process-substitution-delimiter' # <(
|
||||||
|
'7 7 alias' # b
|
||||||
|
'8 8 process-substitution-delimiter' # )
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/alias-self2.zsh
Normal file
37
highlighters/main/test-data/alias-self2.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias cat='cat | cat'
|
||||||
|
|
||||||
|
BUFFER='cat'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 alias' # cat
|
||||||
|
)
|
||||||
@@ -32,5 +32,5 @@ alias x=/
|
|||||||
BUFFER=$'x'
|
BUFFER=$'x'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 unknown-token "issue #668"' # x (/)
|
'1 1 unknown-token' # x (/)
|
||||||
)
|
)
|
||||||
|
|||||||
37
highlighters/main/test-data/alias-to-dir1b.zsh
Normal file
37
highlighters/main/test-data/alias-to-dir1b.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt autocd
|
||||||
|
alias x=/
|
||||||
|
BUFFER=$'x'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 alias' # x
|
||||||
|
)
|
||||||
@@ -32,7 +32,7 @@ BUFFER=$'{\nls\n} always { pwd }'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 reserved-word' # {
|
'1 1 reserved-word' # {
|
||||||
'2 2 unknown-token' # \n
|
'2 2 commandseparator' # \n
|
||||||
'3 4 command' # ls
|
'3 4 command' # ls
|
||||||
'5 5 commandseparator' # \n
|
'5 5 commandseparator' # \n
|
||||||
'6 6 reserved-word' # }
|
'6 6 reserved-word' # }
|
||||||
|
|||||||
46
highlighters/main/test-data/arith-cmdsubst-mess.zsh
Normal file
46
highlighters/main/test-data/arith-cmdsubst-mess.zsh
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $((ls); (ls))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 15 default' # $((ls); (ls))
|
||||||
|
'3 15 command-substitution-unquoted' # $((ls); (ls))
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 5 reserved-word' # (
|
||||||
|
'6 7 command' # ls
|
||||||
|
'8 8 reserved-word' # )
|
||||||
|
'9 9 commandseparator' # ;
|
||||||
|
'11 11 reserved-word' # (
|
||||||
|
'12 13 command' # ls
|
||||||
|
'14 14 reserved-word' # )
|
||||||
|
'15 15 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/arith1.zsh
Normal file
37
highlighters/main/test-data/arith1.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( 6 * 9 ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 14 default' # $(( 6 * 9 ))
|
||||||
|
'3 14 arithmetic-expansion' # $(( 6 * 9 ))
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/arith2.zsh
Normal file
38
highlighters/main/test-data/arith2.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': "$(( 6 * 9 ))"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 16 default' # "$(( 6 * 9 ))"
|
||||||
|
'3 16 double-quoted-argument' # "$(( 6 * 9 ))"
|
||||||
|
'4 15 arithmetic-expansion' # $(( 6 * 9 ))
|
||||||
|
)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( $(echo 2) + 2 ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 22 default' # $(( $(echo 2) + 2 ))
|
||||||
|
'3 22 arithmetic-expansion' # $(( $(echo 2) + 2 ))
|
||||||
|
'7 15 command-substitution-quoted' # $(echo 2)
|
||||||
|
'7 8 command-substitution-delimiter-quoted' # $(
|
||||||
|
'9 12 builtin' # echo
|
||||||
|
'14 14 default' # 2
|
||||||
|
'15 15 command-substitution-delimiter' # )
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/arithmetic-doubled-parens.zsh
Normal file
37
highlighters/main/test-data/arithmetic-doubled-parens.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( ((42)) ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 15 default' # $(( ((42)) ))
|
||||||
|
'3 15 arithmetic-expansion' # $(( ((42)) ))
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/arithmetic-empty.zsh
Normal file
39
highlighters/main/test-data/arithmetic-empty.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': "foo"$(())"bar"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 17 default' # "foo"$(())"bar"
|
||||||
|
'3 7 double-quoted-argument' # "foo"
|
||||||
|
'8 12 arithmetic-expansion' # $(())
|
||||||
|
'13 17 double-quoted-argument' # "bar"
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/arithmetic-hist-expn.zsh
Normal file
38
highlighters/main/test-data/arithmetic-hist-expn.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( \!\! ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 11 default' # $(( !! ))
|
||||||
|
'3 11 arithmetic-expansion' # $(( !! ))
|
||||||
|
'7 8 history-expansion "issue #713"' # !!
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/arithmetic-invalid-chars.zsh
Normal file
39
highlighters/main/test-data/arithmetic-invalid-chars.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( 0 * 1\'\'000 ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 19 default' # $(( 0 * 1\'\'000 ))
|
||||||
|
'3 19 arithmetic-expansion' # $(( 0 * 1\'\'000 ))
|
||||||
|
'12 12 unknown-token' # \'
|
||||||
|
'13 13 unknown-token' # \'
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/arithmetic-multiplication.zsh
Normal file
39
highlighters/main/test-data/arithmetic-multiplication.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': foo*$(( 42 * 1729 ))*bar'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 26 default' # foo*$(( 42 * 1729 ))*bar
|
||||||
|
'6 6 globbing' # *
|
||||||
|
'7 22 arithmetic-expansion' # $(( 42 * 1729 ))
|
||||||
|
'23 23 globbing' # *
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/arithmetic-nested.zsh
Normal file
38
highlighters/main/test-data/arithmetic-nested.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( $(( 1 + 2 )) * 3 ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 25 default' # $(( $(( 1 + 2 )) * 3 ))
|
||||||
|
'3 25 arithmetic-expansion' # $(( $(( 1 + 2 )) * 3 ))
|
||||||
|
'7 18 arithmetic-expansion' # $(( 1 + 2 ))
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/arithmetic-quoted.zsh
Normal file
38
highlighters/main/test-data/arithmetic-quoted.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': "$(( 1 + 1 ))"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 16 default' # "$(( 1 + 1 ))"
|
||||||
|
'3 16 double-quoted-argument' # "$(( 1 + 1 ))"
|
||||||
|
'4 15 arithmetic-expansion' # $(( 1 + 1 ))
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/arithmetic-unclosed.zsh
Normal file
37
highlighters/main/test-data/arithmetic-unclosed.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( 1'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 7 default' # $(( 1
|
||||||
|
'3 7 arithmetic-expansion' # $(( 1
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/arithmetic-unfinished.zsh
Normal file
41
highlighters/main/test-data/arithmetic-unfinished.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(( 1729 )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 12 default' # $(( 1729 )
|
||||||
|
'3 12 arithmetic-expansion' # $(( 1729 )
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ ${(z):-'$('} == '$( ' ]]; then # ignore zsh 5.0.8 bug
|
||||||
|
expected_region_highlight[2]='3 13 default' # $(( 1729 )
|
||||||
|
fi
|
||||||
45
highlighters/main/test-data/array-cmdsep1.zsh
Normal file
45
highlighters/main/test-data/array-cmdsep1.zsh
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2019 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'a=( foo | bar )'
|
||||||
|
bar(){}
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 assign' # a=(
|
||||||
|
'3 3 reserved-word' # (
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 9 unknown-token' # |
|
||||||
|
# zsh reports a parse error at this point. Nevertheless, we test how we
|
||||||
|
# highlight the remainder of $BUFFER. Currently we recover by treating the pipe
|
||||||
|
# as a command separator. That's not the only reasonable behaviour, though; if
|
||||||
|
# we change the behaviour, we should adjust the following expectations accordingly.
|
||||||
|
'11 13 function' # bar
|
||||||
|
'15 15 unknown-token' # )
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/array-cmdsep2.zsh
Normal file
41
highlighters/main/test-data/array-cmdsep2.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2019 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'a=( foo ; bar )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 assign' # a=(
|
||||||
|
'3 3 reserved-word' # (
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 9 unknown-token' # ; (not commandseparator; see highlighter source code)
|
||||||
|
'11 13 default' # bar
|
||||||
|
'15 15 assign' # )
|
||||||
|
'15 15 reserved-word' # )
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/array-cmdsep3.zsh
Normal file
41
highlighters/main/test-data/array-cmdsep3.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2019 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'a=( foo \n bar )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 assign' # a=(
|
||||||
|
'3 3 reserved-word' # (
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 9 commandseparator' # \n
|
||||||
|
'11 13 default' # bar
|
||||||
|
'15 15 assign' # )
|
||||||
|
'15 15 reserved-word' # )
|
||||||
|
)
|
||||||
@@ -31,7 +31,9 @@ BUFFER='a+=(lorem ipsum)'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 4 assign" # a+=(
|
"1 4 assign" # a+=(
|
||||||
|
"4 4 reserved-word" # (
|
||||||
"5 9 default" # lorem
|
"5 9 default" # lorem
|
||||||
"11 15 default" # ipsum
|
"11 15 default" # ipsum
|
||||||
"16 16 assign" # )
|
"16 16 assign" # )
|
||||||
|
"16 16 reserved-word" # )
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ BUFFER='(A=(hello world))'
|
|||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 1 reserved-word" # (
|
"1 1 reserved-word" # (
|
||||||
"2 4 assign" # A=(
|
"2 4 assign" # A=(
|
||||||
|
"4 4 reserved-word" # (
|
||||||
"5 9 default" # hello
|
"5 9 default" # hello
|
||||||
"11 15 default" # world
|
"11 15 default" # world
|
||||||
"16 16 assign" # )
|
"16 16 assign" # )
|
||||||
|
"16 16 reserved-word" # )
|
||||||
"17 17 reserved-word" # )
|
"17 17 reserved-word" # )
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ BUFFER='A=(hello world) ls'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 3 assign" # A=(
|
"1 3 assign" # A=(
|
||||||
|
"3 3 reserved-word" # (
|
||||||
"4 8 default" # hello
|
"4 8 default" # hello
|
||||||
"10 14 default" # world
|
"10 14 default" # world
|
||||||
"15 15 assign" # )
|
"15 15 assign" # )
|
||||||
|
"15 15 reserved-word" # )
|
||||||
"17 18 command" # ls
|
"17 18 command" # ls
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ BUFFER='A=(hello world) b=42'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 3 assign" # A=(
|
"1 3 assign" # A=(
|
||||||
|
"3 3 reserved-word" # (
|
||||||
"4 8 default" # hello
|
"4 8 default" # hello
|
||||||
"10 14 default" # world
|
"10 14 default" # world
|
||||||
"15 15 assign" # )
|
"15 15 assign" # )
|
||||||
|
"15 15 reserved-word" # )
|
||||||
"17 20 assign" # b=42
|
"17 20 assign" # b=42
|
||||||
"19 20 default" # 42
|
"19 20 default" # 42
|
||||||
)
|
)
|
||||||
|
|||||||
37
highlighters/main/test-data/assign-invalid-command.zsh
Normal file
37
highlighters/main/test-data/assign-invalid-command.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'x=y nosuchcommand'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 assign' # x=y
|
||||||
|
'3 3 default' # y
|
||||||
|
'5 17 unknown-token' # nosuchcommand
|
||||||
|
)
|
||||||
45
highlighters/main/test-data/assign-quoted-cmdsubst.zsh
Normal file
45
highlighters/main/test-data/assign-quoted-cmdsubst.zsh
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'x="$(ls x y z)"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 15 assign' # x="$(ls x y z)"
|
||||||
|
'3 15 default' # "$(ls x y z)"
|
||||||
|
'3 3 double-quoted-argument' # "
|
||||||
|
'15 15 double-quoted-argument' # "
|
||||||
|
'4 14 command-substitution-quoted' # $(ls x y z)
|
||||||
|
'4 5 command-substitution-delimiter-quoted' # $(
|
||||||
|
'6 7 command' # ls
|
||||||
|
'9 9 default' # x
|
||||||
|
'11 11 default' # y
|
||||||
|
'13 13 default' # z
|
||||||
|
'14 14 command-substitution-delimiter-quoted' # )
|
||||||
|
)
|
||||||
@@ -33,8 +33,10 @@ expected_region_highlight=(
|
|||||||
"1 3 assign" # A=1
|
"1 3 assign" # A=1
|
||||||
"3 3 default" # 1
|
"3 3 default" # 1
|
||||||
"5 7 assign" # b=(
|
"5 7 assign" # b=(
|
||||||
|
"7 7 reserved-word" # (
|
||||||
"8 12 default" # "foo"
|
"8 12 default" # "foo"
|
||||||
"8 12 double-quoted-argument" # "foo"
|
"8 12 double-quoted-argument" # "foo"
|
||||||
"14 16 default" # bar
|
"14 16 default" # bar
|
||||||
"17 17 assign" # )
|
"17 17 assign" # )
|
||||||
|
"17 17 reserved-word" # )
|
||||||
)
|
)
|
||||||
|
|||||||
40
highlighters/main/test-data/assignment-before-resword1.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword1.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=bar { :; }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 assign' # foo=bar
|
||||||
|
'5 7 default' # bar
|
||||||
|
'9 9 unknown-token' # {
|
||||||
|
'11 11 builtin' # :
|
||||||
|
'12 12 commandseparator' # ;
|
||||||
|
'14 14 reserved-word' # }
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/assignment-before-resword2.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword2.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=bar ( :; )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 assign' # foo=bar
|
||||||
|
'5 7 default' # bar
|
||||||
|
'9 9 unknown-token' # (
|
||||||
|
'11 11 builtin' # :
|
||||||
|
'12 12 commandseparator' # ;
|
||||||
|
'14 14 unknown-token' # )
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/assignment-before-resword3.zsh
Normal file
37
highlighters/main/test-data/assignment-before-resword3.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=bar (( foo ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 assign' # foo=bar
|
||||||
|
'5 7 default' # bar
|
||||||
|
'9 17 unknown-token' # (( foo ))
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/assignment-before-resword4.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword4.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=bar [[ -n foo ]]'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 assign' # foo=bar
|
||||||
|
'5 7 default' # bar
|
||||||
|
'9 10 unknown-token' # [[
|
||||||
|
'12 13 single-hyphen-option' # -n
|
||||||
|
'15 17 default' # foo
|
||||||
|
'19 20 reserved-word' # ]]
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/assignment-before-resword5.zsh
Normal file
38
highlighters/main/test-data/assignment-before-resword5.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=bar \! :'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 assign' # foo=bar
|
||||||
|
'5 7 default' # bar
|
||||||
|
'9 9 unknown-token' # \!
|
||||||
|
'11 11 builtin' # :
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/backslash-continuation2.zsh
Normal file
37
highlighters/main/test-data/backslash-continuation2.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'echo foo\\\nbar"baz"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 18 default "issue #705"' # foo\\\nbar"baz"
|
||||||
|
'14 18 double-quoted-argument "issue #705"' # "baz"
|
||||||
|
)
|
||||||
@@ -32,9 +32,11 @@ BUFFER=$'foo=(bar abaz) \! ls'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 5 assign' # foo=(
|
'1 5 assign' # foo=(
|
||||||
|
'5 5 reserved-word' # (
|
||||||
'6 8 default' # bar
|
'6 8 default' # bar
|
||||||
'10 13 default' # abaz
|
'10 13 default' # abaz
|
||||||
'14 14 assign' # )
|
'14 14 assign' # )
|
||||||
|
'14 14 reserved-word' # )
|
||||||
'16 16 unknown-token' # \!
|
'16 16 unknown-token' # \!
|
||||||
'18 19 command' # ls
|
'18 19 command' # ls
|
||||||
)
|
)
|
||||||
|
|||||||
38
highlighters/main/test-data/block-assignment-no-command.zsh
Normal file
38
highlighters/main/test-data/block-assignment-no-command.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2022 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=$'{ a=42 }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 reserved-word' # {
|
||||||
|
'3 6 assign' # a=42
|
||||||
|
'5 6 default' # 42
|
||||||
|
'8 8 reserved word "issue #854"' # }
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/cdpath-abspath.zsh
Normal file
38
highlighters/main/test-data/cdpath-abspath.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
cdpath=( $PWD )
|
||||||
|
mkdir foo foo/bar
|
||||||
|
|
||||||
|
BUFFER="/foo"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 unknown-token' # x (/)
|
||||||
|
)
|
||||||
@@ -28,11 +28,12 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# see alias-comment1.zsh
|
||||||
setopt interactivecomments
|
setopt interactivecomments
|
||||||
BUFFER=$'# foo\ntrue'
|
BUFFER=$'# foo\ntrue'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 5 comment' # # foo
|
'1 5 comment' # # foo
|
||||||
'6 6 commandseparator "issue #501"' # \n
|
'6 6 commandseparator' # \n
|
||||||
'7 10 builtin' # true
|
'7 10 builtin' # true
|
||||||
)
|
)
|
||||||
|
|||||||
41
highlighters/main/test-data/dinbrack1.zsh
Normal file
41
highlighters/main/test-data/dinbrack1.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'[[ foo && bar || baz ]]'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # [[
|
||||||
|
'4 6 default' # foo
|
||||||
|
'8 9 default' # &&
|
||||||
|
'11 13 default' # bar
|
||||||
|
'15 16 default' # ||
|
||||||
|
'18 20 default' # baz
|
||||||
|
'22 23 reserved-word' # ]]
|
||||||
|
)
|
||||||
@@ -34,6 +34,6 @@ BUFFER=$':;\n:'
|
|||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 builtin' # :
|
'1 1 builtin' # :
|
||||||
'2 2 commandseparator' # ;
|
'2 2 commandseparator' # ;
|
||||||
'3 3 commandseparator "issue #616"' # \n
|
'3 3 commandseparator' # \n
|
||||||
'4 4 builtin' # :
|
'4 4 builtin' # :
|
||||||
)
|
)
|
||||||
|
|||||||
36
highlighters/main/test-data/equals1.zsh
Normal file
36
highlighters/main/test-data/equals1.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': =ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 5 path' # =ls
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/equals2.zsh
Normal file
38
highlighters/main/test-data/equals2.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
unsetopt equals
|
||||||
|
|
||||||
|
BUFFER=$': =nosuchcommand'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 16 default' # =nosuchcommand
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/equals3.zsh
Normal file
36
highlighters/main/test-data/equals3.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': =nosuchcommand'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 16 unknown-token' # =nosuchcommand
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/equals4.zsh
Normal file
36
highlighters/main/test-data/equals4.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': ='
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 3 default' # =
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/fd-target-not-filename.zsh
Normal file
40
highlighters/main/test-data/fd-target-not-filename.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch 2
|
||||||
|
|
||||||
|
BUFFER=$'echo foo>&2'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 8 default' # foo
|
||||||
|
'9 10 redirection' # >&
|
||||||
|
'11 11 numeric-fd' # 2 (not path)
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/global-alias1.zsh
Normal file
38
highlighters/main/test-data/global-alias1.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias -g foo=bar
|
||||||
|
|
||||||
|
BUFFER=$'foo foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 global-alias' # foo
|
||||||
|
'5 7 global-alias' # foo
|
||||||
|
)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': !!= "!!="'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 4 history-expansion "issue #713"' # !!
|
||||||
|
'7 11 default' # "!!="
|
||||||
|
'7 11 double-quoted-argument' # "!!="
|
||||||
|
'8 9 history-expansion "issue #713' # !!
|
||||||
|
)
|
||||||
49
highlighters/main/test-data/meta-no-eval1.zsh
Normal file
49
highlighters/main/test-data/meta-no-eval1.zsh
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': $(kill -9 $$) ${:-$(kill -9 $$)}'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 15 default' # $(kill -9 $$)
|
||||||
|
'3 15 command-substitution-unquoted' # $(kill -9 $$)
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 8 builtin' # kill
|
||||||
|
'10 11 single-hyphen-option' # -9
|
||||||
|
'13 14 default' # $$
|
||||||
|
'15 15 command-substitution-delimiter-unquoted' # )
|
||||||
|
'17 34 default' # ${:-$(kill -9 $$)}
|
||||||
|
'21 33 command-substitution-unquoted' # $(kill -9 $$)
|
||||||
|
'21 22 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'23 26 builtin' # kill
|
||||||
|
'28 29 single-hyphen-option' # -9
|
||||||
|
'31 32 default' # $$
|
||||||
|
'33 33 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/meta-no-eval2.zsh
Normal file
40
highlighters/main/test-data/meta-no-eval2.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# We aren't testing how this is highlighted; we're testing that it's not
|
||||||
|
# evaluated. If it gets evaluated, the test suite will die.
|
||||||
|
BUFFER=$': /(e*exit 42*)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 15 default' # /(e*exit 42*)
|
||||||
|
'6 6 globbing' # *
|
||||||
|
'14 14 globbing' # *
|
||||||
|
)
|
||||||
@@ -32,8 +32,10 @@ BUFFER=$'foo=(\nbar) env'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 5 assign' # foo=(
|
'1 5 assign' # foo=(
|
||||||
|
'5 5 reserved-word' # (
|
||||||
'6 6 commandseparator' # \n
|
'6 6 commandseparator' # \n
|
||||||
'7 9 default' # bar
|
'7 9 default' # bar
|
||||||
'10 10 assign' # )
|
'10 10 assign' # )
|
||||||
'12 14 command' # env
|
'10 10 reserved-word' # )
|
||||||
|
'12 14 precommand' # env
|
||||||
)
|
)
|
||||||
|
|||||||
39
highlighters/main/test-data/multios-negates-globbing.zsh
Normal file
39
highlighters/main/test-data/multios-negates-globbing.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
unsetopt multios
|
||||||
|
|
||||||
|
BUFFER=$'cat < *'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 command' # cat
|
||||||
|
'5 5 redirection' # <
|
||||||
|
'7 7 default' # * - not globbing
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/multios-negates-globbing2.zsh
Normal file
38
highlighters/main/test-data/multios-negates-globbing2.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'cat < *'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 command' # cat
|
||||||
|
'5 5 redirection' # <
|
||||||
|
'7 7 default' # *
|
||||||
|
'7 7 globbing' # *
|
||||||
|
)
|
||||||
@@ -39,6 +39,7 @@ expected_region_highlight=(
|
|||||||
'19 24 reserved-word' # always
|
'19 24 reserved-word' # always
|
||||||
'26 26 reserved-word' # {
|
'26 26 reserved-word' # {
|
||||||
'28 31 builtin' # echo
|
'28 31 builtin' # echo
|
||||||
'33 33 globbing "issue #577"' # *
|
'33 33 default' # *
|
||||||
|
'33 33 globbing' # *
|
||||||
'35 35 reserved-word' # }
|
'35 35 reserved-word' # }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,5 +34,5 @@ expected_region_highlight=(
|
|||||||
'1 4 precommand' # exec
|
'1 4 precommand' # exec
|
||||||
'6 6 redirection' # >
|
'6 6 redirection' # >
|
||||||
'7 15 path' # /dev/null
|
'7 15 path' # /dev/null
|
||||||
'16 16 commandseparator "issue #676"' # ;
|
'16 16 commandseparator' # ;
|
||||||
)
|
)
|
||||||
|
|||||||
38
highlighters/main/test-data/null-exec2-printenv.zsh
Normal file
38
highlighters/main/test-data/null-exec2-printenv.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2021 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=$'env | grep $needle'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 precommand' # env
|
||||||
|
'5 5 commandseparator' # |
|
||||||
|
'7 10 command' # grep
|
||||||
|
'12 18 default' # $needle
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/opt-shwordsplit1.zsh
Normal file
40
highlighters/main/test-data/opt-shwordsplit1.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt shwordsplit
|
||||||
|
local EDITOR='ed -s'
|
||||||
|
|
||||||
|
ed() { command ed "$@" }
|
||||||
|
|
||||||
|
BUFFER=$'$EDITOR'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 function' # $EDITOR
|
||||||
|
)
|
||||||
43
highlighters/main/test-data/optimized-cmdsubst-input.zsh
Normal file
43
highlighters/main/test-data/optimized-cmdsubst-input.zsh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See getoutput() and getoutputfile() in zsh's C source code.
|
||||||
|
|
||||||
|
BUFFER=$': $(<*)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 7 default' # $(<*)
|
||||||
|
'3 7 command-substitution-unquoted' # $(<*)
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 5 redirection' # <
|
||||||
|
'6 6 default' # * - not globbing!
|
||||||
|
'7 7 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# This used to be an infinite loop.
|
||||||
|
|
||||||
|
BUFFER=$'l+=( $1'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 assign' # l+=(
|
||||||
|
'4 4 reserved-word' # (
|
||||||
|
'6 7 default' # $1
|
||||||
|
)
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='$x ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 comment' # $x
|
||||||
|
'4 5 command' # ls
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2021 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt sh_word_split
|
||||||
|
local foo='echo foo'
|
||||||
|
|
||||||
|
BUFFER='$foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # $foo
|
||||||
|
)
|
||||||
42
highlighters/main/test-data/parameter-to-global-alias.zsh
Normal file
42
highlighters/main/test-data/parameter-to-global-alias.zsh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if type global_alias >/dev/null; then
|
||||||
|
skip_test="Test is written on the assumption that 'global_alias' is not a valid command name, but that assumption does not hold"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
alias -g global_alias=y
|
||||||
|
local s=global_alias
|
||||||
|
|
||||||
|
BUFFER=$'$s'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 unknown-token' # $s
|
||||||
|
)
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
BUFFER='$PWD; ${PWD}'
|
BUFFER='$PWD; ${PWD}'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 4 path" # $PWD
|
"1 4 unknown-token" # $PWD (without AUTO_CD)
|
||||||
"5 5 commandseparator" # ;
|
"5 5 commandseparator" # ;
|
||||||
"7 12 path" # ${PWD}
|
"7 12 path_prefix" # ${PWD}
|
||||||
)
|
)
|
||||||
|
|||||||
38
highlighters/main/test-data/path-dollared-word3b.zsh
Normal file
38
highlighters/main/test-data/path-dollared-word3b.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt autocd
|
||||||
|
BUFFER=$'$PWD; ${PWD}'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 autodirectory' # $PWD
|
||||||
|
'5 5 commandseparator' # ;
|
||||||
|
'7 12 autodirectory' # ${PWD}
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/path-mixed-quoting.zsh
Normal file
39
highlighters/main/test-data/path-mixed-quoting.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch foo
|
||||||
|
|
||||||
|
BUFFER=$': \'f\'oo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 7 path' # \'f\'oo
|
||||||
|
'3 5 single-quoted-argument' # \'f\'
|
||||||
|
)
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
# Assumes that '/bin/sh' exists and '/bin/s' does not exist.
|
# Assumes that '/bin/sh' exists and '/bin/s' does not exist.
|
||||||
# Related to path_prefix.zsh
|
# Related to path_prefix.zsh
|
||||||
|
|
||||||
PREBUFFER='ls \'
|
PREBUFFER=$'ls \\\n'
|
||||||
BUFFER='/bin/s'
|
BUFFER='/bin/s'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2020 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch foo
|
||||||
|
chmod -x foo
|
||||||
|
BUFFER=$'./foo; ./foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 5 unknown-token' # ./foo (in middle)
|
||||||
|
'6 6 commandseparator' # ;
|
||||||
|
'8 12 unknown-token' # ./foo (at end)
|
||||||
|
)
|
||||||
@@ -29,11 +29,12 @@
|
|||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
hash sudo=false
|
hash sudo=false
|
||||||
|
touch foo
|
||||||
|
|
||||||
BUFFER='sudo -e /etc/passwd'
|
BUFFER='sudo -e ./foo'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 4 precommand' # sudo
|
'1 4 precommand' # sudo
|
||||||
'6 7 single-hyphen-option' # -e
|
'6 7 single-hyphen-option' # -e
|
||||||
'9 19 path' # /etc/passwd
|
'9 13 path' # ./foo
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ BUFFER='sudo -e /does/not/exist'
|
|||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 4 precommand' # sudo
|
'1 4 precommand' # sudo
|
||||||
'6 7 single-hyphen-option' # -e
|
'6 7 single-hyphen-option' # -e
|
||||||
'9 23 normal "issue #678"' # /does/not/exist
|
'9 23 default' # /does/not/exist
|
||||||
)
|
)
|
||||||
|
|||||||
37
highlighters/main/test-data/precommand-then-assignment.zsh
Normal file
37
highlighters/main/test-data/precommand-then-assignment.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2019 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'nice x=y ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # nice
|
||||||
|
'6 8 unknown-token "issue #641.5"' # x=y
|
||||||
|
'10 11 default "issue #641.5 (fallout)"' # ls
|
||||||
|
)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user