Skip to content

Commit c28312b

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master: (297 commits) driver: Follow-up to grandparent: Have all test suite entry points declare the mock $region_highlight. Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight. driver: Stop re-declaring $region_highlight. It's unneeded. docs: regexp highlighter: Fix a wrong associative array name in the example. docs: Fix obs-repository link tests: Fix a wrong value of $PREBUFFER in a test, and add checks to prevent this from recurring. test harness: Fix use of an undefined variable in an error message. 'main': Don't progress the $in_redirection staller while $in_param. tests: Add an XFail test for issue #712. 'main': Highlight the parentheses of array assignments as reserved words. CI += zsh-5.8 main: Add tests for arithmetic expansion main: Add arithmetic substitution highlighting changelog.md: Restore vertical whitespace before section headers. 'main': Fix issue #677, concerning multiline aliases. changelog: Update through HEAD. 'main': Further optimize argument parsing. 'main': Optimize a hot path. tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file. changelog: Update through HEAD. test harness: Print the expected-v.-actual on every failure, not just upon cardinality failures. Document ZSH_HIGHLIGHT_MAXLENGTH. 'main': Fix the last commit's bug concerning parameter elision not happening in redirects in command position. 'main': Add a test for parameter elision not happening in redirects in command position. 'main': Fix regression in zsh 5.3.1 and older: all precmd hooks later than z-sy-h would be aborted. changelog += WARN_NESTED_VAR fixes (#727, #731) 'main': Fix a regression caused by the great-grandparent commit's WARN_NESTED_VAR fix. 'main': Don't run `_zsh_highlight_main__type` on every non-command word. 'make perf': Show only a cumulative datum per highligher, rather than per test file. 'main': Don't trip WARN_NESTED_VAR. 'main': Follow-up to previous: Document the version number, and deduplicate some option letters. 'main': precommands += strace editorconfig: Fix Makefile settings Fix typo Bump copyright years. driver: Fix "_zsh_highlight:3: read-only variable: ret" warnings when POSIX_BUILTINS is set. tests: Add a test for the infinite loop fixed by each of the last two commits. 'main': Fix expansion of positional parameters in `_zsh_highlight_main_highlighter__try_expand_parameter`. 'main': Fix an infinite loop. 'main': precommands += ionice(1) (from util-linux) driver: Simplify initialization of $zsyh_user_options in the fallback codepath. driver: Make sure we don't change the return value in a called function. 'main': Make logic more robust. No functional change. 'main': Break out an anonymous function into a named function. Fix typos in comments. main: Add test for issue #713 'main': Support the 'env' precommand. test harness: Fix the pretty-printer's padding implementation. Revert "test harness: Rewrite the columnar pretty-printer without external tools." and "travis: Remove bsdmainutils since column(1) has been removed, three commits ago." changelog: Update through HEAD. 'main': Correctly highlight '&&' and '||' inside '[[ … ]]' conditions. 'main': Highlight reserved words following assignments as errors. tests: Add tests for issue #461. test harness: Output the time information to the same place the test name was printed to. test harness: Stringify values in a more readable manner. tests: Add a unit test for a path specified with mixed quoting. tests: Add a test for issue #498, which has already been fixed. tests: Test that global qualifiers and command substitutions aren't evaluated. 'main': Don't consider path_prefix in alias expansions. 'main': Add a test for aliases to AUTO_CD directories. 'main': Let AUTO_CD directories be highlighted with their own style. 'main': Add an auxiliary variable for readability. 'main': In command position, do not highlight directories (unless AUTO_CD is set) and non-executable files. 'main': Extend tests to capture the current behaviour. 'main': Add an XFail test for issue #202. 'main': Highlight errors from the EQUALS option. 'main': Let the type determination ignore global aliases when it ignores regular ones. 'main': Add a regression test for parameters that expand to global aliases. 'main': Enable the zsh/parameter codepath of global aliases highlighting. changelog: Update through HEAD. travis: Remove bsdmainutils since column(1) has been removed, three commits ago. 'main': Highlight global aliases tests: Record current behaviour on global aliases. test harness: Rewrite the columnar pretty-printer without external tools. test harness: Fix an issue with the pretty-printed $expected_region_highlight/$region_highlight diffing. 'main': Support the "close file descriptor" and "coproc" redirection syntaxes tests: Add a test for the "close file descriptor" and "coproc" redirection syntaxes tests: Fix the test added in the last commit. tests: Add a test for issue #705, concerning continuation lines. test harness: Let tests fail early by exiting non-zero or by setting a flag. test harness: Print the test name when $skip_test is set. test harness: Remove a bogus check. test harness: Fix $skip_test support, broken yesterday. travis: Install bsdmainutils to provide column(1). test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight. test harness: Don't leak options from test files to the test harness. test harness: Fix test failures under zsh 5.0.8 and older. 'main': Fix a bug manifesting under zsh 5.2 and older. 'main': Don't highlight arithmetic expansions as command substitutions. tests: Add a test documenting the current state, prior to introducing #704. test harness: Change cardinality check semantics test harness: No-op change to minimize the next diff. 'main': Document additional meanings of the 'S' $braces_stack flag. 'main': When the redirection operator '>&' or '<&' is followed by a positive integer, do not consider that as a filename; it's always a file descriptor. 'main': Add $last_arg for "lookbehind". noop: Clarify comment. 'main': Honour the MULTIOS option when applying the 'globbing' style. 'main': Document what $in_redirection is currently used for. 'main': The optimized cmdsubst input syntax doesn't glob. changelog: Fix markup. ...
2 parents b08d508 + d9a7963 commit c28312b

