Compare commits
528 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb67c0b84f | ||
|
|
15d4587514 | ||
|
|
e5a59f6b56 | ||
|
|
b4d882dd59 | ||
|
|
035d3eb095 | ||
|
|
2e95ffc08f | ||
|
|
b7e277106b | ||
|
|
1495195eb5 | ||
|
|
50cbdbaebc | ||
|
|
242481c279 | ||
|
|
cd9ec14a65 | ||
|
|
24096c2e4f | ||
|
|
28d7056a7a | ||
|
|
1bdb88aee1 | ||
|
|
5dcf0cecd8 | ||
|
|
31250c77bf | ||
|
|
39ab1b7321 | ||
|
|
af0099465f | ||
|
|
d464d3857f | ||
|
|
f5c44ed7a2 | ||
|
|
2335986a39 | ||
|
|
e060a0a1c8 | ||
|
|
f3d0e141fd | ||
|
|
3c90a673f6 | ||
|
|
773d60c833 | ||
|
|
2dff6e54ed | ||
|
|
0020f592c1 | ||
|
|
56e4c38ab4 | ||
|
|
7d38d07255 | ||
|
|
094329eb14 | ||
|
|
bccc3dc269 | ||
|
|
b4537a972e | ||
|
|
2b303f01b6 | ||
|
|
79198759b3 | ||
|
|
dd51b7bebe | ||
|
|
15461e7d21 | ||
|
|
44ef6e38e5 | ||
|
|
4afe670f7a | ||
|
|
c3913e0d8e | ||
|
|
4fc35362ee | ||
|
|
2bb8f0703d | ||
|
|
a2876fb57d | ||
|
|
b2733a64da | ||
|
|
2755438e80 | ||
|
|
c6b6513ac0 | ||
|
|
a053768627 | ||
|
|
e5782e4ddf | ||
|
|
8bf423d16d | ||
|
|
5627fd2045 | ||
|
|
987c133486 | ||
|
|
a4196eda5e | ||
|
|
e15a09840e | ||
|
|
6f91850a01 | ||
|
|
2fabf7ca64 | ||
|
|
51b9d79c3b | ||
|
|
0a9b347483 | ||
|
|
02807f1826 | ||
|
|
a8a6384356 | ||
|
|
fdaeec4514 | ||
|
|
4c4baede51 | ||
|
|
da60234fb2 | ||
|
|
51614ca2c9 | ||
|
|
11c9081967 | ||
|
|
c7f7d2ff16 | ||
|
|
c793e0dcea | ||
|
|
a3d5dfcbda | ||
|
|
f91a7b885e | ||
|
|
f3242cbd6a | ||
|
|
b2ba91f12f | ||
|
|
d1e0defceb | ||
|
|
b7bb4f8657 | ||
|
|
2c002f9f89 | ||
|
|
757d047f09 | ||
|
|
179b8e753f | ||
|
|
6e2ef574c8 | ||
|
|
d1c773faa7 | ||
|
|
295d62ec88 | ||
|
|
d711563fe1 | ||
|
|
e2f863c151 | ||
|
|
4ad311ec0a | ||
|
|
171a4eec2d | ||
|
|
a8fe22d422 | ||
|
|
5bae621900 | ||
|
|
9e569bb0fe | ||
|
|
add6825898 | ||
|
|
8013dc3b8d | ||
|
|
fa57633d81 | ||
|
|
0d41933c61 | ||
|
|
e6fb61c42b | ||
|
|
6b69389bd9 | ||
|
|
3409a2e4d2 | ||
|
|
53083da821 | ||
|
|
95f7206a93 | ||
|
|
fffe13a8fb | ||
|
|
80148f6c84 | ||
|
|
ba16cf2fb2 | ||
|
|
3e59ab41b6 | ||
|
|
d13da0cf00 | ||
|
|
ee07588cfd | ||
|
|
b9112aec79 | ||
|
|
f3d3aaa00c | ||
|
|
9a934d291e | ||
|
|
750aebc553 | ||
|
|
d9e07b5082 | ||
|
|
da91264122 | ||
|
|
e35a0b256e | ||
|
|
10a596f9fd | ||
|
|
4b77af73fb | ||
|
|
47144ad974 | ||
|
|
7fb6f99791 | ||
|
|
fccf92402b | ||
|
|
29b30e0ca7 | ||
|
|
f4036a09ce | ||
|
|
14711a51f3 | ||
|
|
91fa057a39 | ||
|
|
f060622dc6 | ||
|
|
6cd39e7c70 | ||
|
|
a5b8bc0ef0 | ||
|
|
3b67e656bf | ||
|
|
12b879caf7 | ||
|
|
61f43255ab | ||
|
|
6362c757b6 | ||
|
|
d37c55c788 | ||
|
|
364f206a54 | ||
|
|
19acd8e844 | ||
|
|
13018f3dd7 | ||
|
|
0f43026bf0 | ||
|
|
1082067f93 | ||
|
|
ef68f50c04 | ||
|
|
4832f18c50 | ||
|
|
f146651913 | ||
|
|
2f18ba64e3 | ||
|
|
3ce01076b5 | ||
|
|
def8c0da83 | ||
|
|
4f5bb6cf96 | ||
|
|
0ff354b44b | ||
|
|
7b82b88a71 | ||
|
|
ef4bfe5bcc | ||
|
|
5a98cd3a10 | ||
|
|
02229ebd63 | ||
|
|
162c826452 | ||
|
|
a00ed24ba3 | ||
|
|
62f1c108f3 | ||
|
|
5fe8fd8bdc | ||
|
|
2176692704 | ||
|
|
a7a7f8b422 | ||
|
|
15db71abd0 | ||
|
|
fc9c892a3f | ||
|
|
bfabffbf97 | ||
|
|
6889ff6bd2 | ||
|
|
9cab566f53 | ||
|
|
bb341f186c | ||
|
|
b5955213b9 | ||
|
|
f0bae44b76 | ||
|
|
3176b9567c | ||
|
|
6aa57d60aa | ||
|
|
f83bca0847 | ||
|
|
70b5687d66 | ||
|
|
21207c336a | ||
|
|
56a867076c | ||
|
|
f73f3d53d3 | ||
|
|
eaa4335c34 | ||
|
|
d3678ec7a8 | ||
|
|
fd061b5730 | ||
|
|
ccaf6f48a1 | ||
|
|
e05b8e88ad | ||
|
|
95d82568d8 | ||
|
|
f4d3dcb42f | ||
|
|
fd84010252 | ||
|
|
cef49752fd | ||
|
|
e8af14fe1f | ||
|
|
4da9889d15 | ||
|
|
c346f6eb6f | ||
|
|
f34714b8ee | ||
|
|
341a3ae1f0 | ||
|
|
089329660b | ||
|
|
a830613467 | ||
|
|
c54c076cfa | ||
|
|
38c8fbea2d | ||
|
|
b52a485c5c | ||
|
|
d4f8edc9f3 | ||
|
|
367929502f | ||
|
|
78290e043b | ||
|
|
31ac2b36a9 | ||
|
|
bb8d325c0c | ||
|
|
79e4d3d124 | ||
|
|
bc7f8ea433 | ||
|
|
cb02451a4e | ||
|
|
11d378332e | ||
|
|
6a634fac9f | ||
|
|
47a664447c | ||
|
|
261c180a36 | ||
|
|
7e7e291b20 | ||
|
|
4849ef3307 | ||
|
|
4c23a2fd1b | ||
|
|
e635f766be | ||
|
|
18df692ae6 | ||
|
|
487b122c48 | ||
|
|
7044c1986e | ||
|
|
bdb23d1378 | ||
|
|
e500ca2462 | ||
|
|
e938825a85 | ||
|
|
3cb58fd7d7 | ||
|
|
683f4837a0 | ||
|
|
62a6be3d63 | ||
|
|
451665cb2a | ||
|
|
30d8f92df2 | ||
|
|
282c7134e8 | ||
|
|
28932316cc | ||
|
|
5e4b446dee | ||
|
|
9b64ad750f | ||
|
|
936e2e9314 | ||
|
|
ed33d2cb13 | ||
|
|
268656d52b | ||
|
|
38c3ac8831 | ||
|
|
82f5eb17ec | ||
|
|
4f3910cbba | ||
|
|
73ee7c1f6c | ||
|
|
48ecd29180 | ||
|
|
430cf55368 | ||
|
|
46cd970bc4 | ||
|
|
09c4114eb9 | ||
|
|
cf685a3a27 | ||
|
|
69b6c4e450 | ||
|
|
7338c54a25 | ||
|
|
2d792b03bb | ||
|
|
eee130f81d | ||
|
|
952a97dbc9 | ||
|
|
1f1ad09e38 | ||
|
|
eb3715a56a | ||
|
|
95330c691b | ||
|
|
371f8183d6 | ||
|
|
2e5481ab9a | ||
|
|
2ed2f1e3c4 | ||
|
|
b8ced86853 | ||
|
|
84734ba950 | ||
|
|
635a68f7b4 | ||
|
|
438a94496f | ||
|
|
7ee350efcd | ||
|
|
22123ab622 | ||
|
|
ded1c8789b | ||
|
|
0b3183f6cb | ||
|
|
8e115052e9 | ||
|
|
5b34c23cfa | ||
|
|
c575f8f375 | ||
|
|
f5ca4b891b | ||
|
|
51f66ae851 | ||
|
|
0ab450ae47 | ||
|
|
35e0b0ca69 | ||
|
|
2dd6923c30 | ||
|
|
6e99128987 | ||
|
|
bcc9db2784 | ||
|
|
b989ae23d0 | ||
|
|
3f163a2fd4 | ||
|
|
3bedd8571e | ||
|
|
9ce97cd64d | ||
|
|
49f7beecb5 | ||
|
|
12097d55d1 | ||
|
|
8ea392e361 | ||
|
|
91e4a576fb | ||
|
|
6c033e62e9 | ||
|
|
e60737d320 | ||
|
|
17fbcad8ac | ||
|
|
ea5186543d | ||
|
|
1933de83be | ||
|
|
e2096f5c4e | ||
|
|
29fd6ec1de | ||
|
|
3ed0f7f823 | ||
|
|
2dbcb575e5 | ||
|
|
00de155063 | ||
|
|
3bfd250cce | ||
|
|
7d4252f5f5 | ||
|
|
21e5e26923 | ||
|
|
b1619c0013 | ||
|
|
79b95c629e | ||
|
|
3669d69226 | ||
|
|
4fcfb15913 | ||
|
|
bdc1449733 | ||
|
|
1397f1bae1 | ||
|
|
8f19af6b31 | ||
|
|
6e3720f39d | ||
|
|
28776371a0 | ||
|
|
4f0c293fde | ||
|
|
96ee5116b1 | ||
|
|
a636527f70 | ||
|
|
2b35ff1c15 | ||
|
|
c015339202 | ||
|
|
b5d02a2f49 | ||
|
|
e1078a8b4c | ||
|
|
3620ad951f | ||
|
|
b285c7b821 | ||
|
|
44e5323b53 | ||
|
|
c0dafd1d85 | ||
|
|
28abb960de | ||
|
|
a59f442d2d | ||
|
|
8b4adbd991 | ||
|
|
6fbd2aa957 | ||
|
|
9e178f9f39 | ||
|
|
5a38710564 | ||
|
|
d3deffbf46 | ||
|
|
8ab8c815ec | ||
|
|
afa6bb3882 | ||
|
|
1ac39b0af1 | ||
|
|
693de99a90 | ||
|
|
e76f208cf8 | ||
|
|
e9ceb2017e | ||
|
|
2f05620b19 | ||
|
|
9cb87473cc | ||
|
|
f49f3bf0c0 | ||
|
|
a3047a9121 | ||
|
|
86e9249709 | ||
|
|
0d1bfbcbfa | ||
|
|
c216242b46 | ||
|
|
2218e26bf8 | ||
|
|
b397b12ac1 | ||
|
|
87deac3062 | ||
|
|
01d7eeb3c7 | ||
|
|
6d6fb8b03e | ||
|
|
be006aded5 | ||
|
|
c6355a31b7 | ||
|
|
018bc45f21 | ||
|
|
2c9f8c8c95 | ||
|
|
88cf98d9c4 | ||
|
|
0aa6a5db78 | ||
|
|
10b1da64e6 | ||
|
|
80d692c400 | ||
|
|
e49251b6fa | ||
|
|
2080a441ac | ||
|
|
59fbdda64c | ||
|
|
7723edf4f5 | ||
|
|
c808d2187a | ||
|
|
7e6d960a08 | ||
|
|
feec9f58c9 | ||
|
|
ed6d229b1c | ||
|
|
fb5ce43799 | ||
|
|
6fe07c0961 | ||
|
|
4513eaea71 | ||
|
|
9816fcf055 | ||
|
|
871af68082 | ||
|
|
7d45f3e3ec | ||
|
|
98aee7f8b9 | ||
|
|
4d3da30f8b | ||
|
|
557bb7e0c6 | ||
|
|
57624bb9f6 | ||
|
|
663c760cc9 | ||
|
|
20d106bd4d | ||
|
|
d66113c1ed | ||
|
|
728ed66ff9 | ||
|
|
8b8b19d91f | ||
|
|
a18a7427fd | ||
|
|
187371a459 | ||
|
|
c4a9fe9379 | ||
|
|
11c060ab76 | ||
|
|
b2ac98b981 | ||
|
|
22c8736e2b | ||
|
|
d99aa58aaa | ||
|
|
083c47b007 | ||
|
|
30f2f1f144 | ||
|
|
8631cc1061 | ||
|
|
cae87016c6 | ||
|
|
cac3d95269 | ||
|
|
b5c30ae526 | ||
|
|
fee52920ae | ||
|
|
58b0047c81 | ||
|
|
a73b33fc13 | ||
|
|
c687bddea3 | ||
|
|
c30301d474 | ||
|
|
0a7035170a | ||
|
|
85500ec151 | ||
|
|
bb9c407c95 | ||
|
|
6f7bf8c0f4 | ||
|
|
72b1abd17d | ||
|
|
3576df29aa | ||
|
|
bde1c83af1 | ||
|
|
4604deb652 | ||
|
|
f48f5400c1 | ||
|
|
379ab0d34e | ||
|
|
766b350a7d | ||
|
|
fe4e893ce5 | ||
|
|
e0bb30a153 | ||
|
|
728784649f | ||
|
|
9a3c7d1960 | ||
|
|
c538d6b357 | ||
|
|
9c56c624e9 | ||
|
|
43386376d8 | ||
|
|
984b4acd78 | ||
|
|
75d62b9657 | ||
|
|
94191f0731 | ||
|
|
2883c9582d | ||
|
|
83c3f96109 | ||
|
|
7aeadfe01b | ||
|
|
56c793d96a | ||
|
|
e138cfd765 | ||
|
|
07fd773d7e | ||
|
|
5cd1fb26c0 | ||
|
|
faed2fa49e | ||
|
|
69203b1a1d | ||
|
|
800158745a | ||
|
|
7b4598a764 | ||
|
|
52a2ef644b | ||
|
|
6488284814 | ||
|
|
f657406159 | ||
|
|
8b728522de | ||
|
|
79e8c2dd48 | ||
|
|
4ec821b2b1 | ||
|
|
219184f046 | ||
|
|
3fdaec3d4a | ||
|
|
6732783d46 | ||
|
|
0788514cbd | ||
|
|
8a43bd2cd9 | ||
|
|
98366ade11 | ||
|
|
78ad649d47 | ||
|
|
69fcb40275 | ||
|
|
f4164ac86c | ||
|
|
9c7a1109c8 | ||
|
|
dd12dde93a | ||
|
|
cb5589db73 | ||
|
|
35c4bb7bdc | ||
|
|
040df93c01 | ||
|
|
86cd337446 | ||
|
|
c43dc8bd44 | ||
|
|
66eb801358 | ||
|
|
b0cc02ed86 | ||
|
|
4ec0c6d7a7 | ||
|
|
908c4fe150 | ||
|
|
1467eae86d | ||
|
|
9e80fe8f02 | ||
|
|
001e6cb404 | ||
|
|
22fa215e05 | ||
|
|
845361ef3d | ||
|
|
4594d8b7ec | ||
|
|
5fb4cb2f72 | ||
|
|
f7cb4741d6 | ||
|
|
81c8d78d12 | ||
|
|
8767e0ef66 | ||
|
|
b056f592f2 | ||
|
|
e0a7ddb6ec | ||
|
|
416934202e | ||
|
|
627eb71940 | ||
|
|
00862cf4fa | ||
|
|
aab1b8f50f | ||
|
|
4068413dfe | ||
|
|
404d498e1d | ||
|
|
05ab9f7342 | ||
|
|
0d3a5dadea | ||
|
|
51102bf83f | ||
|
|
186536705b | ||
|
|
547b8be304 | ||
|
|
80587e5419 | ||
|
|
c46b8d169e | ||
|
|
a8afbdf2f5 | ||
|
|
6d93ea07fd | ||
|
|
4f5a0fe60b | ||
|
|
e5c2a88db0 | ||
|
|
0e31d6e1a2 | ||
|
|
555e142e66 | ||
|
|
e13c5a1611 | ||
|
|
8515b7e0c5 | ||
|
|
dc701501e5 | ||
|
|
9310d8ae71 | ||
|
|
b3ceea8511 | ||
|
|
a0b5bc6c71 | ||
|
|
d330b49b33 | ||
|
|
f78919d941 | ||
|
|
eaffd88793 | ||
|
|
546a5288e2 | ||
|
|
8e7c26f489 | ||
|
|
7f41967a17 | ||
|
|
13a8db1d71 | ||
|
|
51aed8a765 | ||
|
|
42495cc5d6 | ||
|
|
ea81e3df6e | ||
|
|
c2b9327b07 | ||
|
|
52ece975c3 | ||
|
|
7ee9df915d | ||
|
|
85b3446897 | ||
|
|
b9b67b9f78 | ||
|
|
359d48bf78 | ||
|
|
ff4d402e9a | ||
|
|
384be15b13 | ||
|
|
23cacb12fe | ||
|
|
667495bfb7 | ||
|
|
2c5acaefa9 | ||
|
|
0c8c4b73f8 | ||
|
|
a723f504a5 | ||
|
|
3dc5741900 | ||
|
|
10391d025a | ||
|
|
443908b9a2 | ||
|
|
eb9870f4db | ||
|
|
74a183447d | ||
|
|
d7d4dff1c8 | ||
|
|
7edd08156e | ||
|
|
e8cc271314 | ||
|
|
5320f1e18d | ||
|
|
dcb5da9457 | ||
|
|
c83e266888 | ||
|
|
072c064d2a | ||
|
|
04f9c8884f | ||
|
|
f289a9f8e7 | ||
|
|
8ac964186d | ||
|
|
ffce2a0b20 | ||
|
|
63a720af9b | ||
|
|
784a5dc35b | ||
|
|
441f1a8aad | ||
|
|
c62cb54e9d | ||
|
|
0fc6b07509 | ||
|
|
dffbab0c92 | ||
|
|
3b3a58be91 | ||
|
|
dbd27cb30a | ||
|
|
08b80022ca | ||
|
|
a7ee0597ef | ||
|
|
3677b75731 | ||
|
|
3f2c76f393 | ||
|
|
6fcdb06b28 | ||
|
|
57c01d19de | ||
|
|
8abcf187f6 | ||
|
|
93827ed84d | ||
|
|
228f5a6aad | ||
|
|
0fcc2629d2 | ||
|
|
e5d8a50d36 | ||
|
|
612e493cba | ||
|
|
408b100295 | ||
|
|
a0862053f5 | ||
|
|
b4e667795c | ||
|
|
45194671af | ||
|
|
19981ef9ea | ||
|
|
732b7d6e65 | ||
|
|
966eb851ca |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.revision-hash export-subst
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
*.zwc*
|
*.zwc*
|
||||||
|
.pc/
|
||||||
|
docs/all.md
|
||||||
|
|||||||
1
.revision-hash
Normal file
1
.revision-hash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$Format:%H$
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
|||||||
75
HACKING.md
Normal file
75
HACKING.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
Hacking on zsh-syntax-highlighting itself
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
This document includes information for people working on z-sy-h itself: on the
|
||||||
|
core driver (`zsh-syntax-highlighting.zsh`), on the highlighters in the
|
||||||
|
distribution, and on the test suite. It does not target third-party
|
||||||
|
highlighter authors (although they may find it an interesting read).
|
||||||
|
|
||||||
|
The `main` highlighter
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The following function `pz` is useful when working on the `main` highlighting:
|
||||||
|
|
||||||
|
pq() {
|
||||||
|
(( $#argv )) || return 0
|
||||||
|
print -r -l -- ${(qqqq)argv}
|
||||||
|
}
|
||||||
|
pz() {
|
||||||
|
local arg
|
||||||
|
for arg; do
|
||||||
|
pq ${(z)arg}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
It prints, for each argument, its token breakdown, similar to how the main
|
||||||
|
loop of the `main` highlighter sees it.
|
||||||
|
|
||||||
|
Testing the `brackets` highlighter
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Since the test harness empties `ZSH_HIGHLIGHT_STYLES` and the `brackets`
|
||||||
|
highlighter interrogates `ZSH_HIGHLIGHT_STYLES` to determine how to highlight,
|
||||||
|
tests must set the `bracket-level-#` keys themselves. For example:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
|
BUFFER='echo ({x})'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"6 6 bracket-level-1" # (
|
||||||
|
"7 7 bracket-level-2" # {
|
||||||
|
"9 9 bracket-level-2" # }
|
||||||
|
"10 10 bracket-level-1" # )
|
||||||
|
)
|
||||||
|
|
||||||
|
Testing the `pattern` highlighter
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
Because the `pattern` highlighter modifies `region_highlight` directly instead
|
||||||
|
of using `_zsh_highlight_add_highlight`, the test harness cannot get the
|
||||||
|
`ZSH_HIGHLIGHT_STYLES` keys. Therefore, when writing tests, use the style
|
||||||
|
itself as third word (cf. the [documentation for `expected_region_highlight`]
|
||||||
|
(docs/highlighters.md)). For example:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||||
|
|
||||||
|
BUFFER='rm -rf /'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 8 fg=white,bold,bg=red" # rm -rf /
|
||||||
|
)
|
||||||
|
|
||||||
|
Miscellany
|
||||||
|
----------
|
||||||
|
|
||||||
|
If you work on the driver (`zsh-syntax-highlighting.zsh`), you may find the following zstyle useful:
|
||||||
|
|
||||||
|
zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh
|
||||||
|
|
||||||
|
IRC channel
|
||||||
|
-----------
|
||||||
|
|
||||||
|
We're on #zsh-syntax-highlighting on freenode.
|
||||||
|
|
||||||
101
INSTALL.md
Normal file
101
INSTALL.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
How to install
|
||||||
|
--------------
|
||||||
|
|
||||||
|
### Using packages
|
||||||
|
|
||||||
|
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
|
||||||
|
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package]
|
||||||
|
* Gentoo: [mv overlay][gentoo-overlay]
|
||||||
|
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
|
||||||
|
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package]
|
||||||
|
|
||||||
|
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
|
||||||
|
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
|
||||||
|
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
|
||||||
|
[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting
|
||||||
|
[brew-package]: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh-syntax-highlighting.rb
|
||||||
|
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
|
||||||
|
|
||||||
|
|
||||||
|
### In your ~/.zshrc
|
||||||
|
|
||||||
|
Simply clone this repository and source the script:
|
||||||
|
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||||
|
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||||
|
|
||||||
|
Then, enable syntax highlighting in the current interactive shell:
|
||||||
|
|
||||||
|
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
If `git` is not installed, download and extract a snapshot of the latest
|
||||||
|
development tree from:
|
||||||
|
|
||||||
|
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
|
||||||
|
|
||||||
|
Note the `source` command must be **at the end** of `~/.zshrc`.
|
||||||
|
|
||||||
|
|
||||||
|
### With a plugin manager
|
||||||
|
|
||||||
|
Note that `zsh-syntax-highlighting` must be the last plugin sourced.
|
||||||
|
|
||||||
|
The zsh-syntax-highlighting authors recommend manual installation over the use
|
||||||
|
of a framework or plugin manager.
|
||||||
|
|
||||||
|
This list is incomplete as there are too many [frameworks / plugin managers]
|
||||||
|
(https://github.com/unixorn/awesome-zsh-plugins#frameworks) to list them all
|
||||||
|
here.
|
||||||
|
|
||||||
|
#### [Antigen](https://github.com/zsh-users/antigen)
|
||||||
|
|
||||||
|
Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in
|
||||||
|
your `.zshrc`.
|
||||||
|
|
||||||
|
#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
|
||||||
|
|
||||||
|
1. Clone this repository in oh-my-zsh's plugins directory:
|
||||||
|
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||||
|
|
||||||
|
2. Activate the plugin in `~/.zshrc`:
|
||||||
|
|
||||||
|
plugins=( [plugins...] zsh-syntax-highlighting)
|
||||||
|
|
||||||
|
3. Source `~/.zshrc` to take changes into account:
|
||||||
|
|
||||||
|
source ~/.zshrc
|
||||||
|
|
||||||
|
#### [Prezto](https://github.com/sorin-ionescu/prezto)
|
||||||
|
|
||||||
|
Zsh-syntax-highlighting is included with Prezto. See the [Prezto documentation]
|
||||||
|
(https://github.com/sorin-ionescu/prezto/tree/master/modules/syntax-highlighting)
|
||||||
|
to enable and configure highlighters.
|
||||||
|
|
||||||
|
#### [zgen](https://github.com/tarjoilija/zgen)
|
||||||
|
|
||||||
|
Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
|
||||||
|
|
||||||
|
#### [zplug](https://github.com/zplug/zplug)
|
||||||
|
|
||||||
|
Add `zplug "zsh-users/zsh-syntax-highlighting", nice:10` to your `.zshrc`.
|
||||||
|
|
||||||
|
#### [zplugin](https://github.com/psprint/zplugin)
|
||||||
|
|
||||||
|
Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your
|
||||||
|
`.zshrc`.
|
||||||
|
|
||||||
|
|
||||||
|
### System-wide installation
|
||||||
|
|
||||||
|
Any of the above methods is suitable for a single-user installation,
|
||||||
|
which requires no special privileges. If, however, you desire to install
|
||||||
|
zsh-syntax-highlighting system-wide, you may do so by running
|
||||||
|
|
||||||
|
make install
|
||||||
|
|
||||||
|
and directing your users to add
|
||||||
|
|
||||||
|
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
to their `.zshrc`s.
|
||||||
62
Makefile
Normal file
62
Makefile
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
NAME=zsh-syntax-highlighting
|
||||||
|
|
||||||
|
INSTALL?=install -c
|
||||||
|
PREFIX?=/usr/local
|
||||||
|
SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
|
||||||
|
DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
|
||||||
|
ZSH?=zsh # zsh binary to run tests with
|
||||||
|
|
||||||
|
all:
|
||||||
|
cd docs && \
|
||||||
|
cp highlighters.md all.md && \
|
||||||
|
printf '\n\nIndividual highlighters documentation\n=====================================' >> all.md && \
|
||||||
|
for doc in highlighters/*.md; do printf '\n\n'; cat "$$doc"; done >> all.md
|
||||||
|
|
||||||
|
install: all
|
||||||
|
$(INSTALL) -d $(SHARE_DIR)
|
||||||
|
$(INSTALL) -d $(DOC_DIR)
|
||||||
|
cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR)
|
||||||
|
cp COPYING.md README.md changelog.md $(DOC_DIR)
|
||||||
|
if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
|
||||||
|
git rev-parse HEAD; \
|
||||||
|
else \
|
||||||
|
cat .revision-hash; \
|
||||||
|
fi > $(SHARE_DIR)/.revision-hash
|
||||||
|
:
|
||||||
|
# The [ -e ] check below is to because sh evaluates this with (the moral
|
||||||
|
# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches.
|
||||||
|
for dirname in highlighters highlighters/*/ ; do \
|
||||||
|
$(INSTALL) -d $(SHARE_DIR)/"$$dirname"; \
|
||||||
|
for fname in "$$dirname"/*.zsh ; do [ -e "$$fname" ] && cp "$$fname" $(SHARE_DIR)"/$$dirname"; done; \
|
||||||
|
done
|
||||||
|
cp -R docs/* $(DOC_DIR)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f docs/all.md
|
||||||
|
|
||||||
|
test:
|
||||||
|
@result=0; \
|
||||||
|
for test in highlighters/*; do \
|
||||||
|
if [ -d $$test/test-data ]; then \
|
||||||
|
echo "Running test $${test##*/}"; \
|
||||||
|
$(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
|
||||||
|
: $$(( result |= $$? )); \
|
||||||
|
fi \
|
||||||
|
done; \
|
||||||
|
exit $$result
|
||||||
|
|
||||||
|
quiet-test:
|
||||||
|
$(MAKE) test QUIET=y
|
||||||
|
|
||||||
|
perf:
|
||||||
|
@result=0; \
|
||||||
|
for test in highlighters/*; do \
|
||||||
|
if [ -d $$test/test-data ]; then \
|
||||||
|
echo "Running test $${test##*/}"; \
|
||||||
|
$(ZSH) -f tests/test-perfs.zsh "$${test##*/}"; \
|
||||||
|
: $$(( result |= $$? )); \
|
||||||
|
fi \
|
||||||
|
done; \
|
||||||
|
exit $$result
|
||||||
|
|
||||||
|
.PHONY: all install clean test perf
|
||||||
86
README.md
86
README.md
@@ -1,52 +1,78 @@
|
|||||||
zsh-syntax-highlighting
|
zsh-syntax-highlighting
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
**[Fish shell](http://www.fishshell.com) like syntax highlighting for [Zsh](http://www.zsh.org).**
|
**[Fish shell][fish]-like like syntax highlighting for [Zsh][zsh].**
|
||||||
|
|
||||||
*Requirements: zsh 4.3.9+.*
|
*Requirements: zsh 4.3.17+.*
|
||||||
|
|
||||||
|
[fish]: http://www.fishshell.com/
|
||||||
|
[zsh]: http://www.zsh.org/
|
||||||
|
|
||||||
|
This package provides syntax highlighing for the shell zsh. It enables
|
||||||
|
highlighing of commands whilst they are typed at a zsh prompt into an
|
||||||
|
interactive terminal. This helps in reviewing commands before running
|
||||||
|
them, particularly in catching syntax errors.
|
||||||
|
|
||||||
|
Some examples:
|
||||||
|
|
||||||
|
Before: [](images/before1.png)
|
||||||
|
<br/>
|
||||||
|
After: [](images/after1.png)
|
||||||
|
|
||||||
|
Before: [](images/before2.png)
|
||||||
|
<br/>
|
||||||
|
After: [](images/after2.png)
|
||||||
|
|
||||||
|
Before: [](images/before3.png)
|
||||||
|
<br/>
|
||||||
|
After: [](images/after3.png)
|
||||||
|
|
||||||
|
|
||||||
How to install
|
How to install
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
### Using packages
|
See [INSTALL.md](INSTALL.md).
|
||||||
|
|
||||||
* Arch Linux: [AUR/zsh-syntax-highlighting](https://aur.archlinux.org/packages.php?ID=54171) / [AUR/zsh-syntax-highlighting-git](https://aur.archlinux.org/packages.php?ID=50867)
|
|
||||||
* Gentoo: [mv overlay](http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting)
|
|
||||||
|
|
||||||
### In your ~/.zshrc
|
|
||||||
|
|
||||||
* Download the script or clone this repository:
|
|
||||||
|
|
||||||
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
|
|
||||||
|
|
||||||
* Source the script **at the end** of `~/.zshrc`:
|
|
||||||
|
|
||||||
source /path/to/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
||||||
|
|
||||||
* Source `~/.zshrc` to take changes into account:
|
|
||||||
|
|
||||||
source ~/.zshrc
|
|
||||||
|
|
||||||
|
|
||||||
### With oh-my-zsh
|
FAQ
|
||||||
|
---
|
||||||
|
|
||||||
* Download the script or clone this repository in [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) plugins directory:
|
### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file?
|
||||||
|
|
||||||
cd ~/.oh-my-zsh/custom/plugins
|
`zsh-syntax-highlighting.zsh` wraps ZLE widgets. It must be sourced after all
|
||||||
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
|
custom widgets have been created (i.e., after all `zle -N` calls and after
|
||||||
|
running `compinit`). Widgets created later will work, but will not update the
|
||||||
|
syntax highlighting.
|
||||||
|
|
||||||
* Activate the plugin in `~/.zshrc` (in **last** position):
|
### Does syntax highlighting work during incremental history search?
|
||||||
|
|
||||||
plugins=( [plugins...] zsh-syntax-highlighting)
|
Highlighting the command line during an incremental history search
|
||||||
|
(with the `history-incremental-search-backward` widget, which is
|
||||||
|
bound by default to <kbd>Ctrl+R</kbd> in zsh's emacs keymap) requires zsh 5.3
|
||||||
|
or newer.
|
||||||
|
|
||||||
* Source `~/.zshrc` to take changes into account:
|
Under zsh 5.2 and older, the zsh-default [underlining][zshzle-Character-Highlighting]
|
||||||
|
of the matched portion of the buffer remains available, but zsh-syntax-highlighting's
|
||||||
|
additional highlighting is unavailable. (Those versions of zsh do not provide
|
||||||
|
enough information to allow computing the highlighting correctly.)
|
||||||
|
|
||||||
source ~/.zshrc
|
See [issue #288][i288] for details.
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
|
||||||
|
|
||||||
|
### How are new releases announced?
|
||||||
|
|
||||||
|
There is currently no "push" announcements channel. However, the following
|
||||||
|
alternatives exist:
|
||||||
|
|
||||||
|
- GitHub's RSS feed of releases: https://github.com/zsh-users/zsh-syntax-highlighting/releases.atom
|
||||||
|
- An anitya entry: https://release-monitoring.org/project/7552/
|
||||||
|
|
||||||
|
|
||||||
How to tweak
|
How to tweak
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Syntax highlighting is done by pluggable highlighter scripts, see the [highlighters directory](zsh-syntax-highlighting/tree/master/highlighters)
|
Syntax highlighting is done by pluggable highlighter scripts. See the
|
||||||
for documentation and configuration settings.
|
[documentation on highlighters](docs/highlighters.md) for details and
|
||||||
|
configuration settings.
|
||||||
|
|||||||
486
changelog.md
Normal file
486
changelog.md
Normal file
@@ -0,0 +1,486 @@
|
|||||||
|
up to 0.5.0
|
||||||
|
|
||||||
|
# Changes in version 0.5.0
|
||||||
|
|
||||||
|
|
||||||
|
## Performance improvements:
|
||||||
|
|
||||||
|
We thank Sebastian Gniazdowski and "m0viefreak" for significant contributions
|
||||||
|
in this area.
|
||||||
|
|
||||||
|
- Optimize string operations in the `main` (default) highlighter.
|
||||||
|
(#372/3cb58fd7d7b9, 02229ebd6328, ef4bfe5bcc14, #372/c6b6513ac0d6, #374/15461e7d21c3)
|
||||||
|
|
||||||
|
- Command word highlighting: Use the `zsh/parameter` module to avoid forks.
|
||||||
|
Memoize (cache) the results.
|
||||||
|
(#298, 3ce01076b521, 2f18ba64e397, 12b879caf7a6; #320, 3b67e656bff5)
|
||||||
|
|
||||||
|
- Avoid forks in the driver and in the `root` highlighter.
|
||||||
|
(b9112aec798a, 38c8fbea2dd2)
|
||||||
|
|
||||||
|
|
||||||
|
## Added highlighting of:
|
||||||
|
|
||||||
|
- `pkexec` (a precommand).
|
||||||
|
(#248, 4f3910cbbaa5)
|
||||||
|
|
||||||
|
- Aliases that cannot be defined normally nor invoked normally (highlighted as an error).
|
||||||
|
(#263 (in part), 28932316cca6)
|
||||||
|
|
||||||
|
- Path separators (`/`) — the default behaviour remains to highlight path separators
|
||||||
|
and path components the same way.
|
||||||
|
(#136, #260, 6cd39e7c70d3, 9a934d291e7c, f3d3aaa00cc4)
|
||||||
|
|
||||||
|
- Assignments to individual positional arguments (`42=foo` to assign to `$42`).
|
||||||
|
(f4036a09cee3)
|
||||||
|
|
||||||
|
- Linewise region (the `visual-line-mode` widget, bound to `V` in zsh's `vi` keymap).
|
||||||
|
(#267, a7a7f8b42280, ee07588cfd9b)
|
||||||
|
|
||||||
|
- Command-lines recalled by `isearch` mode; requires zsh≥5.3.
|
||||||
|
(#261 (in part); #257; 4ad311ec0a68)
|
||||||
|
|
||||||
|
- Command-lines whilst the `IGNORE_BRACES` or `IGNORE_CLOSE_BRACES` option is in effect.
|
||||||
|
(a8a6384356af, 02807f1826a5)
|
||||||
|
|
||||||
|
- Mismatched parentheses and braces (in the `main` highlighter).
|
||||||
|
(51b9d79c3bb6, 2fabf7ca64b7, a4196eda5e6f, and others)
|
||||||
|
|
||||||
|
- Mismatched `do`/`done` keywords.
|
||||||
|
(b2733a64da93)
|
||||||
|
|
||||||
|
- Mismatched `foreach`/`end` keywords.
|
||||||
|
(#96, 2bb8f0703d8f)
|
||||||
|
|
||||||
|
- In Bourne-style function definitions, when the `MULTI_FUNC_DEF` option is set
|
||||||
|
(which is the default), highlight the first word in the function body as
|
||||||
|
a command word: `f() { g "$@" }`.
|
||||||
|
(6f91850a01e1)
|
||||||
|
|
||||||
|
- `always` blocks.
|
||||||
|
(#335, e5782e4ddfb6)
|
||||||
|
|
||||||
|
- Command substitutions inside double quotes, `"$(echo foo)"`.
|
||||||
|
(#139 (in part), c3913e0d8ead)
|
||||||
|
|
||||||
|
- Non-alphabetic parameters inside double quotes (`"$$"`, `"$#"`, `"$*"`, `"$@"`, `"$?"`, `"$-"`).
|
||||||
|
(4afe670f7a1b, 44ef6e38e5a7)
|
||||||
|
|
||||||
|
- Command words from future versions of zsh (forward compatibly).
|
||||||
|
This also adds an `arg0` style that all other command word styles fall back to.
|
||||||
|
(b4537a972eed, bccc3dc26943)
|
||||||
|
|
||||||
|
- Escaped history expansions inside double quotes: `: "\!"`
|
||||||
|
(28d7056a7a06, et seq)
|
||||||
|
|
||||||
|
|
||||||
|
## Fixed highlighting of:
|
||||||
|
|
||||||
|
- Command separator tokens in syntactically-invalid positions.
|
||||||
|
(09c4114eb980)
|
||||||
|
|
||||||
|
- Redirections with a file descriptor number at command word.
|
||||||
|
(#238 (in part), 73ee7c1f6c4a)
|
||||||
|
|
||||||
|
- The `select` prompt, `$PS3`.
|
||||||
|
(#268, 451665cb2a8b)
|
||||||
|
|
||||||
|
- Values of variables in `vared`.
|
||||||
|
(e500ca246286)
|
||||||
|
|
||||||
|
- `!` as an argument (neither a history expansion nor a reserved word).
|
||||||
|
(4c23a2fd1b90)
|
||||||
|
|
||||||
|
- "division by zero" error under the `brackets` highlighter when `$ZSH_HIGHLIGHT_STYLES` is empty.
|
||||||
|
(f73f3d53d3a6)
|
||||||
|
|
||||||
|
- Process substitutions, `<(pwd)` and `>(wc -l)`.
|
||||||
|
(#302, 6889ff6bd2ad, bfabffbf975c, fc9c892a3f15)
|
||||||
|
|
||||||
|
- The non-`SHORT_LOOPS` form of `repeat` loops: `repeat 42; do true; done`.
|
||||||
|
(#290, 4832f18c50a5, ef68f50c048f, 6362c757b6f7)
|
||||||
|
|
||||||
|
- Broken symlinks (are now highlighted as files).
|
||||||
|
(#342, 95f7206a9373, 53083da8215e)
|
||||||
|
|
||||||
|
- Lines accepted from `isearch` mode.
|
||||||
|
(#284; #257, #259, #288; 5bae6219008b, a8fe22d42251)
|
||||||
|
|
||||||
|
- Work around upstream bug that triggered when the command word was a relative
|
||||||
|
path, that when interpreted relative to a $PATH directory denoted a command;
|
||||||
|
the effect of that upstream bug was that the relative path was cached as
|
||||||
|
a "valid external command name".
|
||||||
|
(#354, #355, 51614ca2c994, fdaeec45146b, 7d38d07255e4;
|
||||||
|
upstream fix slated to be released in 5.3 (workers/39104))
|
||||||
|
|
||||||
|
- After accepting a line with the cursor on a bracket, the matching bracket
|
||||||
|
of the bracket under the cursor no longer remains highlighted (with the
|
||||||
|
`brackets` highlighter).
|
||||||
|
(4c4baede519a)
|
||||||
|
|
||||||
|
- The first word on a new line within an array assignment or initialization is no
|
||||||
|
longer considered a command position.
|
||||||
|
(8bf423d16d46)
|
||||||
|
|
||||||
|
- Subshells that end at command position, `(A=42)`, `(true;)`.
|
||||||
|
(#231, 7fb6f9979121; #344, 4fc35362ee5a)
|
||||||
|
|
||||||
|
- Command word after array assignment, `a=(lorem ipsum) pwd`.
|
||||||
|
(#330, 7fb6f9979121)
|
||||||
|
|
||||||
|
|
||||||
|
## API changes (for highlighter authors):
|
||||||
|
|
||||||
|
- New interface `_zsh_highlight_add_highlight`.
|
||||||
|
(341a3ae1f015, c346f6eb6fb6)
|
||||||
|
|
||||||
|
- tests: Specify the style key, not its value, in test expectations.
|
||||||
|
(a830613467af, fd061b5730bf, eaa4335c3441, among others)
|
||||||
|
|
||||||
|
- Module author documentation improvements.
|
||||||
|
(#306 (in part), 217669270418, 0ff354b44b6e, 80148f6c8402, 364f206a547f, and others)
|
||||||
|
|
||||||
|
- The driver no longer defines a `_zsh_highlight_${highlighter}_highlighter_cache`
|
||||||
|
variable, which is in the highlighters' namespace.
|
||||||
|
(3e59ab41b6b8, 80148f6c8402, f91a7b885e7d)
|
||||||
|
|
||||||
|
- Rename highlighter entry points. The old names remain supported for
|
||||||
|
backwards compatibility.
|
||||||
|
(a3d5dfcbdae9, c793e0dceab1)
|
||||||
|
|
||||||
|
- tests: Add the "NONE" expectation.
|
||||||
|
(4da9889d1545, 13018f3dd735, d37c55c788cd)
|
||||||
|
|
||||||
|
- tests: consider a test that writes to stderr to have failed.
|
||||||
|
(#291, 1082067f9315)
|
||||||
|
|
||||||
|
|
||||||
|
## Developer-visible changes:
|
||||||
|
|
||||||
|
- Add `make quiet-test`.
|
||||||
|
(9b64ad750f35)
|
||||||
|
|
||||||
|
- test harness: Better quote replaceables in error messages.
|
||||||
|
(30d8f92df225)
|
||||||
|
|
||||||
|
- test harness: Fix exit code for XPASS.
|
||||||
|
(bb8d325c0cbd)
|
||||||
|
|
||||||
|
- Create [HACKING.md](HACKING.md).
|
||||||
|
(cef49752fd0e)
|
||||||
|
|
||||||
|
- tests: Emit a description for PASS test points.
|
||||||
|
(6aa57d60aa64, f0bae44b76dd)
|
||||||
|
|
||||||
|
- tests: Create a script that generates a test file.
|
||||||
|
(8013dc3b8db6, et seq; `tests/generate.zsh`)
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes:
|
||||||
|
|
||||||
|
- Under zsh≤5.2, widgets whose names start with a `_` are no longer excluded
|
||||||
|
from highlighting.
|
||||||
|
(ed33d2cb1388; reverts part of 186d80054a40 which was for #65)
|
||||||
|
|
||||||
|
- Under zsh≤5.2, widgets implemented by a function named after the widget are
|
||||||
|
no longer excluded from highlighting.
|
||||||
|
(487b122c480d; reverts part of 776453cb5b69)
|
||||||
|
|
||||||
|
- Under zsh≤5.2, shell-unsafe widget names can now be wrapped.
|
||||||
|
(#278, 6a634fac9fb9, et seq)
|
||||||
|
|
||||||
|
- Correct some test expectations.
|
||||||
|
(78290e043bc5)
|
||||||
|
|
||||||
|
- `zsh-syntax-highlighting.plugin.zsh`: Convert from symlink to plain file
|
||||||
|
for msys2 compatibility.
|
||||||
|
(#292, d4f8edc9f3ad)
|
||||||
|
|
||||||
|
- Document installation under some plugin managers.
|
||||||
|
(e635f766bef9, 9cab566f539b)
|
||||||
|
|
||||||
|
- Don't leak the `PATH_DIRS` option.
|
||||||
|
(7b82b88a7166)
|
||||||
|
|
||||||
|
- Don't require the `FUNCTION_ARGZERO` option to be set.
|
||||||
|
(#338, 750aebc553f2)
|
||||||
|
|
||||||
|
- Under zsh≤5.2, support binding incomplete/nonexistent widgets.
|
||||||
|
(9e569bb0fe04, part of #288)
|
||||||
|
|
||||||
|
- Make the driver reentrant, fixing possibility of infinite recursion
|
||||||
|
under zsh≤5.2 under interaction with theoretical third-party code.
|
||||||
|
(#305, d711563fe1bf, 295d62ec888d, f3242cbd6aba)
|
||||||
|
|
||||||
|
- Fix warnings when `WARN_CREATE_GLOBAL` is set prior to sourcing zsh-syntax-highlighting.
|
||||||
|
(z-sy-h already sets `WARN_CREATE_GLOBAL` internally.)
|
||||||
|
(da60234fb236)
|
||||||
|
|
||||||
|
- Warn only once, rather than once per keypress, when a highlighter is unavailable.
|
||||||
|
(0a9b347483ae)
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in version 0.4.1
|
||||||
|
|
||||||
|
## Fixes:
|
||||||
|
|
||||||
|
- Arguments to widgets were not properly dash-escaped. Only matters for widgets
|
||||||
|
that take arguments (i.e., that are invoked as `zle ${widget} -- ${args}`).
|
||||||
|
(282c7134e8ac, reverts c808d2187a73)
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in version 0.4.0
|
||||||
|
|
||||||
|
|
||||||
|
## Added highlighting of:
|
||||||
|
|
||||||
|
- incomplete sudo commands
|
||||||
|
(a3047a912100, 2f05620b19ae)
|
||||||
|
|
||||||
|
sudo;
|
||||||
|
sudo -u;
|
||||||
|
|
||||||
|
- command words following reserved words
|
||||||
|
(#207, #222, b397b12ac139 et seq, 6fbd2aa9579b et seq, 8b4adbd991b0)
|
||||||
|
|
||||||
|
if ls; then ls; else ls; fi
|
||||||
|
repeat 10 do ls; done
|
||||||
|
|
||||||
|
(The `ls` are now highlighted as a command.)
|
||||||
|
|
||||||
|
- comments (when `INTERACTIVE_COMMENTS` is set)
|
||||||
|
(#163, #167, 693de99a9030)
|
||||||
|
|
||||||
|
echo Hello # comment
|
||||||
|
|
||||||
|
- closing brackets of arithmetic expansion, subshells, and blocks
|
||||||
|
(#226, a59f442d2d34, et seq)
|
||||||
|
|
||||||
|
(( foo ))
|
||||||
|
( foo )
|
||||||
|
{ foo }
|
||||||
|
|
||||||
|
- command names enabled by the `PATH_DIRS` option
|
||||||
|
(#228, 96ee5116b182)
|
||||||
|
|
||||||
|
# When ~/bin/foo/bar exists, is executable, ~/bin is in $PATH,
|
||||||
|
# and 'setopt PATH_DIRS' is in effect
|
||||||
|
foo/bar
|
||||||
|
|
||||||
|
- parameter expansions with braces inside double quotes
|
||||||
|
(#186, 6e3720f39d84)
|
||||||
|
|
||||||
|
echo "${foo}"
|
||||||
|
|
||||||
|
- parameter expansions in command word
|
||||||
|
(#101, 4fcfb15913a2)
|
||||||
|
|
||||||
|
x=/bin/ls
|
||||||
|
$x -l
|
||||||
|
|
||||||
|
- the command separators '|&', '&!', '&|'
|
||||||
|
|
||||||
|
view file.pdf &! ls
|
||||||
|
|
||||||
|
|
||||||
|
## Fixed highlighting of:
|
||||||
|
|
||||||
|
- precommand modifiers at non-command-word position
|
||||||
|
(#209, 2c9f8c8c95fa)
|
||||||
|
|
||||||
|
ls command foo
|
||||||
|
|
||||||
|
- sudo commands with infix redirections
|
||||||
|
(#221, be006aded590, 86e924970911)
|
||||||
|
|
||||||
|
sudo -u >/tmp/foo.out user ls
|
||||||
|
|
||||||
|
- subshells; anonymous functions
|
||||||
|
(#166, #194, 0d1bfbcbfa67, 9e178f9f3948)
|
||||||
|
|
||||||
|
(true)
|
||||||
|
() { true }
|
||||||
|
|
||||||
|
- parameter assignment statements with no command
|
||||||
|
(#205, 01d7eeb3c713)
|
||||||
|
|
||||||
|
A=1;
|
||||||
|
|
||||||
|
(The semicolon used to be highlighted as a mistake)
|
||||||
|
|
||||||
|
- cursor highlighter: Remove the cursor highlighting when accepting a line.
|
||||||
|
(#109, 4f0c293fdef0)
|
||||||
|
|
||||||
|
|
||||||
|
## Removed features:
|
||||||
|
|
||||||
|
- Removed highlighting of approximate paths (`path_approx`).
|
||||||
|
(#187, 98aee7f8b9a3)
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes:
|
||||||
|
|
||||||
|
- main highlighter refactored to use states rather than booleans.
|
||||||
|
(2080a441ac49, et seq)
|
||||||
|
|
||||||
|
- Fix initialization when sourcing `zsh-syntax-highlighting.zsh` via a symlink
|
||||||
|
(083c47b00707)
|
||||||
|
|
||||||
|
- docs: Add screenshot.
|
||||||
|
(57624bb9f64b)
|
||||||
|
|
||||||
|
- widgets wrapping: Don't add '--' when invoking widgets.
|
||||||
|
(c808d2187a73) [_reverted in 0.4.1_]
|
||||||
|
|
||||||
|
- Refresh highlighting upon `accept-*` widgets (`accept-line` et al).
|
||||||
|
(59fbdda64c21)
|
||||||
|
|
||||||
|
- Stop leaking match/mbegin/mend to global scope (thanks to upstream
|
||||||
|
`WARN_CREATE_GLOBAL` improvements).
|
||||||
|
(d3deffbf46a4)
|
||||||
|
|
||||||
|
- 'make install': Permit setting `$(SHARE_DIR)` from the environment.
|
||||||
|
(e1078a8b4cf1)
|
||||||
|
|
||||||
|
- driver: Tolerate KSH_ARRAYS being set in the calling context.
|
||||||
|
(#162, 8f19af6b319d)
|
||||||
|
|
||||||
|
- 'make install': Install documentation fully and properly.
|
||||||
|
(#219, b1619c001390, et seq)
|
||||||
|
|
||||||
|
- docs: Improve 'main' highlighter's documentation.
|
||||||
|
(00de155063f5, 7d4252f5f596)
|
||||||
|
|
||||||
|
- docs: Moved to a new docs/ tree; assorted minor updates
|
||||||
|
(c575f8f37567, 5b34c23cfad5, et seq)
|
||||||
|
|
||||||
|
- docs: Split README.md into INSTALL.md
|
||||||
|
(0b3183f6cb9a)
|
||||||
|
|
||||||
|
- driver: Report `$ZSH_HIGHLIGHT_REVISION` when running from git
|
||||||
|
(84734ba95026)
|
||||||
|
|
||||||
|
|
||||||
|
## Developer-visible changes:
|
||||||
|
|
||||||
|
- Test harness converted to [TAP](http://testanything.org/tap-specification.html) format
|
||||||
|
(d99aa58aaaef, et seq)
|
||||||
|
|
||||||
|
- Run each test in a separate subprocess, isolating them from each other
|
||||||
|
(d99aa58aaaef, et seq)
|
||||||
|
|
||||||
|
- Fix test failure with nonexisting $HOME
|
||||||
|
(#216, b2ac98b98150)
|
||||||
|
|
||||||
|
- Test output is now colorized.
|
||||||
|
(4d3da30f8b72, 6fe07c096109)
|
||||||
|
|
||||||
|
- Document `make install`
|
||||||
|
(a18a7427fd2c)
|
||||||
|
|
||||||
|
- tests: Allow specifying the zsh binary to use.
|
||||||
|
(557bb7e0c6a0)
|
||||||
|
|
||||||
|
- tests: Add 'make perf' target
|
||||||
|
(4513eaea71d7)
|
||||||
|
|
||||||
|
- tests: Run each test in a sandbox directory
|
||||||
|
(c01533920245)
|
||||||
|
|
||||||
|
|
||||||
|
# Changes in version 0.3.0
|
||||||
|
|
||||||
|
|
||||||
|
## Added highlighting of:
|
||||||
|
|
||||||
|
- suffix aliases (requires zsh 5.1.1 or newer):
|
||||||
|
|
||||||
|
alias -s png=display
|
||||||
|
foo.png
|
||||||
|
|
||||||
|
- prefix redirections:
|
||||||
|
|
||||||
|
<foo.txt cat
|
||||||
|
|
||||||
|
- redirection operators:
|
||||||
|
|
||||||
|
echo > foo.txt
|
||||||
|
|
||||||
|
- arithmetic evaluations:
|
||||||
|
|
||||||
|
(( 42 ))
|
||||||
|
|
||||||
|
- $'' strings, including \x/\octal/\u/\U escapes
|
||||||
|
|
||||||
|
: $'foo\u0040bar'
|
||||||
|
|
||||||
|
- multiline strings:
|
||||||
|
|
||||||
|
% echo "line 1
|
||||||
|
line 2"
|
||||||
|
|
||||||
|
- string literals that haven't been finished:
|
||||||
|
|
||||||
|
% echo "Hello, world
|
||||||
|
|
||||||
|
- command words that involve tilde expansion:
|
||||||
|
|
||||||
|
% ~/bin/foo
|
||||||
|
|
||||||
|
|
||||||
|
## Fixed highlighting of:
|
||||||
|
|
||||||
|
- quoted command words:
|
||||||
|
|
||||||
|
% \ls
|
||||||
|
|
||||||
|
- backslash escapes in "" strings:
|
||||||
|
|
||||||
|
% echo "\x41"
|
||||||
|
|
||||||
|
- noglob after command separator:
|
||||||
|
|
||||||
|
% :; noglob echo *
|
||||||
|
|
||||||
|
- glob after command separator, when the first command starts with 'noglob':
|
||||||
|
|
||||||
|
% noglob true; echo *
|
||||||
|
|
||||||
|
- the region (vi visual mode / set-mark-command) (issue #165)
|
||||||
|
|
||||||
|
- redirection and command separators that would be highlighted as `path_approx`
|
||||||
|
|
||||||
|
% echo foo;‸
|
||||||
|
% echo <‸
|
||||||
|
|
||||||
|
(where `‸` represents the cursor location)
|
||||||
|
|
||||||
|
- escaped globbing (outside quotes)
|
||||||
|
|
||||||
|
% echo \*
|
||||||
|
|
||||||
|
|
||||||
|
## Other changes:
|
||||||
|
|
||||||
|
- implemented compatibility with zsh's paste highlighting (issue #175)
|
||||||
|
|
||||||
|
- `$?` propagated correctly to wrapped widgets
|
||||||
|
|
||||||
|
- don't leak $REPLY into global scope
|
||||||
|
|
||||||
|
|
||||||
|
## Developer-visible changes:
|
||||||
|
|
||||||
|
- added makefile with `install` and `test` targets
|
||||||
|
|
||||||
|
- set `warn_create_global` internally
|
||||||
|
|
||||||
|
- document release process
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Version 0.2.1
|
||||||
|
|
||||||
|
(Start of changelog.)
|
||||||
|
|
||||||
97
docs/highlighters.md
Normal file
97
docs/highlighters.md
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Syntax highlighting is done by pluggable highlighters:
|
||||||
|
|
||||||
|
* `main` - the base highlighter, and the only one [active by default][1].
|
||||||
|
* `brackets` - [matches brackets][2] and parenthesis.
|
||||||
|
* `pattern` - matches [user-defined patterns][3].
|
||||||
|
* `cursor` - matches [the cursor position][4].
|
||||||
|
* `root` - highlights the whole command line [if the current user is root][5].
|
||||||
|
* `line` - applied to [the whole command line][6].
|
||||||
|
|
||||||
|
[1]: highlighters/main.md
|
||||||
|
[2]: highlighters/brackets.md
|
||||||
|
[3]: highlighters/pattern.md
|
||||||
|
[4]: highlighters/cursor.md
|
||||||
|
[5]: highlighters/root.md
|
||||||
|
[6]: highlighters/line.md
|
||||||
|
|
||||||
|
|
||||||
|
How to activate highlighters
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in
|
||||||
|
`~/.zshrc`, for example:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
||||||
|
|
||||||
|
By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main`
|
||||||
|
highlighter is active.
|
||||||
|
|
||||||
|
|
||||||
|
How to tweak highlighters
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` associative array.
|
||||||
|
Navigate into the [individual highlighters' documentation](highlighters/) to
|
||||||
|
see what styles (keys) each highlighter defines; the syntax for values is the
|
||||||
|
same as the syntax of "types of highlighting" of the zsh builtin
|
||||||
|
`$zle_highlight` array, which is documented in [the `zshzle(1)` manual
|
||||||
|
page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
|
|
||||||
|
Some highlighters support additional configuration parameters; see each
|
||||||
|
highlighter's documentation for details and examples.
|
||||||
|
|
||||||
|
|
||||||
|
How to implement a new highlighter
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
To create your own `acme` highlighter:
|
||||||
|
|
||||||
|
* Create your script at
|
||||||
|
`highlighters/acme/acme-highlighter.zsh`.
|
||||||
|
|
||||||
|
* Implement the `_zsh_highlight_highlighter_acme_predicate` function.
|
||||||
|
This function must return 0 when the highlighter needs to be called and
|
||||||
|
non-zero otherwise, for example:
|
||||||
|
|
||||||
|
_zsh_highlight_highlighter_acme_predicate() {
|
||||||
|
# Call this highlighter in SVN working copies
|
||||||
|
[[ -d .svn ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
* Implement the `_zsh_highlight_highlighter_acme_paint` function.
|
||||||
|
This function does the actual syntax highlighting, by calling
|
||||||
|
`_zsh_highlight_add_highlight` with the start and end of the region to
|
||||||
|
be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. Define the default
|
||||||
|
style for that key in the highlighter script outside of any function with
|
||||||
|
`: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix
|
||||||
|
the key with your highlighter name and a colon. For example:
|
||||||
|
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green}
|
||||||
|
|
||||||
|
_zsh_highlight_highlighter_acme_paint() {
|
||||||
|
# Colorize the whole buffer with the 'aurora' style
|
||||||
|
_zsh_highlight_add_highlight 0 $#BUFFER acme:aurora
|
||||||
|
}
|
||||||
|
|
||||||
|
* Name your own functions and global variables `_zsh_highlight_acme_*`.
|
||||||
|
|
||||||
|
- In zsh-syntax-highlighting 0.4.0 and earlier, the entrypoints
|
||||||
|
`_zsh_highlight_highlighter_acme_predicate` and
|
||||||
|
`_zsh_highlight_highlighter_acme_paint`
|
||||||
|
were named
|
||||||
|
`_zsh_highlight_acme_highlighter_predicate` and
|
||||||
|
`_zsh_highlight_highlighter_acme_paint` respectively.
|
||||||
|
|
||||||
|
These names are still supported for backwards compatibility;
|
||||||
|
however, support for them will be removed in a a future major or minor release (v0.x.0 or v1.0.0).
|
||||||
|
|
||||||
|
* Activate your highlighter in `~/.zshrc`:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(acme)
|
||||||
|
|
||||||
|
* [Write tests](../tests/README.md).
|
||||||
29
docs/highlighters/brackets.md
Normal file
29
docs/highlighters/brackets.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / brackets
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
This is the `brackets` highlighter, that highlights brackets and parentheses, and
|
||||||
|
matches them.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
This highlighter defines the following styles:
|
||||||
|
|
||||||
|
* `bracket-error` - unmatched brackets
|
||||||
|
* `bracket-level-N` - brackets with nest level N
|
||||||
|
* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket
|
||||||
|
|
||||||
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
# To define styles for nested brackets up to level 4
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
22
docs/highlighters/cursor.md
Normal file
22
docs/highlighters/cursor.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / cursor
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
This is the `cursor` highlighter, that highlights the cursor.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
This highlighter defines the following styles:
|
||||||
|
|
||||||
|
* `cursor` - the style for the current cursor position
|
||||||
|
|
||||||
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
22
docs/highlighters/line.md
Normal file
22
docs/highlighters/line.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / line
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
This is the `line` highlighter, that highlights the whole line.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
This highlighter defines the following styles:
|
||||||
|
|
||||||
|
* `line` - the style for the whole line
|
||||||
|
|
||||||
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[line]='bold'
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
91
docs/highlighters/main.md
Normal file
91
docs/highlighters/main.md
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / main
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
This is the `main` highlighter, that highlights:
|
||||||
|
|
||||||
|
* Commands
|
||||||
|
* Options
|
||||||
|
* Arguments
|
||||||
|
* Paths
|
||||||
|
* Strings
|
||||||
|
|
||||||
|
This highlighter is active by default.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
This highlighter defines the following styles:
|
||||||
|
|
||||||
|
* `unknown-token` - unknown tokens / errors
|
||||||
|
* `reserved-word` - shell reserved words (`if`, `for`)
|
||||||
|
* `alias` - aliases
|
||||||
|
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
||||||
|
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
|
||||||
|
* `function` - function names
|
||||||
|
* `command` - command names
|
||||||
|
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
||||||
|
* `commandseparator` - command separation tokens (`;`, `&&`)
|
||||||
|
* `hashed-command` - hashed commands
|
||||||
|
* `path` - existing filenames
|
||||||
|
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
|
||||||
|
* `path_prefix` - prefixes of existing filenames
|
||||||
|
* `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default)
|
||||||
|
* `globbing` - globbing expressions (`*.txt`)
|
||||||
|
* `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`)
|
||||||
|
* `single-hyphen-option` - single hyphen options (`-o`)
|
||||||
|
* `double-hyphen-option` - double hyphen options (`--option`)
|
||||||
|
* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
|
||||||
|
* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
|
||||||
|
* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
|
||||||
|
* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
|
||||||
|
* `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
|
||||||
|
* `back-double-quoted-argument` - back double quoted arguments (`\x` inside `""`)
|
||||||
|
* `back-dollar-quoted-argument` - back dollar quoted arguments (`\x` inside `$''`)
|
||||||
|
* `assign` - parameter assignments
|
||||||
|
* `redirection` - redirection operators (`<`, `>`, etc)
|
||||||
|
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
|
||||||
|
* `arg0` - a command word other than one of those enumrated above (other than a command, precommand, alias, function, or shell builtin command).
|
||||||
|
* `default` - everything else
|
||||||
|
|
||||||
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
# Declare the variable
|
||||||
|
typeset -A ZSH_HIGHLIGHT_STYLES
|
||||||
|
|
||||||
|
# To differentiate aliases from other command types
|
||||||
|
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
|
||||||
|
|
||||||
|
# To have paths colored instead of underlined
|
||||||
|
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
||||||
|
|
||||||
|
# To disable highlighting of globbing expressions
|
||||||
|
ZSH_HIGHLIGHT_STYLES[globbing]='none'
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
### Useless trivia
|
||||||
|
|
||||||
|
#### Forward compatibility.
|
||||||
|
|
||||||
|
zsh-syntax-highlighting attempts to be forward-compatible with zsh.
|
||||||
|
Specifically, we attempt to facilitate highlighting _command word_ types that
|
||||||
|
had not yet been invented when this version of zsh-syntax-highlighting was
|
||||||
|
released.
|
||||||
|
|
||||||
|
A _command word_ is something like a function name, external command name, et
|
||||||
|
cetera. (See
|
||||||
|
[Simple Commands & Pipelines in `zshmisc(1)`][zshmisc-Simple-Commands-And-Pipelines]
|
||||||
|
for a formal definition.)
|
||||||
|
|
||||||
|
If a new _kind_ of command word is ever added to zsh — something conceptually
|
||||||
|
different than "function" and "alias" and "external command" — then command words
|
||||||
|
of that (new) kind will be highlighted by the style `arg0_$kind`,
|
||||||
|
where `$kind` is the output of `type -w` on the new kind of command word. If that
|
||||||
|
style is not defined, then the style `arg0` will be used instead.
|
||||||
|
|
||||||
|
[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
19
docs/highlighters/pattern.md
Normal file
19
docs/highlighters/pattern.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / pattern
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
This is the `pattern` highlighter, that highlights user-defined patterns.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
To use this highlighter, associate patterns with styles in the
|
||||||
|
`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
# To have commands starting with `rm -rf` in red:
|
||||||
|
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
23
docs/highlighters/root.md
Normal file
23
docs/highlighters/root.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
zsh-syntax-highlighting / highlighters / root
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
This is the `root` highlighter, that highlights the whole line if the current
|
||||||
|
user is root.
|
||||||
|
|
||||||
|
|
||||||
|
### How to tweak it
|
||||||
|
|
||||||
|
This highlighter defines the following styles:
|
||||||
|
|
||||||
|
* `root` - the style for the whole line if the current user is root.
|
||||||
|
|
||||||
|
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||||
|
for example in `~/.zshrc`:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[root]='bg=red'
|
||||||
|
|
||||||
|
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||||
|
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||||
|
manual page][zshzle-Character-Highlighting].
|
||||||
|
|
||||||
|
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
|
||||||
@@ -1,49 +1,8 @@
|
|||||||
zsh-syntax-highlighting / highlighters
|
zsh-syntax-highlighting / highlighters
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
Syntax highlighting is done by pluggable highlighters:
|
Navigate into the individual highlighters' documentation to see
|
||||||
|
what styles (`$ZSH_HIGHLIGHT_STYLES` keys) each highlighter defines.
|
||||||
|
|
||||||
* [***main***](highlighters/main) - the base highlighter, and the only one active by default.
|
Refer to the [documentation on highlighters](../docs/highlighters.md) for further
|
||||||
* [***brackets***](highlighters/brackets) - matches brackets and parenthesis.
|
information.
|
||||||
* [***pattern***](highlighters/pattern) - matches user-defined patterns.
|
|
||||||
* [***cursor***](highlighters/cursor) - matches the cursor position.
|
|
||||||
* [***root***](highlighters/root) - triggered if the current user is root.
|
|
||||||
|
|
||||||
|
|
||||||
How to activate highlighters
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in `~/.zshrc`, for example:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
|
||||||
|
|
||||||
|
|
||||||
How to tweak highlighters
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` array. Navigate into each highlighter directory to see what styles it defines and how to configure it.
|
|
||||||
|
|
||||||
|
|
||||||
How to implement a new highlighter
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
To create your own ***myhighlighter*** highlighter:
|
|
||||||
|
|
||||||
* Create your script at **highlighters/*myhighlighter*/*myhighlighter*-highlighter.zsh**.
|
|
||||||
* Implement the `_zsh_highlight_myhighlighter_highlighter_predicate` function. This function must return 0 when the highlighter needs to be called, for example:
|
|
||||||
|
|
||||||
_zsh_highlight_myhighlighter_highlighter_predicate() {
|
|
||||||
# Call this highlighter in SVN repositories
|
|
||||||
[[ -d .svn ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
* Implement the `_zsh_highlight_myhighlighter_highlighter` function. This function does the actual syntax highlighting, by modifying `region_highlight`, for example:
|
|
||||||
|
|
||||||
_zsh_highlight_myhighlighter_highlighter() {
|
|
||||||
# Colorize the whole buffer with blue background
|
|
||||||
region_highlight+=(0 $#BUFFER bg=blue)
|
|
||||||
}
|
|
||||||
|
|
||||||
* Activate your highlighter in `~/.zshrc`:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(myhighlighter)
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
zsh-syntax-highlighting / highlighters / brackets
|
|
||||||
=================================================
|
|
||||||
|
|
||||||
This is the ***brackets*** highlighter, that highlights brackets, parenthesis and matches them.
|
|
||||||
|
|
||||||
|
|
||||||
How to activate it
|
|
||||||
------------------
|
|
||||||
To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] brackets)
|
|
||||||
|
|
||||||
|
|
||||||
How to tweak it
|
|
||||||
---------------
|
|
||||||
This highlighter defines the following styles:
|
|
||||||
|
|
||||||
* `bracket-error` - unmatched brackets
|
|
||||||
* `bracket-level-N` - brackets with nest level N
|
|
||||||
* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket
|
|
||||||
|
|
||||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`:
|
|
||||||
|
|
||||||
# To define styles for nested brackets up to level 4
|
|
||||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
|
||||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
|
|
||||||
ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
|
|
||||||
ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
|
|
||||||
|
|
||||||
The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135).
|
|
||||||
1
highlighters/brackets/README.md
Symbolic link
1
highlighters/brackets/README.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../docs/highlighters/brackets.md
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -39,72 +38,70 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout}
|
: ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout}
|
||||||
|
|
||||||
# Whether the brackets highlighter should be called or not.
|
# Whether the brackets highlighter should be called or not.
|
||||||
_zsh_highlight_brackets_highlighter_predicate()
|
_zsh_highlight_highlighter_brackets_predicate()
|
||||||
{
|
{
|
||||||
_zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified
|
[[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified
|
||||||
}
|
}
|
||||||
|
|
||||||
# Brackets highlighting function.
|
# Brackets highlighting function.
|
||||||
_zsh_highlight_brackets_highlighter()
|
_zsh_highlight_highlighter_brackets_paint()
|
||||||
{
|
{
|
||||||
local level=0 pos
|
local char style
|
||||||
local -A levelpos lastoflevel matching typepos
|
local -i bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} buflen=${#BUFFER} level=0 matchingpos pos
|
||||||
|
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 = 0; $pos < ${#BUFFER}; pos++ )) ; do
|
for (( pos = 1; pos <= buflen; pos++ )) ; do
|
||||||
local char=$BUFFER[pos+1]
|
char=$BUFFER[pos]
|
||||||
case $char in
|
case $char in
|
||||||
["([{"])
|
["([{"])
|
||||||
levelpos[$pos]=$((++level))
|
levelpos[$pos]=$((++level))
|
||||||
lastoflevel[$level]=$pos
|
lastoflevel[$level]=$pos
|
||||||
_zsh_highlight_brackets_highlighter_brackettype $char
|
|
||||||
;;
|
;;
|
||||||
[")]}"])
|
[")]}"])
|
||||||
matching[$lastoflevel[$level]]=$pos
|
matchingpos=$lastoflevel[$level]
|
||||||
matching[$pos]=$lastoflevel[$level]
|
|
||||||
levelpos[$pos]=$((level--))
|
levelpos[$pos]=$((level--))
|
||||||
_zsh_highlight_brackets_highlighter_brackettype $char
|
if _zsh_highlight_brackets_match $matchingpos $pos; then
|
||||||
|
matching[$matchingpos]=$pos
|
||||||
|
matching[$pos]=$matchingpos
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
['"'\'])
|
['"'\'])
|
||||||
# Skip everything inside quotes
|
# Skip everything inside quotes
|
||||||
local quotetype=$char
|
pos=$BUFFER[(ib:pos+1:)$char]
|
||||||
while (( $pos < ${#BUFFER} )) ; do
|
|
||||||
(( pos++ ))
|
|
||||||
[[ $BUFFER[$pos+1] == $quotetype ]] && break
|
|
||||||
done
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Now highlight all found brackets
|
# Now highlight all found brackets
|
||||||
for pos in ${(k)levelpos}; do
|
for pos in ${(k)levelpos}; do
|
||||||
if [[ -n $matching[$pos] ]] && [[ $typepos[$pos] == $typepos[$matching[$pos]] ]]; then
|
if (( $+matching[$pos] )); then
|
||||||
local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]}
|
if (( bracket_color_size )); then
|
||||||
local bracket_color_level=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
|
style=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
|
||||||
local style=$ZSH_HIGHLIGHT_STYLES[$bracket_color_level]
|
fi
|
||||||
region_highlight+=("$pos $((pos + 1)) $style")
|
|
||||||
else
|
else
|
||||||
local style=$ZSH_HIGHLIGHT_STYLES[bracket-error]
|
style=bracket-error
|
||||||
region_highlight+=("$pos $((pos + 1)) $style")
|
|
||||||
fi
|
fi
|
||||||
|
_zsh_highlight_add_highlight $((pos - 1)) $pos $style
|
||||||
done
|
done
|
||||||
|
|
||||||
# If cursor is on a bracket, then highlight corresponding bracket, if any
|
# If cursor is on a bracket, then highlight corresponding bracket, if any.
|
||||||
pos=$CURSOR
|
if [[ $WIDGET != zle-line-finish ]]; then
|
||||||
if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then
|
pos=$((CURSOR + 1))
|
||||||
local otherpos=$matching[$pos]
|
if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then
|
||||||
local style=$ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]
|
local -i otherpos=$matching[$pos]
|
||||||
region_highlight+=("$otherpos $((otherpos + 1)) $style")
|
_zsh_highlight_add_highlight $((otherpos - 1)) $otherpos cursor-matchingbracket
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to differentiate type
|
# Helper function to differentiate type
|
||||||
_zsh_highlight_brackets_highlighter_brackettype()
|
_zsh_highlight_brackets_match()
|
||||||
{
|
{
|
||||||
case $1 in
|
case $BUFFER[$1] in
|
||||||
["()"]) typepos[$pos]=round;;
|
\() [[ $BUFFER[$2] == \) ]];;
|
||||||
["[]"]) typepos[$pos]=bracket;;
|
\[) [[ $BUFFER[$2] == \] ]];;
|
||||||
["{}"]) typepos[$pos]=curly;;
|
\{) [[ $BUFFER[$2] == \} ]];;
|
||||||
*) ;;
|
*) false;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
WIDGET=zle-line-finish
|
||||||
|
|
||||||
|
BUFFER=': $foo[bar]'
|
||||||
|
CURSOR=6 # cursor is zero-based
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"11 11 NONE"
|
||||||
|
)
|
||||||
39
highlighters/brackets/test-data/cursor-matchingbracket.zsh
Normal file
39
highlighters/brackets/test-data/cursor-matchingbracket.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
|
||||||
|
|
||||||
|
BUFFER=': ((( )))'
|
||||||
|
CURSOR=2 # cursor is zero-based
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"9 9 cursor-matchingbracket"
|
||||||
|
)
|
||||||
34
highlighters/brackets/test-data/empty-styles.zsh
Normal file
34
highlighters/brackets/test-data/empty-styles.zsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': (x)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 5 NONE"
|
||||||
|
)
|
||||||
51
highlighters/brackets/test-data/loop-styles.zsh
Normal file
51
highlighters/brackets/test-data/loop-styles.zsh
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
|
||||||
|
|
||||||
|
BUFFER=': ({[({[(x)]})]})'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 3 bracket-level-1"
|
||||||
|
"4 4 bracket-level-2"
|
||||||
|
"5 5 bracket-level-3"
|
||||||
|
"6 6 bracket-level-1"
|
||||||
|
"7 7 bracket-level-2"
|
||||||
|
"8 8 bracket-level-3"
|
||||||
|
"9 9 bracket-level-1"
|
||||||
|
"11 11 bracket-level-1"
|
||||||
|
"12 12 bracket-level-3"
|
||||||
|
"13 13 bracket-level-2"
|
||||||
|
"14 14 bracket-level-1"
|
||||||
|
"15 15 bracket-level-3"
|
||||||
|
"16 16 bracket-level-2"
|
||||||
|
"17 17 bracket-level-1"
|
||||||
|
)
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,11 +27,14 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x}]'
|
BUFFER='echo ({x}]'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # (
|
"6 6 bracket-error" # (
|
||||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
"7 7 bracket-level-2" # {
|
||||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
"9 9 bracket-level-2" # }
|
||||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # )
|
"10 10 bracket-error" # )
|
||||||
)
|
)
|
||||||
|
|||||||
38
highlighters/brackets/test-data/near-quotes.zsh
Normal file
38
highlighters/brackets/test-data/near-quotes.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
|
||||||
|
BUFFER=': {"{x}"}'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 3 bracket-level-1"
|
||||||
|
"4 8 NONE"
|
||||||
|
"9 9 bracket-level-1"
|
||||||
|
)
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,13 +27,17 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
|
||||||
|
|
||||||
BUFFER='echo $(echo ${(z)array})'
|
BUFFER='echo $(echo ${(z)array})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # (
|
"7 7 bracket-level-1" # (
|
||||||
"13 13 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
"14 14 bracket-level-2" # {
|
||||||
"14 14 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # (
|
"15 15 bracket-level-3" # (
|
||||||
"16 16 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # )
|
"17 17 bracket-level-3" # )
|
||||||
"22 22 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
"23 23 bracket-level-2" # }
|
||||||
"23 23 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # )
|
"24 24 bracket-level-1" # )
|
||||||
)
|
)
|
||||||
|
|||||||
36
highlighters/brackets/test-data/nested-quote.zsh
Normal file
36
highlighters/brackets/test-data/nested-quote.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
|
||||||
|
BUFFER=': "\"{x"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 9 NONE 'issue #303'"
|
||||||
|
)
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -31,5 +30,5 @@
|
|||||||
BUFFER='echo "foo ( bar"'
|
BUFFER='echo "foo ( bar"'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 15 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing
|
"1 16 NONE" # We expect the brackets highlighter to do nothing
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,11 +27,14 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x})'
|
BUFFER='echo ({x})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # (
|
"6 6 bracket-level-1" # (
|
||||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
"7 7 bracket-level-2" # {
|
||||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
"9 9 bracket-level-2" # }
|
||||||
"9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # )
|
"10 10 bracket-level-1" # )
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,10 +27,13 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x}'
|
BUFFER='echo ({x}'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # (
|
"6 6 bracket-error" # (
|
||||||
"6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # {
|
"7 7 bracket-level-2" # {
|
||||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # }
|
"9 9 bracket-level-2" # }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,10 +27,12 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
|
||||||
BUFFER='echo {x})'
|
BUFFER='echo {x})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # {
|
"6 6 bracket-level-1" # {
|
||||||
"7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # }
|
"8 8 bracket-level-1" # }
|
||||||
"8 8 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # )
|
"9 9 bracket-error" # )
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
zsh-syntax-highlighting / highlighters / cursor
|
|
||||||
=================================================
|
|
||||||
|
|
||||||
This is the ***cursor*** highlighter, that highlights the cursor.
|
|
||||||
|
|
||||||
|
|
||||||
How to activate it
|
|
||||||
------------------
|
|
||||||
To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] cursor)
|
|
||||||
|
|
||||||
|
|
||||||
How to tweak it
|
|
||||||
---------------
|
|
||||||
This highlighter defines the following styles:
|
|
||||||
|
|
||||||
* `cursor` - the style for the current cursor position
|
|
||||||
|
|
||||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
|
|
||||||
|
|
||||||
The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135).
|
|
||||||
1
highlighters/cursor/README.md
Symbolic link
1
highlighters/cursor/README.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../docs/highlighters/cursor.md
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
@@ -33,13 +32,16 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout}
|
: ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout}
|
||||||
|
|
||||||
# Whether the cursor highlighter should be called or not.
|
# Whether the cursor highlighter should be called or not.
|
||||||
_zsh_highlight_cursor_highlighter_predicate()
|
_zsh_highlight_highlighter_cursor_predicate()
|
||||||
{
|
{
|
||||||
_zsh_highlight_cursor_moved
|
# remove cursor highlighting when the line is finished
|
||||||
|
[[ $WIDGET == zle-line-finish ]] || _zsh_highlight_cursor_moved
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cursor highlighting function.
|
# Cursor highlighting function.
|
||||||
_zsh_highlight_cursor_highlighter()
|
_zsh_highlight_highlighter_cursor_paint()
|
||||||
{
|
{
|
||||||
region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]")
|
[[ $WIDGET == zle-line-finish ]] && return
|
||||||
|
|
||||||
|
_zsh_highlight_add_highlight $CURSOR $(( $CURSOR + 1 )) cursor
|
||||||
}
|
}
|
||||||
|
|||||||
1
highlighters/line/README.md
Symbolic link
1
highlighters/line/README.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../docs/highlighters/line.md
|
||||||
44
highlighters/line/line-highlighter.zsh
Normal file
44
highlighters/line/line-highlighter.zsh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# Define default styles.
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[line]:=}
|
||||||
|
|
||||||
|
# Whether the root highlighter should be called or not.
|
||||||
|
_zsh_highlight_highlighter_line_predicate()
|
||||||
|
{
|
||||||
|
_zsh_highlight_buffer_modified
|
||||||
|
}
|
||||||
|
|
||||||
|
# root highlighting function.
|
||||||
|
_zsh_highlight_highlighter_line_paint()
|
||||||
|
{
|
||||||
|
_zsh_highlight_add_highlight 0 $#BUFFER line
|
||||||
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
zsh-syntax-highlighting / highlighters / main
|
|
||||||
=============================================
|
|
||||||
|
|
||||||
This is the ***main*** highlighter, that highlights:
|
|
||||||
|
|
||||||
* Commands
|
|
||||||
* Options
|
|
||||||
* Arguments
|
|
||||||
* Paths
|
|
||||||
* Strings
|
|
||||||
|
|
||||||
How to activate it
|
|
||||||
------------------
|
|
||||||
To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`:
|
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] main)
|
|
||||||
|
|
||||||
This highlighter is active by default.
|
|
||||||
|
|
||||||
|
|
||||||
How to tweak it
|
|
||||||
---------------
|
|
||||||
This highlighter defines the following styles:
|
|
||||||
|
|
||||||
* `unknown-token` - unknown tokens / errors
|
|
||||||
* `reserved-word` - shell reserved words
|
|
||||||
* `alias` - aliases
|
|
||||||
* `builtin` - shell builtin commands
|
|
||||||
* `function` - functions
|
|
||||||
* `command` - commands
|
|
||||||
* `precommand` - precommands (i.e. exec, builtin, ...)
|
|
||||||
* `commandseparator` - command separation tokens
|
|
||||||
* `hashed-command` - hashed commands
|
|
||||||
* `path` - paths
|
|
||||||
* `globbing` - globbing expressions
|
|
||||||
* `history-expansion` - history expansion expressions
|
|
||||||
* `single-hyphen-option` - single hyphen options
|
|
||||||
* `double-hyphen-option` - double hyphen options
|
|
||||||
* `back-quoted-argument` - backquoted expressions
|
|
||||||
* `single-quoted-argument` - single quoted arguments
|
|
||||||
* `double-quoted-argument` - double quoted arguments
|
|
||||||
* `dollar-double-quoted-argument` - dollar double quoted arguments
|
|
||||||
* `back-double-quoted-argument` - back double quoted arguments
|
|
||||||
* `assign` - variable assignments
|
|
||||||
* `default` - parts of the buffer that do not match anything
|
|
||||||
|
|
||||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`:
|
|
||||||
|
|
||||||
# To differentiate aliases from other command types
|
|
||||||
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
|
|
||||||
|
|
||||||
# To have paths colored instead of underlined
|
|
||||||
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
|
||||||
|
|
||||||
# To disable highlighting of globbing expressions
|
|
||||||
ZSH_HIGHLIGHT_STYLES[globbing]='none'
|
|
||||||
|
|
||||||
The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135).
|
|
||||||
1
highlighters/main/README.md
Symbolic link
1
highlighters/main/README.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../docs/highlighters/main.md
|
||||||
865
highlighters/main/main-highlighter.zsh
Executable file → Normal file
865
highlighters/main/main-highlighter.zsh
Executable file → Normal file
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -33,14 +32,12 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[default]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[default]:=none}
|
||||||
: ${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[alias]:=fg=green}
|
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[builtin]:=fg=green}
|
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[function]:=fg=green}
|
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[command]:=fg=green}
|
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green}
|
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
|
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
|
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none}
|
||||||
@@ -48,118 +45,733 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
|
: ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
|
: ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
|
: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
|
||||||
: ${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[assign]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
|
||||||
|
|
||||||
# Whether the highlighter should be called or not.
|
# Whether the highlighter should be called or not.
|
||||||
_zsh_highlight_main_highlighter_predicate()
|
_zsh_highlight_highlighter_main_predicate()
|
||||||
{
|
{
|
||||||
_zsh_highlight_buffer_modified
|
# may need to remove path_prefix highlighting when the line ends
|
||||||
|
[[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper to deal with tokens crossing line boundaries.
|
||||||
|
_zsh_highlight_main_add_region_highlight() {
|
||||||
|
integer start=$1 end=$2
|
||||||
|
shift 2
|
||||||
|
|
||||||
|
if (( $+argv[2] )); then
|
||||||
|
# Caller specified inheritance explicitly.
|
||||||
|
else
|
||||||
|
# Automate inheritance.
|
||||||
|
typeset -A fallback_of; fallback_of=(
|
||||||
|
alias arg0
|
||||||
|
suffix-alias arg0
|
||||||
|
builtin arg0
|
||||||
|
function arg0
|
||||||
|
command arg0
|
||||||
|
precommand arg0
|
||||||
|
hashed-command arg0
|
||||||
|
|
||||||
|
path_prefix path
|
||||||
|
# The path separator fallback won't ever be used, due to the optimisation
|
||||||
|
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
||||||
|
path_pathseparator path
|
||||||
|
path_prefix_pathseparator path_prefix
|
||||||
|
)
|
||||||
|
local needle=$1 value
|
||||||
|
while [[ -n ${value::=$fallback_of[$needle]} ]]; do
|
||||||
|
unset "fallback_of[$needle]" # paranoia against infinite loops
|
||||||
|
argv+=($value)
|
||||||
|
needle=$value
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
|
||||||
|
# relative to $BUFFER.
|
||||||
|
(( start -= $#PREBUFFER ))
|
||||||
|
(( end -= $#PREBUFFER ))
|
||||||
|
|
||||||
|
(( end < 0 )) && return # having end<0 would be a bug
|
||||||
|
(( start < 0 )) && start=0 # having start<0 is normal with e.g. multiline strings
|
||||||
|
_zsh_highlight_add_highlight $start $end "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the type of a command.
|
||||||
|
#
|
||||||
|
# Uses the zsh/parameter module if available to avoid forks, and a
|
||||||
|
# wrapper around 'type -w' as fallback.
|
||||||
|
#
|
||||||
|
# Takes a single argument.
|
||||||
|
#
|
||||||
|
# The result will be stored in REPLY.
|
||||||
|
_zsh_highlight_main__type() {
|
||||||
|
if (( $+_zsh_highlight_main__command_type_cache )); then
|
||||||
|
REPLY=$_zsh_highlight_main__command_type_cache[(e)$1]
|
||||||
|
if [[ -n "$REPLY" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( $#options_to_set )); then
|
||||||
|
setopt localoptions $options_to_set;
|
||||||
|
fi
|
||||||
|
unset REPLY
|
||||||
|
if zmodload -e zsh/parameter; then
|
||||||
|
if (( $+aliases[(e)$1] )); then
|
||||||
|
REPLY=alias
|
||||||
|
elif (( $+saliases[(e)${1##*.}] )); then
|
||||||
|
REPLY='suffix alias'
|
||||||
|
elif (( $reswords[(Ie)$1] )); then
|
||||||
|
REPLY=reserved
|
||||||
|
elif (( $+functions[(e)$1] )); then
|
||||||
|
REPLY=function
|
||||||
|
elif (( $+builtins[(e)$1] )); then
|
||||||
|
REPLY=builtin
|
||||||
|
elif (( $+commands[(e)$1] )); then
|
||||||
|
REPLY=command
|
||||||
|
# zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly
|
||||||
|
# runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo
|
||||||
|
# exists and is in $PATH). Avoid triggering the bug, at the expense of
|
||||||
|
# falling through to the $() below, incurring a fork. (Issue #354.)
|
||||||
|
#
|
||||||
|
# The first disjunct mimics the isrelative() C call from the zsh bug.
|
||||||
|
elif { [[ $1 != */* ]] || is-at-least 5.3 } &&
|
||||||
|
! builtin type -w -- $1 >/dev/null 2>&1; then
|
||||||
|
REPLY=none
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if ! (( $+REPLY )); then
|
||||||
|
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }"
|
||||||
|
fi
|
||||||
|
if (( $+_zsh_highlight_main__command_type_cache )); then
|
||||||
|
_zsh_highlight_main__command_type_cache[(e)$1]=$REPLY
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check whether the first argument is a redirection operator token.
|
||||||
|
# Report result via the exit code.
|
||||||
|
_zsh_highlight_main__is_redirection() {
|
||||||
|
# A redirection operator token:
|
||||||
|
# - starts with an optional single-digit number;
|
||||||
|
# - then, has a '<' or '>' character;
|
||||||
|
# - is not a process substitution [<(...) or >(...)].
|
||||||
|
[[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Resolve alias.
|
||||||
|
#
|
||||||
|
# Takes a single argument.
|
||||||
|
#
|
||||||
|
# The result will be stored in REPLY.
|
||||||
|
_zsh_highlight_main__resolve_alias() {
|
||||||
|
if zmodload -e zsh/parameter; then
|
||||||
|
REPLY=${aliases[$arg]}
|
||||||
|
else
|
||||||
|
REPLY="${"$(alias -- $arg)"#*=}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# $1: character expected to be at the top of $braces_stack
|
||||||
|
# $2: assignment to execute it if matches
|
||||||
|
_zsh_highlight_main__stack_pop() {
|
||||||
|
if [[ $braces_stack[1] == $1 ]]; then
|
||||||
|
braces_stack=${braces_stack:1}
|
||||||
|
eval "$2"
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main syntax highlighting function.
|
# Main syntax highlighting function.
|
||||||
_zsh_highlight_main_highlighter()
|
_zsh_highlight_highlighter_main_paint()
|
||||||
{
|
{
|
||||||
|
## Before we even 'emulate -L', we must test a few options that would reset.
|
||||||
|
if [[ -o interactive_comments ]]; then
|
||||||
|
local interactive_comments= # set to empty
|
||||||
|
fi
|
||||||
|
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
|
||||||
|
local right_brace_is_recognised_everywhere=false
|
||||||
|
else
|
||||||
|
local right_brace_is_recognised_everywhere=true
|
||||||
|
fi
|
||||||
|
if [[ -o path_dirs ]]; then
|
||||||
|
integer path_dirs_was_set=1
|
||||||
|
else
|
||||||
|
integer path_dirs_was_set=0
|
||||||
|
fi
|
||||||
|
if [[ -o multi_func_def ]]; then
|
||||||
|
integer multi_func_def=1
|
||||||
|
else
|
||||||
|
integer multi_func_def=0
|
||||||
|
fi
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt localoptions extendedglob bareglobqual
|
setopt localoptions extendedglob bareglobqual
|
||||||
local start_pos=0 end_pos highlight_glob=true new_expression=true arg style
|
|
||||||
|
# At the PS3 prompt and in vared, highlight nothing.
|
||||||
|
#
|
||||||
|
# (We can't check this in _zsh_highlight_highlighter_main_predicate because
|
||||||
|
# if the predicate returns false, the previous value of region_highlight
|
||||||
|
# would be reused.)
|
||||||
|
if [[ $CONTEXT == (select|vared) ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Variable declarations and initializations
|
||||||
|
local start_pos=0 end_pos highlight_glob=true arg style
|
||||||
|
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS
|
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
|
||||||
region_highlight=()
|
local -a options_to_set # used in callees
|
||||||
|
local buf="$PREBUFFER$BUFFER"
|
||||||
|
integer len="${#buf}"
|
||||||
|
integer pure_buf_len=$(( len - ${#PREBUFFER} )) # == $#BUFFER, used e.g. in *_check_path
|
||||||
|
|
||||||
|
# "R" for round
|
||||||
|
# "Q" for square
|
||||||
|
# "Y" for curly
|
||||||
|
# "D" for do/done
|
||||||
|
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
||||||
|
local braces_stack
|
||||||
|
|
||||||
|
if (( path_dirs_was_set )); then
|
||||||
|
options_to_set+=( PATH_DIRS )
|
||||||
|
fi
|
||||||
|
unset path_dirs_was_set
|
||||||
|
|
||||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||||
'|' '||' ';' '&' '&&'
|
'|' '||' ';' '&' '&&'
|
||||||
|
'|&'
|
||||||
|
'&!' '&|'
|
||||||
|
# ### 'case' syntax, but followed by a pattern, not by a command
|
||||||
|
# ';;' ';&' ';|'
|
||||||
)
|
)
|
||||||
ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=(
|
ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=(
|
||||||
'builtin' 'command' 'exec' 'nocorrect' 'noglob'
|
'builtin' 'command' 'exec' 'nocorrect' 'noglob'
|
||||||
)
|
'pkexec' # immune to #121 because it's usually not passed --option flags
|
||||||
# Tokens that are always immediately followed by a command.
|
|
||||||
ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS=(
|
|
||||||
$ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for arg in ${(z)BUFFER}; do
|
# Tokens that, at (naively-determined) "command position", are followed by
|
||||||
local substr_color=0
|
# a de jure command position. All of these are reserved words.
|
||||||
[[ $start_pos -eq 0 && $arg = 'noglob' ]] && highlight_glob=false
|
ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW=(
|
||||||
((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]##[[:space:]]#}}))
|
$'\x7b' # block
|
||||||
((end_pos=$start_pos+${#arg}))
|
$'\x28' # subshell
|
||||||
if $new_expression; then
|
'()' # anonymous function
|
||||||
new_expression=false
|
'while'
|
||||||
|
'until'
|
||||||
|
'if'
|
||||||
|
'then'
|
||||||
|
'elif'
|
||||||
|
'else'
|
||||||
|
'do'
|
||||||
|
'time'
|
||||||
|
'coproc'
|
||||||
|
'!' # reserved word; unrelated to $histchars[1]
|
||||||
|
)
|
||||||
|
|
||||||
|
local -a match mbegin mend
|
||||||
|
|
||||||
|
# State machine
|
||||||
|
#
|
||||||
|
# The states are:
|
||||||
|
# - :start: Command word
|
||||||
|
# - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i")
|
||||||
|
# - :sudo_arg: The argument to a sudo leading-dash option that takes one,
|
||||||
|
# when given as a separate word; i.e., "foo" in "-u foo" (two
|
||||||
|
# words) but not in "-ufoo" (one word).
|
||||||
|
# - :regular: "Not a command word", and command delimiters are permitted.
|
||||||
|
# Mainly used to detect premature termination of commands.
|
||||||
|
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
|
||||||
|
#
|
||||||
|
# When the kind of a word is not yet known, $this_word / $next_word may contain
|
||||||
|
# multiple states. For example, after "sudo -i", the next word may be either
|
||||||
|
# another --flag or a command name, hence the state would include both :start:
|
||||||
|
# and :sudo_opt:.
|
||||||
|
#
|
||||||
|
# The tokens are always added with both leading and trailing colons to serve as
|
||||||
|
# word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/}
|
||||||
|
# will DTRT regardless of how many elements or repetitions $x has..
|
||||||
|
#
|
||||||
|
# Handling of redirections: upon seeing a redirection token, we must stall
|
||||||
|
# the current state --- that is, the value of $this_word --- for two iterations
|
||||||
|
# (one for the redirection operator, one for the word following it representing
|
||||||
|
# the redirection target). Therefore, we set $in_redirection to 2 upon seeing a
|
||||||
|
# redirection operator, decrement it each iteration, and stall the current state
|
||||||
|
# when it is non-zero. Thus, upon reaching the next word (the one that follows
|
||||||
|
# the redirection operator and target), $this_word will still contain values
|
||||||
|
# appropriate for the word immediately following the word that preceded the
|
||||||
|
# redirection operator.
|
||||||
|
#
|
||||||
|
# The "the previous word was a redirection operator" state is not communicated
|
||||||
|
# to the next iteration via $next_word/$this_word as usual, but via
|
||||||
|
# $in_redirection. The value of $next_word from the iteration that processed
|
||||||
|
# the operator is discarded.
|
||||||
|
#
|
||||||
|
local this_word=':start:' next_word
|
||||||
|
integer in_redirection
|
||||||
|
# Processing buffer
|
||||||
|
local proc_buf="$buf"
|
||||||
|
for arg in ${interactive_comments-${(z)buf}} \
|
||||||
|
${interactive_comments+${(zZ+c+)buf}}; do
|
||||||
|
# Initialize $next_word.
|
||||||
|
if (( in_redirection )); then
|
||||||
|
(( --in_redirection ))
|
||||||
|
fi
|
||||||
|
if (( in_redirection == 0 )); then
|
||||||
|
# Initialize $next_word to its default value.
|
||||||
|
next_word=':regular:'
|
||||||
|
else
|
||||||
|
# Stall $next_word.
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize per-"simple command" [zshmisc(1)] variables:
|
||||||
|
#
|
||||||
|
# $already_added (see next paragraph)
|
||||||
|
# $style how to highlight $arg
|
||||||
|
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
|
||||||
|
# $highlight_glob boolean flag for "'noglob' is in effect"
|
||||||
|
#
|
||||||
|
# $already_added is set to 1 to disable adding an entry to region_highlight
|
||||||
|
# for this iteration. Currently, that is done for "" and $'' strings,
|
||||||
|
# which add the entry early so escape sequences within the string override
|
||||||
|
# the string's color.
|
||||||
|
integer already_added=0
|
||||||
|
style=unknown-token
|
||||||
|
if [[ $this_word == *':start:'* ]]; then
|
||||||
|
in_array_assignment=false
|
||||||
|
if [[ $arg == 'noglob' ]]; then
|
||||||
|
highlight_glob=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
|
||||||
|
if [[ $arg == ';' ]] ; then
|
||||||
|
# We're looking for either a semicolon or a newline, whichever comes
|
||||||
|
# first. Both of these are rendered as a ";" (SEPER) by the ${(z)..}
|
||||||
|
# flag.
|
||||||
|
#
|
||||||
|
# We can't use the (Z+n+) flag because that elides the end-of-command
|
||||||
|
# token altogether, so 'echo foo\necho bar' (two commands) becomes
|
||||||
|
# indistinguishable from 'echo foo echo bar' (one command with three
|
||||||
|
# words for arguments).
|
||||||
|
local needle=$'[;\n]'
|
||||||
|
integer offset=$(( ${proc_buf[(i)$needle]} - 1 ))
|
||||||
|
(( start_pos += offset ))
|
||||||
|
(( end_pos = start_pos + $#arg ))
|
||||||
|
else
|
||||||
|
# The line was:
|
||||||
|
#
|
||||||
|
# integer offset=$(((len-start_pos)-${#${proc_buf##([[:space:]]|\\[[:space:]])#}}))
|
||||||
|
#
|
||||||
|
# - len-start_pos is length of current proc_buf; basically: initial length minus where
|
||||||
|
# we are, and proc_buf is chopped to the "where we are" (compare the "previous value
|
||||||
|
# of start_pos" below, and the len-(start_pos-offset) = len-start_pos+offset)
|
||||||
|
# - what's after main minus sign is: length of proc_buf without spaces at the beginning
|
||||||
|
# - so what the line actually did, was computing length of the spaces!
|
||||||
|
# - this can be done via (#b) flag, like below
|
||||||
|
if [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then
|
||||||
|
# The first, outer parenthesis
|
||||||
|
integer offset="${#match[1]}"
|
||||||
|
else
|
||||||
|
integer offset=0
|
||||||
|
fi
|
||||||
|
((start_pos+=offset))
|
||||||
|
((end_pos=$start_pos+${#arg}))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compute the new $proc_buf. We advance it
|
||||||
|
# (chop off characters from the beginning)
|
||||||
|
# beyond what end_pos points to, by skipping
|
||||||
|
# as many characters as end_pos was advanced.
|
||||||
|
#
|
||||||
|
# end_pos was advanced by $offset (via start_pos)
|
||||||
|
# and by $#arg. Note the `start_pos=$end_pos`
|
||||||
|
# below.
|
||||||
|
#
|
||||||
|
# As for the [,len]. We could use [,len-start_pos+offset]
|
||||||
|
# here, but to make it easier on eyes, we use len and
|
||||||
|
# rely on the fact that Zsh simply handles that. The
|
||||||
|
# length of proc_buf is len-start_pos+offset because
|
||||||
|
# we're chopping it to match current start_pos, so its
|
||||||
|
# length matches the previous value of start_pos.
|
||||||
|
#
|
||||||
|
# Why [,-1] is slower than [,length] isn't clear.
|
||||||
|
proc_buf="${proc_buf[offset + $#arg + 1,len]}"
|
||||||
|
|
||||||
|
# Handle the INTERACTIVE_COMMENTS option.
|
||||||
|
#
|
||||||
|
# We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
|
||||||
|
if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then
|
||||||
|
if [[ $this_word == *(':regular:'|':start:')* ]]; then
|
||||||
|
style=comment
|
||||||
|
else
|
||||||
|
style=unknown-token # prematurely terminated
|
||||||
|
fi
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
|
already_added=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Analyse the current word.
|
||||||
|
if _zsh_highlight_main__is_redirection $arg ; then
|
||||||
|
# A '<' or '>', possibly followed by a digit
|
||||||
|
in_redirection=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Special-case the first word after 'sudo'.
|
||||||
|
if (( ! in_redirection )); then
|
||||||
|
if [[ $this_word == *':sudo_opt:'* ]] && [[ $arg != -* ]]; then
|
||||||
|
this_word=${this_word//:sudo_opt:/}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse the sudo command line
|
||||||
|
if (( ! in_redirection )); then
|
||||||
|
if [[ $this_word == *':sudo_opt:'* ]]; then
|
||||||
|
case "$arg" in
|
||||||
|
# Flag that requires an argument
|
||||||
|
'-'[Cgprtu]) this_word=${this_word//:start:/};
|
||||||
|
next_word=':sudo_arg:';;
|
||||||
|
# This prevents misbehavior with sudo -u -otherargument
|
||||||
|
'-'*) this_word=${this_word//:start:/};
|
||||||
|
next_word+=':start:';
|
||||||
|
next_word+=':sudo_opt:';;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
elif [[ $this_word == *':sudo_arg:'* ]]; then
|
||||||
|
next_word+=':sudo_opt:'
|
||||||
|
next_word+=':start:'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The Great Fork: is this a command word? Is this a non-command word?
|
||||||
|
if [[ $this_word == *':always:'* && $arg == 'always' ]]; then
|
||||||
|
# try-always construct
|
||||||
|
style=reserved-word # de facto a reserved word, although not de jure
|
||||||
|
next_word=':start:'
|
||||||
|
elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word
|
||||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[precommand]
|
style=precommand
|
||||||
|
elif [[ "$arg" = "sudo" ]]; then
|
||||||
|
style=precommand
|
||||||
|
next_word=${next_word//:regular:/}
|
||||||
|
next_word+=':sudo_opt:'
|
||||||
|
next_word+=':start:'
|
||||||
else
|
else
|
||||||
res=$(LC_ALL=C builtin type -w $arg 2>/dev/null)
|
_zsh_highlight_main_highlighter_expand_path $arg
|
||||||
|
local expanded_arg="$REPLY"
|
||||||
|
_zsh_highlight_main__type ${expanded_arg}
|
||||||
|
local res="$REPLY"
|
||||||
|
() {
|
||||||
|
# Special-case: command word is '$foo', like that, without braces or anything.
|
||||||
|
#
|
||||||
|
# That's not entirely correct --- if the parameter's value happens to be a reserved
|
||||||
|
# word, the parameter expansion will be highlighted as a reserved word --- but that
|
||||||
|
# incorrectness is outweighed by the usability improvement of permitting the use of
|
||||||
|
# parameters that refer to commands, functions, and builtins.
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
|
if [[ $res == none ]] && (( ${+parameters} )) &&
|
||||||
|
[[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]] &&
|
||||||
|
(( ${+parameters[${MATCH}]} ))
|
||||||
|
then
|
||||||
|
_zsh_highlight_main__type ${(P)MATCH}
|
||||||
|
res=$REPLY
|
||||||
|
fi
|
||||||
|
}
|
||||||
case $res in
|
case $res in
|
||||||
*': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];;
|
reserved) # reserved word
|
||||||
*': alias') style=$ZSH_HIGHLIGHT_STYLES[alias]
|
style=reserved-word
|
||||||
local aliased_command="${"$(alias $arg)"#*=}"
|
case $arg in
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS+=($arg)
|
($'\x7b')
|
||||||
|
braces_stack='Y'"$braces_stack"
|
||||||
|
;;
|
||||||
|
($'\x7d')
|
||||||
|
# We're at command word, so no need to check $right_brace_is_recognised_everywhere
|
||||||
|
_zsh_highlight_main__stack_pop 'Y' style=reserved-word
|
||||||
|
if [[ $style == reserved-word ]]; then
|
||||||
|
next_word+=':always:'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
('do')
|
||||||
|
braces_stack='D'"$braces_stack"
|
||||||
|
;;
|
||||||
|
('done')
|
||||||
|
_zsh_highlight_main__stack_pop 'D' style=reserved-word
|
||||||
|
;;
|
||||||
|
('foreach')
|
||||||
|
braces_stack='$'"$braces_stack"
|
||||||
|
;;
|
||||||
|
('end')
|
||||||
|
_zsh_highlight_main__stack_pop '$' style=reserved-word
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
*': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];;
|
'suffix alias') style=suffix-alias;;
|
||||||
*': function') style=$ZSH_HIGHLIGHT_STYLES[function];;
|
alias) () {
|
||||||
*': command') style=$ZSH_HIGHLIGHT_STYLES[command];;
|
integer insane_alias
|
||||||
*': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];;
|
case $arg in
|
||||||
*) if _zsh_highlight_main_highlighter_check_assign; then
|
# Issue #263: aliases with '=' on their LHS.
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[assign]
|
#
|
||||||
new_expression=true
|
# There are three cases:
|
||||||
elif _zsh_highlight_main_highlighter_check_path; then
|
#
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
# - Unsupported, breaks 'alias -L' output, but invokable:
|
||||||
elif [[ $arg[0,1] = $histchars[0,1] ]]; then
|
('='*) :;;
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
# - Unsupported, not invokable:
|
||||||
|
(*'='*) insane_alias=1;;
|
||||||
|
# - The common case:
|
||||||
|
(*) :;;
|
||||||
|
esac
|
||||||
|
if (( insane_alias )); then
|
||||||
|
style=unknown-token
|
||||||
|
else
|
||||||
|
style=alias
|
||||||
|
_zsh_highlight_main__resolve_alias $arg
|
||||||
|
local alias_target="$REPLY"
|
||||||
|
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
builtin) style=builtin;;
|
||||||
|
function) style=function;;
|
||||||
|
command) style=command;;
|
||||||
|
hashed) style=hashed-command;;
|
||||||
|
none) if _zsh_highlight_main_highlighter_check_assign; then
|
||||||
|
style=assign
|
||||||
|
if [[ $arg[-1] == '(' ]]; then
|
||||||
|
in_array_assignment=true
|
||||||
|
else
|
||||||
|
# assignment to a scalar parameter.
|
||||||
|
# (For array assignments, the command doesn't start until the ")" token.)
|
||||||
|
next_word+=':start:'
|
||||||
|
fi
|
||||||
|
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
||||||
|
style=history-expansion
|
||||||
|
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
|
||||||
|
style=history-expansion
|
||||||
|
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
||||||
|
if [[ $this_word == *':regular:'* ]]; then
|
||||||
|
# This highlights empty commands (semicolon follows nothing) as an error.
|
||||||
|
# Zsh accepts them, though.
|
||||||
|
style=commandseparator
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
|
elif (( in_redirection == 2 )); then
|
||||||
|
style=redirection
|
||||||
|
elif [[ $arg[1,2] == '((' ]]; then
|
||||||
|
# Arithmetic evaluation.
|
||||||
|
#
|
||||||
|
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
|
||||||
|
# splitter would only output the '((' token if the matching '))' had
|
||||||
|
# been typed. Therefore, under those versions of zsh, BUFFER="(( 42"
|
||||||
|
# would be highlighted as an error until the matching "))" are typed.
|
||||||
|
#
|
||||||
|
# We highlight just the opening parentheses, as a reserved word; this
|
||||||
|
# is how [[ ... ]] is highlighted, too.
|
||||||
|
style=reserved-word
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $((start_pos + 2)) $style
|
||||||
|
already_added=1
|
||||||
|
if [[ $arg[-2,-1] == '))' ]]; then
|
||||||
|
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos $style
|
||||||
|
already_added=1
|
||||||
|
fi
|
||||||
|
elif [[ $arg == '()' ]]; then
|
||||||
|
# anonymous function
|
||||||
|
style=reserved-word
|
||||||
|
elif [[ $arg == $'\x28' ]]; then
|
||||||
|
# subshell
|
||||||
|
style=reserved-word
|
||||||
|
braces_stack='R'"$braces_stack"
|
||||||
|
elif [[ $arg == $'\x29' ]]; then
|
||||||
|
# end of subshell
|
||||||
|
_zsh_highlight_main__stack_pop 'R' style=reserved-word
|
||||||
else
|
else
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
|
if _zsh_highlight_main_highlighter_check_path; then
|
||||||
|
style=$REPLY
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res arg0
|
||||||
|
already_added=1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
|
if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath
|
||||||
|
{ (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] }
|
||||||
|
then # $arg is a non-command word
|
||||||
case $arg in
|
case $arg in
|
||||||
'--'*) style=$ZSH_HIGHLIGHT_STYLES[double-hyphen-option];;
|
$'\x29') # subshell or end of array assignment
|
||||||
'-'*) style=$ZSH_HIGHLIGHT_STYLES[single-hyphen-option];;
|
if $in_array_assignment; then
|
||||||
"'"*"'") style=$ZSH_HIGHLIGHT_STYLES[single-quoted-argument];;
|
style=assign
|
||||||
'"'*'"') style=$ZSH_HIGHLIGHT_STYLES[double-quoted-argument]
|
in_array_assignment=false
|
||||||
region_highlight+=("$start_pos $end_pos $style")
|
next_word+=':start:'
|
||||||
_zsh_highlight_main_highlighter_highlight_string
|
|
||||||
substr_color=1
|
|
||||||
;;
|
|
||||||
'`'*'`') style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];;
|
|
||||||
*"*"*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];;
|
|
||||||
*) if _zsh_highlight_main_highlighter_check_path; then
|
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[path]
|
|
||||||
elif [[ $arg[0,1] = $histchars[0,1] ]]; then
|
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[history-expansion]
|
|
||||||
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[commandseparator]
|
|
||||||
else
|
else
|
||||||
style=$ZSH_HIGHLIGHT_STYLES[default]
|
_zsh_highlight_main__stack_pop 'R' style=reserved-word
|
||||||
|
fi;;
|
||||||
|
$'\x28\x29') # possibly a function definition
|
||||||
|
if (( multi_func_def )) || false # TODO: or if the previous word was a command word
|
||||||
|
then
|
||||||
|
next_word+=':start:'
|
||||||
|
fi
|
||||||
|
style=reserved-word
|
||||||
|
;;
|
||||||
|
$'\x7d') # right brace
|
||||||
|
#
|
||||||
|
# Parsing rule: # {
|
||||||
|
#
|
||||||
|
# Additionally, `tt(})' is recognized in any position if neither the
|
||||||
|
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set."""
|
||||||
|
if $right_brace_is_recognised_everywhere; then
|
||||||
|
_zsh_highlight_main__stack_pop 'Y' style=reserved-word
|
||||||
|
if [[ $style == reserved-word ]]; then
|
||||||
|
next_word+=':always:'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Fall through to the catchall case at the end.
|
||||||
|
fi
|
||||||
|
;|
|
||||||
|
'--'*) style=double-hyphen-option;;
|
||||||
|
'-'*) style=single-hyphen-option;;
|
||||||
|
"'"*) style=single-quoted-argument;;
|
||||||
|
'"'*) style=double-quoted-argument
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
|
_zsh_highlight_main_highlighter_highlight_string
|
||||||
|
already_added=1
|
||||||
|
;;
|
||||||
|
\$\'*) style=dollar-quoted-argument
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
|
_zsh_highlight_main_highlighter_highlight_dollar_string
|
||||||
|
already_added=1
|
||||||
|
;;
|
||||||
|
'`'*) style=back-quoted-argument;;
|
||||||
|
[*?]*|*[^\\][*?]*)
|
||||||
|
$highlight_glob && style=globbing || style=default;;
|
||||||
|
*) if false; then
|
||||||
|
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
|
||||||
|
# was handled by the $'\x7d' case above
|
||||||
|
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
||||||
|
style=history-expansion
|
||||||
|
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
||||||
|
if [[ $this_word == *':regular:'* ]]; then
|
||||||
|
style=commandseparator
|
||||||
|
else
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
|
elif (( in_redirection == 2 )); then
|
||||||
|
style=redirection
|
||||||
|
else
|
||||||
|
if _zsh_highlight_main_highlighter_check_path; then
|
||||||
|
style=$REPLY
|
||||||
|
else
|
||||||
|
style=default
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
[[ $substr_color = 0 ]] && region_highlight+=("$start_pos $end_pos $style")
|
if ! (( already_added )); then
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && new_expression=true
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
|
[[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators
|
||||||
|
fi
|
||||||
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
||||||
|
if [[ $arg == ';' ]] && $in_array_assignment; then
|
||||||
|
# literal newline inside an array assignment
|
||||||
|
next_word=':regular:'
|
||||||
|
else
|
||||||
|
next_word=':start:'
|
||||||
|
highlight_glob=true
|
||||||
|
fi
|
||||||
|
elif
|
||||||
|
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] ||
|
||||||
|
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then
|
||||||
|
next_word=':start:'
|
||||||
|
elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then
|
||||||
|
# skip the repeat-count word
|
||||||
|
in_redirection=2
|
||||||
|
# The redirection mechanism assumes $this_word describes the word
|
||||||
|
# following the redirection. Make it so.
|
||||||
|
#
|
||||||
|
# That word can be a command word with shortloops (`repeat 2 ls`)
|
||||||
|
# or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`).
|
||||||
|
#
|
||||||
|
# The repeat-count word will be handled like a redirection target.
|
||||||
|
this_word=':start::regular:'
|
||||||
|
fi
|
||||||
start_pos=$end_pos
|
start_pos=$end_pos
|
||||||
|
if (( in_redirection == 0 )); then
|
||||||
|
# This is the default/common codepath.
|
||||||
|
this_word=$next_word
|
||||||
|
else
|
||||||
|
# Stall $this_word.
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the argument is variable assignment
|
# Check if $arg is variable assignment
|
||||||
_zsh_highlight_main_highlighter_check_assign()
|
_zsh_highlight_main_highlighter_check_assign()
|
||||||
{
|
{
|
||||||
setopt localoptions extended_glob
|
setopt localoptions extended_glob
|
||||||
[[ ${(Q)arg} == [[:alpha:]_]([[:alnum:]_])#=* ]]
|
[[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])(|[+])=* ]] ||
|
||||||
|
[[ $arg == [0-9]##(|[+])=* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the argument is a path.
|
_zsh_highlight_main_highlighter_highlight_path_separators()
|
||||||
|
{
|
||||||
|
local pos style_pathsep
|
||||||
|
style_pathsep=${style}_pathseparator
|
||||||
|
[[ -z "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" || "$ZSH_HIGHLIGHT_STYLES[$style]" == "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" ]] && return 0
|
||||||
|
for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do
|
||||||
|
if [[ $BUFFER[pos] == / ]]; then
|
||||||
|
_zsh_highlight_main_add_region_highlight $((pos - 1)) $pos $style_pathsep
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if $arg is a path.
|
||||||
|
# If yes, return 0 and in $REPLY the style to use.
|
||||||
|
# Else, return non-zero (and the contents of $REPLY is undefined).
|
||||||
_zsh_highlight_main_highlighter_check_path()
|
_zsh_highlight_main_highlighter_check_path()
|
||||||
{
|
{
|
||||||
setopt localoptions nonomatch
|
_zsh_highlight_main_highlighter_expand_path $arg;
|
||||||
local expanded_path; : ${expanded_path:=${(Q)~arg}}
|
local expanded_path="$REPLY"
|
||||||
|
|
||||||
|
REPLY=path
|
||||||
|
|
||||||
[[ -z $expanded_path ]] && return 1
|
[[ -z $expanded_path ]] && return 1
|
||||||
|
[[ -L $expanded_path ]] && return 0
|
||||||
[[ -e $expanded_path ]] && return 0
|
[[ -e $expanded_path ]] && return 0
|
||||||
[[ ! -e ${expanded_path:h} ]] && return 1
|
|
||||||
[[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos && -n $(print ${expanded_path}*(N)) ]] && return 0
|
# Search the path in CDPATH
|
||||||
|
local cdpath_dir
|
||||||
|
for cdpath_dir in $cdpath ; do
|
||||||
|
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
# If dirname($arg) doesn't exist, neither does $arg.
|
||||||
|
[[ ! -d ${expanded_path:h} ]] && return 1
|
||||||
|
|
||||||
|
# If this word ends the buffer, check if it's the prefix of a valid path.
|
||||||
|
if [[ ${BUFFER[1]} != "-" && $pure_buf_len == $end_pos ]] &&
|
||||||
|
[[ $WIDGET != zle-line-finish ]]; then
|
||||||
|
local -a tmp
|
||||||
|
tmp=( ${expanded_path}*(N) )
|
||||||
|
(( $#tmp > 0 )) && REPLY=path_prefix && return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# It's not a path.
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,19 +779,122 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
_zsh_highlight_main_highlighter_highlight_string()
|
_zsh_highlight_main_highlighter_highlight_string()
|
||||||
{
|
{
|
||||||
setopt localoptions noksharrays
|
setopt localoptions noksharrays
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
local i j k style
|
local i j k style
|
||||||
# Starting quote is at 1, so start parsing at offset 2 in the string.
|
# Starting quote is at 1, so start parsing at offset 2 in the string.
|
||||||
for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
|
for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
|
||||||
(( j = i + start_pos - 1 ))
|
(( j = i + start_pos - 1 ))
|
||||||
(( k = j + 1 ))
|
(( k = j + 1 ))
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
'$') style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument];;
|
'$' ) style=dollar-double-quoted-argument
|
||||||
"\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]
|
# Look for an alphanumeric parameter name.
|
||||||
(( k += 1 )) # Color following char too.
|
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
|
||||||
(( i += 1 )) # Skip parsing the escaped char.
|
(( k += $#MATCH )) # highlight the parameter name
|
||||||
|
(( i += $#MATCH )) # skip past it
|
||||||
|
elif [[ ${arg:$i} =~ ^[{]([A-Za-z_][A-Za-z0-9_]*|[0-9]+)[}] ]] ; then
|
||||||
|
(( k += $#MATCH )) # highlight the parameter name and braces
|
||||||
|
(( i += $#MATCH )) # skip past it
|
||||||
|
elif [[ $arg[i+1] == '$' ]]; then
|
||||||
|
# $$ - pid
|
||||||
|
(( k += 1 )) # highlight both dollar signs
|
||||||
|
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
||||||
|
elif [[ $arg[i+1] == [-#*@?] ]]; then
|
||||||
|
# $#, $*, $@, $?, $- - like $$ above
|
||||||
|
(( k += 1 )) # highlight both dollar signs
|
||||||
|
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
||||||
|
elif [[ $arg[i+1] == $'\x28' ]]; then
|
||||||
|
# Highlight just the '$'.
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*) continue;;
|
"\\") style=back-double-quoted-argument
|
||||||
|
if [[ \\\`\"\$${histchars[1]} == *$arg[$i+1]* ]]; then
|
||||||
|
(( k += 1 )) # Color following char too.
|
||||||
|
(( i += 1 )) # Skip parsing the escaped char.
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue ;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
region_highlight+=("$j $k $style")
|
_zsh_highlight_main_add_region_highlight $j $k $style
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Highlight special chars inside dollar-quoted strings
|
||||||
|
_zsh_highlight_main_highlighter_highlight_dollar_string()
|
||||||
|
{
|
||||||
|
setopt localoptions noksharrays
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
|
local i j k style
|
||||||
|
local AA
|
||||||
|
integer c
|
||||||
|
# Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string.
|
||||||
|
for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do
|
||||||
|
(( j = i + start_pos - 1 ))
|
||||||
|
(( k = j + 1 ))
|
||||||
|
case "$arg[$i]" in
|
||||||
|
"\\") style=back-dollar-quoted-argument
|
||||||
|
for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do
|
||||||
|
[[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
|
||||||
|
done
|
||||||
|
AA=$arg[$i+1,$c-1]
|
||||||
|
# Matching for HEX and OCT values like \0xA6, \xA6 or \012
|
||||||
|
if [[ "$AA" =~ "^(x|X)[0-9a-fA-F]{1,2}"
|
||||||
|
|| "$AA" =~ "^[0-7]{1,3}"
|
||||||
|
|| "$AA" =~ "^u[0-9a-fA-F]{1,4}"
|
||||||
|
|| "$AA" =~ "^U[0-9a-fA-F]{1,8}"
|
||||||
|
]]; then
|
||||||
|
(( k += $#MATCH ))
|
||||||
|
(( i += $#MATCH ))
|
||||||
|
else
|
||||||
|
if (( $#arg > $i+1 )) && [[ $arg[$i+1] == [xXuU] ]]; then
|
||||||
|
# \x not followed by hex digits is probably an error
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
|
(( k += 1 )) # Color following char too.
|
||||||
|
(( i += 1 )) # Skip parsing the escaped char.
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue ;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
_zsh_highlight_main_add_region_highlight $j $k $style
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called with a single positional argument.
|
||||||
|
# Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value.
|
||||||
|
#
|
||||||
|
# Does not perform filename generation (globbing).
|
||||||
|
_zsh_highlight_main_highlighter_expand_path()
|
||||||
|
{
|
||||||
|
(( $# == 1 )) || print -r -- >&2 "zsh-syntax-highlighting: BUG: _zsh_highlight_main_highlighter_expand_path: called without argument"
|
||||||
|
|
||||||
|
# The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}.
|
||||||
|
setopt localoptions nonomatch
|
||||||
|
unset REPLY
|
||||||
|
: ${REPLY:=${(Q)~1}}
|
||||||
|
}
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Main highlighter initialization
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_zsh_highlight_main__precmd_hook() {
|
||||||
|
_zsh_highlight_main__command_type_cache=()
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
if add-zsh-hook precmd _zsh_highlight_main__precmd_hook 2>/dev/null; then
|
||||||
|
# Initialize command type cache
|
||||||
|
typeset -gA _zsh_highlight_main__command_type_cache
|
||||||
|
else
|
||||||
|
print -r -- >&2 'zsh-syntax-highlighting: Failed to load add-zsh-hook. Some speed optimizations will not be used.'
|
||||||
|
# Make sure the cache is unset
|
||||||
|
unset _zsh_highlight_main__command_type_cache
|
||||||
|
fi
|
||||||
|
|||||||
37
highlighters/main/test-data/alias-assignment1.zsh
Normal file
37
highlighters/main/test-data/alias-assignment1.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Issue #263 (more-pathological case): aliases[x=y]=z works; the ${(z)} splitter considers
|
||||||
|
# that a single word; but it's not looked up as an alias. Hence, highlight it as an error.
|
||||||
|
aliases[x=y]='lorem ipsum dolor sit amet'
|
||||||
|
BUFFER='x=y ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 3 unknown-token" # x=y
|
||||||
|
)
|
||||||
50
highlighters/main/test-data/alias.zsh
Normal file
50
highlighters/main/test-data/alias.zsh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
alias alias1="unused expansion"
|
||||||
|
alias -s alias2="echo"
|
||||||
|
alias1() {} # to check that it's highlighted as an alias, not as a function
|
||||||
|
|
||||||
|
BUFFER='x.alias2; alias1'
|
||||||
|
|
||||||
|
# Set expected_region_highlight as a function of zsh version.
|
||||||
|
#
|
||||||
|
# Highlight of suffix alias requires zsh-5.1.1 or newer; see issue #126,
|
||||||
|
# and commit 36403 to zsh itself. Therefore, check if the requisite zsh
|
||||||
|
# functionality is present, and skip verifying suffix-alias highlighting
|
||||||
|
# if it isn't.
|
||||||
|
expected_region_highlight=()
|
||||||
|
if [[ "$(type -w x.alias2)" == *suffix* ]]; then
|
||||||
|
expected_region_highlight+=(
|
||||||
|
"1 8 suffix-alias" # x.alias2
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
expected_region_highlight+=(
|
||||||
|
"11 16 alias" # alias1
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/always1.zsh
Normal file
41
highlighters/main/test-data/always1.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='{ ls } always { pwd }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 reserved-word' # {
|
||||||
|
'3 4 command' # ls
|
||||||
|
'6 6 reserved-word' # }
|
||||||
|
'8 13 reserved-word' # always
|
||||||
|
'15 15 reserved-word' # {
|
||||||
|
'17 19 builtin' # pwd
|
||||||
|
'21 21 reserved-word' # }
|
||||||
|
)
|
||||||
43
highlighters/main/test-data/always2.zsh
Normal file
43
highlighters/main/test-data/always2.zsh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'{\nls\n} always { pwd }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 reserved-word' # {
|
||||||
|
'2 2 unknown-token' # \n
|
||||||
|
'3 4 command' # ls
|
||||||
|
'5 5 commandseparator' # \n
|
||||||
|
'6 6 reserved-word' # }
|
||||||
|
'8 13 reserved-word' # always
|
||||||
|
'15 15 reserved-word' # {
|
||||||
|
'17 19 builtin' # pwd
|
||||||
|
'21 21 reserved-word' # }
|
||||||
|
)
|
||||||
43
highlighters/main/test-data/always3.zsh
Normal file
43
highlighters/main/test-data/always3.zsh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt ignorebraces
|
||||||
|
BUFFER='echo { foo } always { bar }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 6 default' # {
|
||||||
|
'8 10 default' # foo
|
||||||
|
'12 12 default' # }
|
||||||
|
'14 19 default' # always
|
||||||
|
'21 21 default' # {
|
||||||
|
'23 25 default' # bar
|
||||||
|
'27 27 default' # }
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/anonymous-function.zsh
Normal file
41
highlighters/main/test-data/anonymous-function.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='() echo hello; () { echo world } "argument"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 2 reserved-word" # ()
|
||||||
|
"4 7 builtin" # echo
|
||||||
|
"9 13 default" # hello
|
||||||
|
"14 14 commandseparator" # ;
|
||||||
|
"16 17 reserved-word" # ()
|
||||||
|
"19 19 reserved-word" # {
|
||||||
|
"21 24 builtin" # echo
|
||||||
|
"34 43 double-quoted-argument" # "argument"
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/arithmetic-evaluation.zsh
Normal file
40
highlighters/main/test-data/arithmetic-evaluation.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Must be at command word, since the word following 'if' isn't currently considered
|
||||||
|
# a command word (issue #207).
|
||||||
|
#
|
||||||
|
# An opening '((' without matching '))' is highlighted correctly under zsh-5.1.1-52-g4bed2cf
|
||||||
|
# or newer, only (issue #188).
|
||||||
|
BUFFER='(( x == 42 ))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 2 reserved-word" # ((
|
||||||
|
"12 13 reserved-word" # ))
|
||||||
|
)
|
||||||
34
highlighters/main/test-data/assign-append.zsh
Normal file
34
highlighters/main/test-data/assign-append.zsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='a+=(lorem ipsum)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 4 assign" # a+=(
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/assign-argv.zsh
Normal file
35
highlighters/main/test-data/assign-argv.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='42=foo 43+=bar'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 6 assign" # 42=foo
|
||||||
|
"8 14 assign" # 43+=bar
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/assign-array.zsh
Normal file
37
highlighters/main/test-data/assign-array.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='(A=(hello world))'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 1 reserved-word" # (
|
||||||
|
"2 4 assign" # A=(
|
||||||
|
"16 16 assign" # )
|
||||||
|
"17 17 reserved-word" # )
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/assign-array2.zsh
Normal file
36
highlighters/main/test-data/assign-array2.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='A=(hello world) ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 3 assign" # A=(
|
||||||
|
"15 15 assign" # )
|
||||||
|
"17 18 command" # ls
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/assign-array3.zsh
Normal file
36
highlighters/main/test-data/assign-array3.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='A=(hello world) b=42'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 3 assign" # A=(
|
||||||
|
"15 15 assign" # )
|
||||||
|
"17 20 assign" # b=42
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/assign-semicolon.zsh
Normal file
35
highlighters/main/test-data/assign-semicolon.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='A=1; echo hello world'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"4 4 commandseparator" # ;
|
||||||
|
"6 9 builtin" # echo
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/assign-subshell.zsh
Normal file
36
highlighters/main/test-data/assign-subshell.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='(A=1)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 1 reserved-word" # (
|
||||||
|
"2 4 assign" # A=1
|
||||||
|
"5 5 reserved-word" # )
|
||||||
|
)
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@@ -28,8 +27,12 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BUFFER='A=1'
|
BUFFER='A=1 b=("foo" bar)'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 3 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1
|
"1 3 assign" # A=1
|
||||||
|
"5 7 assign" # b=(
|
||||||
|
"8 12 double-quoted-argument" # "foo"
|
||||||
|
"14 16 default" # bar
|
||||||
|
"17 17 assign" # )
|
||||||
)
|
)
|
||||||
|
|||||||
34
highlighters/main/test-data/back-quoted-argument.zsh
Normal file
34
highlighters/main/test-data/back-quoted-argument.zsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo `echo 42`'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"6 14 back-quoted-argument"
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/backslash-continuation.zsh
Normal file
35
highlighters/main/test-data/backslash-continuation.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
PREBUFFER=$'echo \\\n'
|
||||||
|
BUFFER='noglob'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 6 default" # 'noglob' highlighted as a string, not as a precomand
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/braces1.zsh
Normal file
41
highlighters/main/test-data/braces1.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'() { echo }\n}'
|
||||||
|
# no special setopts
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # ()
|
||||||
|
'4 4 reserved-word' # {
|
||||||
|
'6 9 builtin' # echo
|
||||||
|
'11 11 reserved-word' # }
|
||||||
|
'12 12 commandseparator' # \n
|
||||||
|
'13 13 unknown-token' # }
|
||||||
|
)
|
||||||
41
highlighters/main/test-data/braces2.zsh
Normal file
41
highlighters/main/test-data/braces2.zsh
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'() { echo }\n}'
|
||||||
|
setopt ignorebraces
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # ()
|
||||||
|
'4 4 reserved-word' # {
|
||||||
|
'6 9 builtin' # echo
|
||||||
|
'11 11 default' # }
|
||||||
|
'12 12 commandseparator' # \n
|
||||||
|
'13 13 reserved-word' # }
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/brackets-mismatch1.zsh
Normal file
39
highlighters/main/test-data/brackets-mismatch1.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='() { echo foo )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # ()
|
||||||
|
'4 4 reserved-word' # {
|
||||||
|
'6 9 builtin' # echo
|
||||||
|
'11 13 default' # foo
|
||||||
|
'15 15 unknown-token' # )
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/brackets-mismatch2.zsh
Normal file
39
highlighters/main/test-data/brackets-mismatch2.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='() ( echo foo }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 reserved-word' # ()
|
||||||
|
'4 4 reserved-word' # (
|
||||||
|
'6 9 builtin' # echo
|
||||||
|
'11 13 default' # foo
|
||||||
|
'15 15 unknown-token' # }
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/brackets-mismatch3.zsh
Normal file
36
highlighters/main/test-data/brackets-mismatch3.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo )'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 6 unknown-token' # )
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/brackets-mismatch4.zsh
Normal file
36
highlighters/main/test-data/brackets-mismatch4.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 6 unknown-token' # }
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/brackets-mismatch5.zsh
Normal file
37
highlighters/main/test-data/brackets-mismatch5.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo { }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 6 default' # {
|
||||||
|
'8 8 unknown-token' # }
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/brackets-mismatch6.zsh
Normal file
40
highlighters/main/test-data/brackets-mismatch6.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='(repeat 1; do)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 reserved-word' # (
|
||||||
|
'2 7 reserved-word' # repeat
|
||||||
|
'9 9 default' # 1
|
||||||
|
'10 10 commandseparator' # ;
|
||||||
|
'12 13 reserved-word' # do
|
||||||
|
'14 14 unknown-token' # )
|
||||||
|
)
|
||||||
44
highlighters/main/test-data/brackets-mismatch7.zsh
Normal file
44
highlighters/main/test-data/brackets-mismatch7.zsh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2012 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='for n in *; do echo $n; end'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 reserved-word' # for
|
||||||
|
'5 5 default' # n
|
||||||
|
'7 8 default' # in
|
||||||
|
'10 10 globbing' # *
|
||||||
|
'11 11 commandseparator' # ;
|
||||||
|
'13 14 reserved-word' # do
|
||||||
|
'16 19 builtin' # echo
|
||||||
|
'21 22 default' # $n
|
||||||
|
'23 23 commandseparator' # ;
|
||||||
|
'25 27 unknown-token' # end
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/brackets-mismatch8.zsh
Normal file
38
highlighters/main/test-data/brackets-mismatch8.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='(ls&)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 reserved-word' # (
|
||||||
|
'2 3 command' # ls
|
||||||
|
'4 4 commandseparator' # &
|
||||||
|
'5 5 reserved-word' # )
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/commandseparator.zsh
Normal file
37
highlighters/main/test-data/commandseparator.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=':; pwd &! ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"2 2 commandseparator" # ;
|
||||||
|
"4 6 builtin" # pwd
|
||||||
|
"8 9 commandseparator" # &!
|
||||||
|
"11 12 command" # ls
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/comment-leading.zsh
Normal file
37
highlighters/main/test-data/comment-leading.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt interactive_comments
|
||||||
|
|
||||||
|
BUFFER='# echo foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 1 comment" # #
|
||||||
|
"2 10 comment" # " echo foo"
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/comment-off.zsh
Normal file
38
highlighters/main/test-data/comment-off.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
unsetopt interactive_comments
|
||||||
|
|
||||||
|
BUFFER='# echo foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 1 unknown-token" # #
|
||||||
|
"3 6 default" # " echo foo"
|
||||||
|
"8 10 default" # " echo foo"
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/comments.zsh
Normal file
38
highlighters/main/test-data/comments.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt interactive_comments
|
||||||
|
|
||||||
|
BUFFER='echo "foo #bar" #baz # quux'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 4 builtin" # echo
|
||||||
|
"6 15 double-quoted-argument" # "foo #bar"
|
||||||
|
"17 27 comment" # #baz # quux
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/commmand-parameter.zsh
Normal file
36
highlighters/main/test-data/commmand-parameter.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
x=/usr/bin/env
|
||||||
|
BUFFER='$x "argument"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 2 command" # $x
|
||||||
|
"4 13 double-quoted-argument" # "argument"
|
||||||
|
)
|
||||||
50
highlighters/main/test-data/control-flow.zsh
Normal file
50
highlighters/main/test-data/control-flow.zsh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='while if echo Hello; then ls /; else ls; fi; do stat "x"; done; repeat 10 ls'
|
||||||
|
|
||||||
|
expected_region_highlight+=(
|
||||||
|
"1 5 reserved-word" # while
|
||||||
|
"7 8 reserved-word" # if
|
||||||
|
"10 13 builtin" # echo
|
||||||
|
"15 19 default" # Hello
|
||||||
|
"22 25 reserved-word" # then
|
||||||
|
"27 28 command" # ls
|
||||||
|
"30 30 path" # /
|
||||||
|
"31 31 commandseparator" # ;
|
||||||
|
"33 36 reserved-word" # else
|
||||||
|
"38 39 command" # ls
|
||||||
|
"42 43 reserved-word" # fi
|
||||||
|
"46 47 reserved-word" # do
|
||||||
|
"49 52 command" # stat
|
||||||
|
"54 56 double-quoted-argument" # "x"
|
||||||
|
"59 62 reserved-word" # done
|
||||||
|
"65 70 reserved-word" # repeat
|
||||||
|
"75 76 command" # ls
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/control-flow2.zsh
Normal file
40
highlighters/main/test-data/control-flow2.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='repeat 42; do ls; done'
|
||||||
|
|
||||||
|
expected_region_highlight+=(
|
||||||
|
"1 6 reserved-word" # repeat
|
||||||
|
"8 9 default" # 42
|
||||||
|
"10 10 commandseparator" # ;
|
||||||
|
"12 13 reserved-word" # do
|
||||||
|
"15 16 command" # ls
|
||||||
|
"17 17 commandseparator" # ;
|
||||||
|
"19 22 reserved-word" # done
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/control-flow3.zsh
Normal file
39
highlighters/main/test-data/control-flow3.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='repeat 42; ls; pwd'
|
||||||
|
|
||||||
|
expected_region_highlight+=(
|
||||||
|
"1 6 reserved-word" # repeat
|
||||||
|
"8 9 default" # 42
|
||||||
|
"10 10 commandseparator" # ;
|
||||||
|
"12 13 command" # ls
|
||||||
|
"14 14 commandseparator" # ;
|
||||||
|
"16 18 builtin" # pwd
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/dollar-dollar.zsh
Normal file
39
highlighters/main/test-data/dollar-dollar.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "$$ $$foo"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 3 double-quoted-argument' # "
|
||||||
|
'4 5 dollar-double-quoted-argument' # $$
|
||||||
|
'7 8 dollar-double-quoted-argument' # $$
|
||||||
|
'9 12 double-quoted-argument' # foo"
|
||||||
|
)
|
||||||
46
highlighters/main/test-data/dollar-noise.zsh
Normal file
46
highlighters/main/test-data/dollar-noise.zsh
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "$- $# $* $@ $?"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 3 double-quoted-argument' # "
|
||||||
|
'4 5 dollar-double-quoted-argument' # $-
|
||||||
|
'6 6 double-quoted-argument' # <space>
|
||||||
|
'7 8 dollar-double-quoted-argument' # $#
|
||||||
|
'9 9 double-quoted-argument' # <space>
|
||||||
|
'10 11 dollar-double-quoted-argument' # $*
|
||||||
|
'12 12 double-quoted-argument' # <space>
|
||||||
|
'13 14 dollar-double-quoted-argument' # $@
|
||||||
|
'15 15 double-quoted-argument' # <space>
|
||||||
|
'16 17 dollar-double-quoted-argument' # $?
|
||||||
|
'18 18 double-quoted-argument' # "
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/dollar-paren.zsh
Normal file
38
highlighters/main/test-data/dollar-paren.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "$(:)"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 3 double-quoted-argument' # "
|
||||||
|
'4 4 dollar-double-quoted-argument' # $
|
||||||
|
'5 8 double-quoted-argument' # (:)"
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/dollar-quoted.zsh
Normal file
35
highlighters/main/test-data/dollar-quoted.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=": \$'*' 'foo'"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 6 dollar-quoted-argument" # $'*' - not a glob
|
||||||
|
"8 12 single-quoted-argument" # 'foo'
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/dollar-quoted2.zsh
Normal file
40
highlighters/main/test-data/dollar-quoted2.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=": \$'foo\xbar\udeadbeef\uzzzz'"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 7 dollar-quoted-argument" # $'foo
|
||||||
|
"8 11 back-dollar-quoted-argument" # \xba
|
||||||
|
"12 12 dollar-quoted-argument" # r
|
||||||
|
"13 18 back-dollar-quoted-argument" # \dead
|
||||||
|
"19 22 dollar-quoted-argument" # beef
|
||||||
|
"23 24 unknown-token" # \u
|
||||||
|
"25 29 dollar-quoted-argument" # zzzz'
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/dollar-quoted3.zsh
Normal file
37
highlighters/main/test-data/dollar-quoted3.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Similar to double-quoted2.zsh
|
||||||
|
# This test checks that the '1' gets highlighted correctly. Do not append to the BUFFER.
|
||||||
|
BUFFER=": \$'\xa1"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 4 dollar-quoted-argument" # $'
|
||||||
|
"5 8 back-dollar-quoted-argument" # \xa1
|
||||||
|
)
|
||||||
34
highlighters/main/test-data/double-hyphen-option.zsh
Normal file
34
highlighters/main/test-data/double-hyphen-option.zsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='hello --world'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"7 13 double-hyphen-option" # --world
|
||||||
|
)
|
||||||
45
highlighters/main/test-data/double-quoted.zsh
Normal file
45
highlighters/main/test-data/double-quoted.zsh
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "foo$bar:\`:\":\$:'
|
||||||
|
BUFFER+=\\\\:\"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 6 double-quoted-argument" # "foo
|
||||||
|
"7 10 dollar-double-quoted-argument" # $bar
|
||||||
|
"11 11 double-quoted-argument" # :
|
||||||
|
"12 13 back-double-quoted-argument" # \`
|
||||||
|
"14 14 double-quoted-argument" # :
|
||||||
|
"15 16 back-double-quoted-argument" # \$
|
||||||
|
"17 17 double-quoted-argument" # :
|
||||||
|
"18 19 back-double-quoted-argument" # \"
|
||||||
|
"20 20 double-quoted-argument" # :
|
||||||
|
"21 22 back-double-quoted-argument" # \\
|
||||||
|
"23 24 double-quoted-argument" # :"
|
||||||
|
)
|
||||||
37
highlighters/main/test-data/double-quoted2.zsh
Normal file
37
highlighters/main/test-data/double-quoted2.zsh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Similar to dollar-quoted3.zsh
|
||||||
|
# This test checks that the 'r' gets highlighted correctly. Do not append to the BUFFER.
|
||||||
|
BUFFER=': "foo$bar'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 6 double-quoted-argument" # "foo
|
||||||
|
"7 10 dollar-double-quoted-argument" # $bar
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/double-quoted3.zsh
Normal file
39
highlighters/main/test-data/double-quoted3.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "$" "$42foo"'
|
||||||
|
BUFFER+=\ \"\\\'\\x\"
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 5 double-quoted-argument" # "$"
|
||||||
|
"7 7 double-quoted-argument" # "
|
||||||
|
"8 10 dollar-double-quoted-argument" # $42
|
||||||
|
"11 14 double-quoted-argument" # foo"
|
||||||
|
"16 21 double-quoted-argument" # "\'\x" - \' and \x are not escape sequences
|
||||||
|
)
|
||||||
36
highlighters/main/test-data/double-quoted4.zsh
Normal file
36
highlighters/main/test-data/double-quoted4.zsh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': "${foo}bar"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"3 3 double-quoted-argument" # "
|
||||||
|
"4 9 dollar-double-quoted-argument" # ${foo}
|
||||||
|
"10 13 double-quoted-argument" # bar"
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/empty-command.zsh
Normal file
35
highlighters/main/test-data/empty-command.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo; ;'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"5 5 commandseparator" # ;
|
||||||
|
"7 7 unknown-token" # ;
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/empty-command2.zsh
Normal file
38
highlighters/main/test-data/empty-command2.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Same test data and expectations as empty-command.zsh; the only difference is:
|
||||||
|
touch ';'
|
||||||
|
|
||||||
|
BUFFER='echo; ;'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"5 5 commandseparator" # ;
|
||||||
|
"7 7 unknown-token" # ;
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/exec-redirection1.zsh
Normal file
38
highlighters/main/test-data/exec-redirection1.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='exec {foo}>&/tmp ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 4 precommand" # exec
|
||||||
|
"6 10 redirection 'issue #238'" # {foo}
|
||||||
|
"11 12 redirection" # >&
|
||||||
|
"13 16 path" # /tmp
|
||||||
|
"18 19 command 'issue #238'" # ls
|
||||||
|
)
|
||||||
44
highlighters/main/test-data/function-named1.zsh
Normal file
44
highlighters/main/test-data/function-named1.zsh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='f() pwd; f() { balanced braces }'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 TBD "issue #223"' # f
|
||||||
|
'2 3 reserved-word' # ()
|
||||||
|
'5 7 builtin' # pwd
|
||||||
|
'8 8 commandseparator' # ;
|
||||||
|
'10 10 TBD "issue #223"' # f
|
||||||
|
'11 12 reserved-word' # ()
|
||||||
|
'14 14 reserved-word' # {
|
||||||
|
'16 23 unknown-token' # balanced
|
||||||
|
'25 30 default' # braces
|
||||||
|
'32 32 reserved-word' # }
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/function-named2.zsh
Normal file
39
highlighters/main/test-data/function-named2.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='f g h () pwd'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 TBD "issue #223"' # f
|
||||||
|
'3 3 TBD "issue #223"' # g
|
||||||
|
'5 5 TBD "issue #223"' # h
|
||||||
|
'7 8 reserved-word' # ()
|
||||||
|
'10 12 builtin' # pwd
|
||||||
|
)
|
||||||
44
highlighters/main/test-data/function.zsh
Normal file
44
highlighters/main/test-data/function.zsh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
cd() {
|
||||||
|
builtin cd "$@"
|
||||||
|
}
|
||||||
|
ls() {
|
||||||
|
command ls "$@"
|
||||||
|
}
|
||||||
|
BUFFER='cd;ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 2 function" # cd
|
||||||
|
"4 5 function" # ls
|
||||||
|
)
|
||||||
|
|
||||||
|
# don't 'unfunction cd ls', since cd() and ls() should still be a functions
|
||||||
|
# when _zsh_highlight runs. Leaving the wrapper functions is harmless.
|
||||||
38
highlighters/main/test-data/glob.zsh
Normal file
38
highlighters/main/test-data/glob.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=': foo* bar? *baz qux\?'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 1 builtin" # :
|
||||||
|
"3 6 globbing" # foo*
|
||||||
|
"8 11 globbing" # bar?
|
||||||
|
"13 16 globbing" # *baz
|
||||||
|
"18 22 default" # qux\?
|
||||||
|
)
|
||||||
35
highlighters/main/test-data/hashed-command.zsh
Normal file
35
highlighters/main/test-data/hashed-command.zsh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
hash zsh_syntax_highlighting_hash=/doesnotexist
|
||||||
|
BUFFER='zsh_syntax_highlighting_hash'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 28 hashed-command 'zsh/parameter cannot distinguish between hashed and command'"
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='echo "Hello\!"'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin' # echo
|
||||||
|
'6 11 double-quoted-argument' # "Hello
|
||||||
|
'12 13 back-double-quoted-argument' # \!
|
||||||
|
'14 14 double-quoted-argument' # "Hello\!"
|
||||||
|
)
|
||||||
38
highlighters/main/test-data/history-expansion.zsh
Normal file
38
highlighters/main/test-data/history-expansion.zsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='!foo bar !baz ! ; !'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 4 history-expansion" # !foo
|
||||||
|
"6 8 default" # bar
|
||||||
|
"10 13 history-expansion" # !baz
|
||||||
|
"15 15 default" # ! (before the semicolon)
|
||||||
|
"19 19 reserved-word" # ! (after the semicolon)
|
||||||
|
)
|
||||||
34
highlighters/main/test-data/history-expansion2.zsh
Normal file
34
highlighters/main/test-data/history-expansion2.zsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2015 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER='^foo^bar'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"1 8 history-expansion" # ^foo^bar
|
||||||
|
)
|
||||||
40
highlighters/main/test-data/inheritance.zsh
Normal file
40
highlighters/main/test-data/inheritance.zsh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_zsh_highlight_add_highlight()
|
||||||
|
{
|
||||||
|
region_highlight+=("$1 $2 ${(j.,.)argv[3,-1]}")
|
||||||
|
}
|
||||||
|
|
||||||
|
BUFFER='type'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 builtin,arg0' # type
|
||||||
|
)
|
||||||
39
highlighters/main/test-data/multiline-array-assignment1.zsh
Normal file
39
highlighters/main/test-data/multiline-array-assignment1.zsh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2016 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'foo=(\nbar) env'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 5 assign' # foo=(
|
||||||
|
'6 6 commandseparator' # \n
|
||||||
|
'7 9 default' # bar
|
||||||
|
'10 10 assign' # )
|
||||||
|
'12 14 command' # env
|
||||||
|
)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user