File tree

172 files changed

+6289
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+6289
-598
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Top-most editorconfig file
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
tab_width = 2
8+
indent_size = 2
9+
indent_style = space
10+
11+
[Makefile]
12+
tab_width = 8
13+
indent_size = 8
14+
indent_style = tab
15+

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ sudo: required
33

44
env:
55
- ZSH=master
6+
- ZSH=5.8
7+
- ZSH=5.7.1
8+
- ZSH=5.7
69
- ZSH=5.6.2
710
- ZSH=5.6.1
811
- ZSH=5.6
@@ -33,7 +36,7 @@ env:
3336
- ZSH=4.3.12
3437
- ZSH=4.3.11
3538

36-
script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'install_packages make procps && make test'
39+
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps bsdmainutils && make test'
3740

3841
notifications:
3942
webhooks:

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.0-dev
1+
0.7.2-dev

COPYING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
1+
Copyright (c) 2010-2020 zsh-syntax-highlighting contributors
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted

HACKING.md

+49-25
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ The `main` highlighter
1111

1212
The following function `pz` is useful when working on the `main` highlighting:
1313

14-
pq() {
15-
(( $#argv )) || return 0
16-
print -r -l -- ${(qqqq)argv}
17-
}
18-
pz() {
19-
local arg
20-
for arg; do
21-
pq ${(z)arg}
22-
done
23-
}
14+
```zsh
15+
pq() {
16+
(( $#argv )) || return 0
17+
print -r -l -- ${(qqqq)argv}
18+
}
19+
pz() {
20+
local arg
21+
for arg; do
22+
pq ${(z)arg}
23+
done
24+
}
25+
```
2426

2527
It prints, for each argument, its token breakdown, similar to how the main
2628
loop of the `main` highlighter sees it.
@@ -32,17 +34,19 @@ Since the test harness empties `ZSH_HIGHLIGHT_STYLES` and the `brackets`
3234
highlighter interrogates `ZSH_HIGHLIGHT_STYLES` to determine how to highlight,
3335
tests must set the `bracket-level-#` keys themselves. For example:
3436

35-
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
36-
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
37+
```zsh
38+
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
39+
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
3740

38-
BUFFER='echo ({x})'
41+
BUFFER='echo ({x})'
3942

40-
expected_region_highlight=(
41-
"6 6 bracket-level-1" # (
42-
"7 7 bracket-level-2" # {
43-
"9 9 bracket-level-2" # }
44-
"10 10 bracket-level-1" # )
45-
)
43+
expected_region_highlight=(
44+
"6 6 bracket-level-1" # (
45+
"7 7 bracket-level-2" # {
46+
"9 9 bracket-level-2" # }
47+
"10 10 bracket-level-1" # )
48+
)
49+
```
4650

4751
Testing the `pattern` and `regexp` highlighters
4852
-----------------------------------------------
@@ -53,20 +57,40 @@ cannot get the `ZSH_HIGHLIGHT_STYLES` keys. Therefore, when writing tests, use
5357
the style itself as third word (cf. the
5458
[documentation for `expected_region_highlight`](docs/highlighters.md)). For example:
5559

56-
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
60+
```zsh
61+
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
5762

58-
BUFFER='rm -rf /'
63+
BUFFER='rm -rf /'
64+
65+
expected_region_highlight=(
66+
"1 8 fg=white,bold,bg=red" # rm -rf /
67+
)
68+
```
69+
70+
Memos and commas
71+
----------------
72+
73+
We append to `region_highlight` as follows:
74+
75+
76+
```zsh
77+
region_highlight+=("$start $end $spec, memo=zsh-syntax-highlighting")
78+
```
79+
80+
That comma is required to cause zsh 5.8 and older to ignore the memo without
81+
ignoring the `$spec`. It's a hack, but given that no further 5.8.x patch
82+
releases are planned, it's been deemed acceptable. See issue #418 and the
83+
cross-referenced issues.
5984

60-
expected_region_highlight=(
61-
"1 8 fg=white,bold,bg=red" # rm -rf /
62-
)
6385

6486
Miscellany
6587
----------
6688

6789
If you work on the driver (`zsh-syntax-highlighting.zsh`), you may find the following zstyle useful:
6890

69-
zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh
91+
```zsh
92+
zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh
93+
```
7094

7195
IRC channel
7296
-----------

INSTALL.md

+26-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ How to install
66
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
77
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository])
88
* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository])
9-
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`textproc/zsh-syntax-highlighting`][freebsd-port])
9+
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port])
1010
* Gentoo: [mv overlay][gentoo-overlay]
1111
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
1212
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
@@ -23,8 +23,8 @@ How to install
2323
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
2424
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
2525
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
26-
[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
27-
[void-package]: https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
26+
[obs-repository]: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
27+
[void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
2828

2929
See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
3030

@@ -33,17 +33,23 @@ See also [repology's cross-distro index](https://repology.org/metapackage/zsh-sy
3333

3434
Simply clone this repository and source the script:
3535

36-
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
37-
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
36+
```zsh
37+
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
38+
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
39+
```
3840

3941
Then, enable syntax highlighting in the current interactive shell:
4042

41-
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
43+
```zsh
44+
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
45+
```
4246

4347
If `git` is not installed, download and extract a snapshot of the latest
4448
development tree from:
4549

46-
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
50+
```
51+
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
52+
```
4753

4854
Note the `source` command must be **at the end** of `~/.zshrc`.
4955

@@ -69,15 +75,17 @@ your `.zshrc`.
6975

7076
1. Clone this repository in oh-my-zsh's plugins directory:
7177

72-
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
78+
```zsh
79+
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
80+
```
7381

7482
2. Activate the plugin in `~/.zshrc`:
7583

76-
plugins=( [plugins...] zsh-syntax-highlighting)
84+
```zsh
85+
plugins=( [plugins...] zsh-syntax-highlighting)
86+
```
7787

78-
3. Source `~/.zshrc` to take changes into account:
79-
80-
source ~/.zshrc
88+
3. Restart zsh (such as by opening a new instance of your terminal emulator).
8189

8290
#### [Prezto](https://github.com/sorin-ionescu/prezto)
8391

@@ -106,10 +114,14 @@ Any of the above methods is suitable for a single-user installation,
106114
which requires no special privileges. If, however, you desire to install
107115
zsh-syntax-highlighting system-wide, you may do so by running
108116

109-
make install
117+
```zsh
118+
make install
119+
```
110120

111121
and directing your users to add
112122

113-
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
123+
```zsh
124+
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
125+
```
114126

115127
to their `.zshrc`s.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test:
4141
for test in highlighters/*; do \
4242
if [ -d $$test/test-data ]; then \
4343
echo "Running test $${test##*/}"; \
44-
$(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
44+
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
4545
: $$(( result |= $$? )); \
4646
fi \
4747
done; \

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Before: [![Screenshot #3.1](images/before3-smaller.png)](images/before3.png)
2727
<br/>
2828
After:&nbsp; [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png)
2929

30+
Before: [![Screenshot #4.1](images/before4-smaller.png)](images/before4-smaller.png)
31+
<br/>
32+
After:&nbsp; [![Screenshot #4.2](images/after4-smaller.png)](images/after4-smaller.png)
33+
34+
3035

3136
How to install
3237
--------------

0 commit comments

Comments
 (0)