Compare commits

...

234 commits

Author SHA1 Message Date
Max Coplan 4672ad5dd9
fix(chroma/ssh): treat -R and -Q as flags that take an argument (#91)
Some checks failed
zunit / zunit (push) Has been cancelled
The ssh chroma keeps a list of flags whose argument must be skipped, so the
argument is not mistaken for the hostname. Every entry is hyphenated except
two: `Q` and `R` are written bare, so `-Q` and `-R` never match.

For `-R` the consequence is visible. Typing

    ssh -R 5037:localhost:5037 devbox

leaves `5037:localhost:5037` counted as the first non-option token, so it
becomes the hostname. Its trailing `:5037` then matches the host:port check and
the chroma calls `zle -M` with

    Format of hostname incorrect, use -p to pass port number

while you type, on a command line that is perfectly valid. `-L` is in the list
correctly, so the identical local-forward spec highlights fine and only the
remote forward is affected. `-Q` mislabels its argument as the host in the same
way, without reaching the message.

Adds two tests: `-R` must stay silent, and a hostspec that really does carry a
port must still be reported.

Related to #33, which reports `-LRD` forwarding specs highlighting wrongly;
this fixes the `-R` half.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 09:14:04 +02:00
Quentin Burgess 3d574ccf48
misc(make): trigger new parser only when new shared cache is enabled (#83)
Some checks failed
zunit / zunit (push) Has been cancelled
2025-07-16 12:16:33 +02:00
mrnoname1000 3922b911a3
_chroma/-perl.ch: Support -E flag (#61) 2025-07-16 10:42:14 +02:00
Quentin Burgess 5ecd353c81
feat(chroma/make): new makefile colorization caching strategy (#82)
* fix(chroma/make): huge delay on big units

* fix(fast-make): code-style indentation

* feat(fast-make): allow shared cache

One may enable the shared cache by setting the following prior to
loading the fast-synthax-highlighting module

```sh
typeset -gA FAST_HIGHLIGHT
FAST_HIGHLIGHT[chroma-make-cache-global]=1
```

This new implementation change the way the cached makefile' parsed
content are expired. Prior to this commit, cached item expired after
7s. The new implementation get ride of the timer limit and
replace it with a good old "is my file content's different"
2025-07-16 10:37:53 +02:00
Quentin Burgess dcee72bb99
fix(make): colorize targets from imported make-files (#81)
* fix(make): colorize targets from imported make-files

Old behavior use to parse the content of the invoked `Makefile` unit
to define targets.

Such parsing didn't take into account targets from unit imported by the
current (ex: targets defined in files imported such as `import
./targets/help.mk`).

New behavior pass the content of the Makefile unit post lexing (aka
`make -f Makefile -pn` instead of the plain unit.

* Update →chroma/-make.ch

---------

Co-authored-by: Philipp Schmitt <pschmitt@users.noreply.github.com>
2025-06-25 09:44:25 +02:00
Quentin Burgess 6f57bbe57c
feat(chrome): support for podman (#80) 2025-06-25 09:42:43 +02:00
Ultimator14 cf318e06a9
Add '--message' to git commit syntax highlighting (#57)
Fix zdharma-continuum/fast-syntax-highlighting#47

Signed-off-by: Jan Breig <git@pygos.space>
2023-07-05 23:10:19 +02:00
Lucas Larson 13d7b4e634
add support for goawk (#51)
`goawk` is a POSIX-compliant AWK interpreter that benefits from the
same highlighting as other AWK interpreters here.

Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
2023-04-03 08:58:53 +02:00
Lucas Larson 371591a7b6
avoid errors unbound variables and unset parameters (#50)
zsh prints an abundance of errors when `setopt nounset` is enabled and
fast-syntax-highlighting is activated (#49). This commit helps to avoid
the unnecessary verbosity.

Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
2023-03-24 23:06:05 +01:00
memchr 5521b083f8
feat: whatis recognizes section suffix (#45)
[F-Sy-H](https://github.com/zdharma-continuum/fast-syntax-highlighting) can recognize and highlight manual subsection suffixes (i.e., `open.2`, `ls.1p`, `printf.3`).

- `man-db` is known to support subsection suffixes
- `mandoc` should not be affected by this commit
2023-03-10 16:14:33 -06:00
QuarticCat 7c390ee3bf
fix: correct highlighting logic for global aliases (#26)
Thank you to @QuarticCat for the fix.
2022-11-19 20:50:23 -06:00
Loong Wang 770bcd9866
maint: update links (e.g., zdharma -> zdharma-continuum) (#41)
Authored by: @wangl-cc
2022-09-30 22:22:15 -05:00
Brendan Falk 13dd94ba82
docs: Fig installation instructions (#37) 2022-07-22 17:30:21 -05:00
Francisco Borges 721be2a935
Use 'typeset -g' to avoid warning when WARN_CREATE_GLOBAL is set. (#36) 2022-06-11 11:10:30 +02:00
Guido Cella 370106d95d
feat: new base16 theme (#31)
Author: @guidocella
2022-06-08 02:32:31 -05:00
vladislav doster 9469bd0e7e
maint: add linting Github action workflow (#29)
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
2022-04-25 01:18:04 -05:00
Aloxaf ef8ba84c3a
fix: correct highlighting logic for hex color codes (e.g., #fff & #ffffff) (#18)
- fixes an issue of incorrectly parsing certain strings as hex color codes
2022-02-27 22:19:23 -05:00
Yusei Ueno c8771e436d
docs(README.md): correct link pointing to chromas directory (#19) 2022-02-27 22:02:47 -05:00
vladislav doster 35556c2f83
maint(_chroma/-ssh.ch): don't expand $userdirs for user matching
`$userdirs` can be pretty huge, and blindly expanding it to match as a regex expression
can be expensive.

Because `$userdirs` is an associative array, leveraging direct member lookup is the optimal method.
2022-02-27 21:55:37 -05:00
Marek Rusinowski 8064150eee -ssh.sh: don't expand $userdirs for user matching
$userdirs can be quite huge and blindly expanding it to then match as regexp
can be very expensive. Because $userdirs is an associative array, we can do
a direct member lookup which is much quicker.
2022-01-31 22:09:40 +01:00
Aaron Lichtman 585c089968
Merge pull request #10 from zdharma-continuum/ci-pinned-versions 2021-11-13 20:27:09 -06:00
Philipp Schmitt 6f36339a31
Pin zunit, revolver and color.zsh versions 2021-11-13 18:23:36 +01:00
Aaron Lichtman db6d265db0
Merge pull request #9 from zdharma-continuum/ci 2021-11-13 10:44:42 -06:00
Philipp Schmitt 5327d7f9c0
Remove travic CI config 2021-11-12 23:29:57 +01:00
Philipp Schmitt 41fe53aa00
Unit tests via GH Actions 2021-11-12 23:29:04 +01:00
Alexandros Kozák f4d007e4da
Restore compatibility with Zsh v4.3.11 (#7) 2021-11-12 18:41:38 +01:00
Philipp Schmitt 47f1ce7a32
Merge pull request #6 from zdharma-continuum/gitter-im 2021-11-12 18:11:36 +01:00
Philipp Schmitt 84c7e50f12
Merge pull request #3 from agkozak/exit-code 2021-11-11 15:56:57 +01:00
Alexandros Kozak 31107990dc Change : to true 2021-11-11 06:43:43 -08:00
Philipp Schmitt 8fc2b8b9a7
Update TOC 2021-11-11 15:23:58 +01:00
Philipp Schmitt 1bf99ed4cd
Replace IRC with gitter.im badge
https://github.com/zdharma-continuum/zinit/issues/29
2021-11-11 12:07:03 +01:00
Philipp Schmitt 6c072dc503
Update repo url 2021-11-10 18:44:53 +01:00
Philipp Schmitt 55fedda2de
Update url 2021-11-10 18:27:26 +01:00
Alexandros Kozak c63603f1e2 Suppress exit code when nearcolor is not available 2021-11-09 10:58:44 -08:00
Aaron Lichtman 9a5a4a5199
Delete FUNDING.yml 2021-11-01 04:54:26 -05:00
Aaron Lichtman 55073ac3b1
Merge pull request #2 from vladdoster/patch-1 2021-11-01 04:09:05 -05:00
vladislav doster a4cd9a4ec0
(maint): update links to point towards zdharma-contiuum 2021-11-01 04:08:13 -05:00
Sebastian Gniazdowski 817916dfa9 Update plugin.zsh (work dir setting by default). 2021-05-14 14:57:11 -05:00
Sebastian Gniazdowski a62d721aff
Merge pull request #215 from xPMo/patch-1
Blacklist zle-keymap-select widget
2021-01-21 17:57:34 +01:00
xPMo 6c1c00bba0
Blacklist zle-keymap-select widget
Fixes #214
2021-01-21 09:20:43 -06:00
Sebastian Gniazdowski be2f385453
Merge pull request #206 from xerus2000/patch-1
Fix oh-my-zsh guide in README.md
2020-11-26 12:01:05 +01:00
Janek f88a94b8fa
Fix oh-my-zsh guide in README.md 2020-10-08 11:14:36 +02:00
Sebastian Gniazdowski a47b508863 Revert "Merge pull request #198 from pushqrdx/master"
This reverts commit 52bd095088, reversing
changes made to 865566ce48.
2020-08-12 01:48:43 +02:00
Sebastian Gniazdowski 52bd095088
Merge pull request #198 from pushqrdx/master
Fix highlighting lost issues with tab completions and stack pop
2020-08-08 12:52:18 +02:00
pushqrdx 94717acab1 check for v5.4 and fallback for older versions
this commit addresses versions older than 5.4 by using older widget hook method
2020-08-08 12:46:01 +02:00
pushqrdx daf9b6c1fe check for appropriate zsh version
adds the check for minimum zsh version supporting `add-zle-hook-widget` for `zle-line-init`
2020-08-07 21:30:00 +02:00
pushqrdx 98876e4e8b fix for highlight loss issues
this commit fixes
1- highlighting lost after tab completion with no results
2- highlighting lost after popping from the stack
2020-08-07 17:30:02 +02:00
Sebastian Gniazdowski 865566ce48 plugin.zsh: Solve the permissions problems #185 2020-07-04 01:56:49 +02:00
Sebastian Gniazdowski 5317179cf4 highlight: Don't use the #i flag for non-extendedglob shells #179 2020-06-29 19:56:23 +02:00
Sebastian Gniazdowski 5d0e4fef45 highlight: Fix the OS X test #179 2020-06-29 10:58:39 +02:00
Sebastian Gniazdowski 19141c09f5 highlight: Definitely disable man chroma on Darwin #179 2020-06-28 18:10:55 +02:00
Sebastian Gniazdowski 3636ce9abd highlight: Correctly implement the #fff / rgb(f,f,f) feature #167 2020-06-23 13:03:21 +02:00
Sebastian Gniazdowski 4bdc45b506 plugin.zsh: Load zsh/nearcolor 2020-06-21 22:25:59 +02:00
Sebastian Gniazdowski d737097a5e highlight: FEATURE – #00ff00 and rgb(00,ff,00) etc. get colored in green
etc. #167
2020-06-21 22:22:12 +02:00
Sebastian Gniazdowski 29e1c986a1 plugin.zsh: A better condition #185 2020-06-21 18:15:55 +02:00
Sebastian Gniazdowski 6faeb7fc86 plugin.zsh: Don't use man chroma on OS X #179 2020-06-21 18:01:05 +02:00
Sebastian Gniazdowski 9f1087f3b4 *string-highlight: Support \' inside $'…' #190 2020-05-31 03:56:15 +02:00
Sebastian Gniazdowski 365e51e0e3 *highlight: Use patterns instead of regexes 2020-05-31 03:55:03 +02:00
Sebastian Gniazdowski b259daa347 *highlight: Don't set unnecessary option 2020-05-31 03:54:20 +02:00
Sebastian Gniazdowski 902cddc127 fast-highlight: Use emulate 2020-05-31 03:53:47 +02:00
Sebastian Gniazdowski a58aa4ef24 plugin.zsh: Use the work-dir, not the base-dir #185 2020-04-23 01:59:48 +02:00
Sebastian Gniazdowski 7108a135e1 *highlight: Recognize strace and ltrace 2020-04-20 20:14:33 +02:00
Sebastian Gniazdowski 89cdcfd855 plugin.zsh: Correct output file name 2020-04-16 16:11:35 +02:00
Sebastian Gniazdowski 118a9cafb3 plugin.zsh: Correct theme name 2020-04-16 16:10:10 +02:00
Sebastian Gniazdowski d38c611741 plugin.zsh: Correct theme name 2020-04-16 16:08:29 +02:00
Sebastian Gniazdowski a1cb6944ce plugin.zsh: Create secondary_theme.zsh 2020-04-16 16:05:42 +02:00
Sebastian Gniazdowski cb8aa8e3f5 *highlight,plugin.zsh,other: Default theme to have a secondary 2020-04-16 16:04:13 +02:00
Sebastian Gniazdowski f1e9456d0c *make-targets: Rename functions #184 2020-04-16 13:29:52 +02:00
Sebastian Gniazdowski 89afa554c3 *highlight: Include OS X Jiaweis in the man fix #135 2020-04-15 23:54:13 +02:00
Sebastian Gniazdowski 482ab87201 *highilight: No man chroma on OS X Catalina #135 2020-04-15 23:51:44 +02:00
Sebastian Gniazdowski a3242a9339 :chroma/* → →chroma/* 2020-04-14 20:06:04 +02:00
Sebastian Gniazdowski c4c419edb9 Revert "*highlight: Remove sudo support"
This reverts commit 303eeee818.
2020-04-02 19:05:33 +02:00
Sebastian Gniazdowski a066003db6
Update FUNDING.yml 2020-04-02 19:04:14 +02:00
Sebastian Gniazdowski 303eeee818 *highlight: Remove sudo support 2020-03-06 09:48:07 +01:00
Sebastian Gniazdowski 4c0e992f16 README.md 2020-02-25 12:13:58 +01:00
Sebastian Gniazdowski b0c0e9bcbf README.md
Fixes #176
2020-02-25 12:12:47 +01:00
Sebastian Gniazdowski e0f3a487f1 Revert "Revert "plugin.zsh: Always highlight, not only on an non-error widget call""
This reverts commit 4656034779.
2020-02-23 01:03:25 +01:00
Sebastian Gniazdowski 41c83eeac7 plugin.zsh: Fix forward-word incompatibility with zsh-autosuggestions
See: https://www.reddit.com/r/zsh/comments/f7w14o/
2020-02-23 01:02:03 +01:00
Sebastian Gniazdowski 08a4ce9695 plugin.zsh: Use emulate instead of bare setopt 2020-02-23 01:01:14 +01:00
Sebastian Gniazdowski 3f9dbd2664 -zinit.ch: Add -p,--parallel to `update' 2020-02-23 01:00:22 +01:00
Sebastian Gniazdowski 4656034779 Revert "plugin.zsh: Always highlight, not only on an non-error widget call"
This reverts commit bd4564c2f5.
2020-02-22 19:36:09 +01:00
Sebastian Gniazdowski 04a4b247a2 -git.ch: Utilize the --status option of .fast-run-git-command 2020-02-16 21:59:04 +01:00
Sebastian Gniazdowski a12906ca5e .fast-run-git-command: Support for --status option 2020-02-16 21:58:42 +01:00
Sebastian Gniazdowski 274012fd84 .fast-run-git-command: Remove unneeded quoting 2020-02-16 21:58:06 +01:00
Sebastian Gniazdowski a7f3f83972 -whatis.ch: A default style to limit blinking – thanks @camsteffen 2020-02-15 18:25:47 +01:00
Sebastian Gniazdowski 705bb211a1 -zinit.ch: Add `extract' ice 2020-02-15 18:22:04 +01:00
Cameron Steffen df3144002c Update IRC link in README 2020-02-13 20:44:23 +01:00
Sebastian Gniazdowski 94b6b5b8e5 -git.ch: Introduce regular file and option highlighting for `git mv' 2020-02-07 02:39:16 +01:00
Sebastian Gniazdowski 556a3dc642 main-chroma.ch: Ability to skip set of subcommands 2020-02-07 02:38:37 +01:00
Sebastian Gniazdowski 0f81857b7a main-chroma.ch: Introduce the alternate syntax in one place 2020-02-07 02:37:50 +01:00
Sebastian Gniazdowski 6358641181 -zplugin.ch → -zinit.ch,*highlight,plugin.zsh: Zplugin → Zinit rename 2020-02-02 19:35:57 +01:00
Sebastian Gniazdowski 3bc8839a68 -git.ch: Correctly verify branch for `checkout' 2020-02-02 08:42:58 +01:00
Sebastian Gniazdowski 34e0c652f1 -git.ch: Lower the cache timeout to 10 seconds 2020-02-02 08:42:26 +01:00
Sebastian Gniazdowski 461f717a14 -git.ch: Remove unneeded quoting 2020-02-02 08:41:43 +01:00
Sebastian Gniazdowski 71d50b9cfb -zplugin.ch: Zplugin → Zinit rename 2020-02-01 19:38:39 +01:00
Sebastian Gniazdowski 6bedf87660 -whatis.ch: Rename the autoload function, fixes #174 2020-01-26 23:45:06 +01:00
Sebastian Gniazdowski a5a4bb4181 _fast-theme: FEATURE – now also the XDG:… themes are being completed 2020-01-26 22:59:02 +01:00
Sebastian Gniazdowski 23033dfbf8 many: Rename autoload functions to follow the standard recommendations
See:
http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#namespacing
2020-01-26 22:50:35 +01:00
Sebastian Gniazdowski 429ace63e4 plugin.zsh: Standard-conformant $fpath extending 2020-01-25 00:14:18 +01:00
Sebastian Gniazdowski b7b0f61188 -zplugin.ch: Update the ice list 2020-01-15 21:36:06 +01:00
Sebastian Gniazdowski 1b045323ea -subversion.ch: Correctly autoload the function, fixes #173 2020-01-15 08:32:17 +01:00
Sebastian Gniazdowski 88135014e3 -subversion.ch: Fix the highlighting #173 2020-01-15 08:28:35 +01:00
Sebastian Gniazdowski bd3c6f70fa -sh.ch: Remove unneeded quoting #169 2020-01-15 05:25:55 +01:00
Sebastian Gniazdowski ad43154542 -zplugin.ch: Highlight --all for report' and -q for unload' 2020-01-14 02:49:37 +01:00
Sebastian Gniazdowski 1daabc2282 -zplugin.ch: Highlight snippets for all commands 2020-01-13 04:45:36 +01:00
Sebastian Gniazdowski 285e50fe78 -zplugin.ch: Highlight also snippets for delete, update 2020-01-13 04:31:44 +01:00
Sebastian Gniazdowski b2d46e7b46 plugin.zsh: Add FAST_HIGHLIGHT_VERSION parameter 2020-01-11 09:45:21 +01:00
Sebastian Gniazdowski 5351bd907e -zplugin.ch: Add options of update' and delete' 2020-01-11 04:17:36 +01:00
Sebastian Gniazdowski 7cb3d86615 -ruby.ch: Reset the state for the next option after -e
Related issue: #171
2020-01-10 20:41:47 +01:00
Sebastian Gniazdowski f3caac4506 -which.ch: Support here-string 2019-12-30 03:33:22 +01:00
Sebastian Gniazdowski 8acefd6ae2 -whatis.ch: Support here-string 2019-12-30 03:33:09 +01:00
Sebastian Gniazdowski 6945514e11 -subversion.ch: Support here-string 2019-12-30 03:32:55 +01:00
Sebastian Gniazdowski 6101f09247 -subcommand.ch: Support here-string 2019-12-30 03:32:44 +01:00
Sebastian Gniazdowski 3f6c55a71b -ssh.ch: Support here-string 2019-12-30 03:32:29 +01:00
Sebastian Gniazdowski 59ab419ae9 -source.ch: Support here-string 2019-12-30 03:32:15 +01:00
Sebastian Gniazdowski e15e97c4ba -sh.ch: Support here-string 2019-12-30 03:32:03 +01:00
Sebastian Gniazdowski aefdd1b6d6 -scp.ch: Support here-string 2019-12-30 03:31:48 +01:00
Sebastian Gniazdowski 19ec8c375b -ruby.ch: Support here-string 2019-12-30 03:31:35 +01:00
Sebastian Gniazdowski 1852dab768 -printf.ch: Support here-string 2019-12-30 03:31:20 +01:00
Sebastian Gniazdowski cbfeada3ad -perl.ch: Support here-string 2019-12-30 03:31:02 +01:00
Sebastian Gniazdowski 27b74e7830 -ogit.ch: Support here-string 2019-12-30 03:30:49 +01:00
Sebastian Gniazdowski 921c053a56 -nmcli.ch: Support here-string 2019-12-30 03:30:39 +01:00
Sebastian Gniazdowski 3630fe52a6 -nice.ch: Support here-string 2019-12-30 03:30:22 +01:00
Sebastian Gniazdowski c7e066179b -make.ch: Support here-string 2019-12-30 03:29:58 +01:00
Sebastian Gniazdowski 7556a65f84 -lab.ch: Support here-string 2019-12-30 03:29:44 +01:00
Sebastian Gniazdowski 3d008b686f -ionice.ch: Support here-string 2019-12-30 03:29:31 +01:00
Sebastian Gniazdowski a091802241 -hub.ch: Support here-string 2019-12-30 03:29:09 +01:00
Sebastian Gniazdowski cb70f5aede -grep.ch: Support here-string 2019-12-30 03:28:55 +01:00
Sebastian Gniazdowski 6495273ee8 -fast-theme.ch: Support here-string 2019-12-30 03:28:41 +01:00
Sebastian Gniazdowski 94cfb6ffc3 -example.ch: Support here-string 2019-12-30 03:28:23 +01:00
Sebastian Gniazdowski 565746a96e -docker.ch: Support here-string 2019-12-30 03:28:08 +01:00
Sebastian Gniazdowski 3720503f31 -awk.ch: Support here-string 2019-12-30 03:27:52 +01:00
Sebastian Gniazdowski fa7e25cc28 -autorandr.ch: Support here-string 2019-12-30 03:27:35 +01:00
Sebastian Gniazdowski 29d79759a2 -autoload.ch:: Support here-string 2019-12-30 03:27:13 +01:00
Sebastian Gniazdowski 2f0e992e7c -alias.ch: Support here-string 2019-12-30 03:26:20 +01:00
Sebastian Gniazdowski 778fc0fca3 main-chroma.ch: Support here-string #99 2019-12-30 03:07:12 +01:00
Sebastian Gniazdowski 8504cc28d7 -node.ch: Support here-string #99 2019-12-30 03:06:25 +01:00
Sebastian Gniazdowski 634ab24636 -git.ch: Correct highlight of directories 2019-12-03 11:04:04 +01:00
Sebastian Gniazdowski 917ec4c57b -git.ch: Add all options of `add' 2019-12-02 03:55:50 +01:00
Sebastian Gniazdowski 465a2f6de3 -git.ch: Use the style also for `add'. Response to: https://www.reddit.com/r/zplugin/comments/e3gy7s 2019-12-01 23:05:32 +01:00
Sebastian Gniazdowski 61ecaac48a -git.ch: Use path-sparator style. Response to: https://www.reddit.com/r/zplugin/comments/e3gy7s 2019-12-01 23:03:54 +01:00
Sebastian Gniazdowski 780568da1c -git.ch: Feature: add highlighting of the `add' git subcommand. 2019-12-01 22:32:44 +01:00
Sebastian Gniazdowski bb2da8f833 *ini-file: Update mode line 2019-11-24 11:57:41 +01:00
SugarSnack 7209cb0c33 Update README.md
Make compatible for users with the Oh My Zsh repository in a different location
2019-11-22 00:13:35 +01:00
Sebastian Gniazdowski c39c4675a6 Revert "plugin.zsh: Finally always highlight, not only on non-error widgets!"
This reverts commit 6965d962c9.
2019-11-16 01:52:57 +01:00
Sebastian Gniazdowski 6965d962c9 plugin.zsh: Finally always highlight, not only on non-error widgets! 2019-11-15 19:52:22 +01:00
Sebastian Gniazdowski bd4564c2f5 plugin.zsh: Always highlight, not only on an non-error widget call 2019-11-15 18:57:58 +01:00
Sebastian Gniazdowski 090977b7ce -zplugin.ch: Properly recognize ices that are both val and nval. Helps
especially to the z-a-bin-gem-node's `sbin' ice.
2019-11-15 17:23:23 +01:00
Sebastian Gniazdowski ac74c547a3 -zplugin.ch: Quote the array elements 2019-11-15 17:22:22 +01:00
Sebastian Gniazdowski d8e5bbe3da images: 203654.gif 2019-11-03 06:27:45 +01:00
Sebastian Gniazdowski fb6f0ab133 fast-theme: Add -q and -v options to the help 2019-11-03 06:25:55 +01:00
Sebastian Gniazdowski 892dd58b7a _fast-theme: Add 4 missing options 2019-11-03 06:23:55 +01:00
Sebastian Gniazdowski 644da6bbd3 fast-theme: Reformat the help text to 80 columns 2019-11-03 06:17:48 +01:00
Sebastian Gniazdowski bc58bd6786 Updated README.md 2019-11-01 01:32:48 +01:00
Sebastian Gniazdowski 651b69a13d -git.ch: Fix `checkout -b …' highlighting – it again wants *new* branch 2019-11-01 01:30:24 +01:00
Sebastian Gniazdowski 2f56658deb *highlight: Recognize `doas' as a precommand modifier
Issue #161
2019-10-29 19:04:36 +01:00
Sebastian Gniazdowski ca4f3b1422 tests: New test 2019-10-28 15:39:40 +01:00
Sebastian Gniazdowski 3666efb871 -zplugin.ch: Include the latest ices 2019-10-23 22:26:35 +02:00
Sebastian Gniazdowski 01471d8f29 *ini-file: Default name of the output hash 2019-10-23 17:37:40 +02:00
Sebastian Gniazdowski 6440fd970a plugin.zsh,*highlight,chroma/all: Rename to :chroma to avoid completing
Issue #157
2019-10-21 16:28:23 +02:00
Sebastian Gniazdowski 9a6f95c5a6 main-chroma.ch: Fix (workaround) the WSL bug #146, #153, #155, #158 2019-10-21 15:19:34 +02:00
Sebastian Gniazdowski 431ca9a355 main-chroma.ch: Update a debug print 2019-10-21 15:16:28 +02:00
Sebastian Gniazdowski 704cee14df main.zunit: Fix the test title 2019-10-14 08:12:24 +02:00
Sebastian Gniazdowski 66824e4a91 main.zunit: A new 'tr : \\n <<<$PATH' test 2019-10-14 08:11:18 +02:00
Sebastian Gniazdowski 076c94e7db main.zunit: Fix $'ls /bin/df\n # a comment\nls /usr/bin' test 2019-10-14 08:10:37 +02:00
Sebastian Gniazdowski fdfd837cf7 main.zunit: Fix ls /usr/bin/ls test 2019-10-14 08:09:56 +02:00
Sebastian Gniazdowski 5ec56d2140 main-chroma.ch: Remove a misleading comment 2019-10-14 08:09:27 +02:00
Sebastian Gniazdowski 26dc787ad6 plugin.zsh: Don't override yank-pop 2019-10-03 07:19:45 +02:00
Sebastian Gniazdowski 10d5f36865 plugin.zsh,*-highlight,-whatis.ch,-zplugin.ch: Update copyright notice 2019-09-27 05:21:39 +02:00
Sebastian Gniazdowski f150062fe4 -whatis.ch: Correctly handle the case when there's no `whatis' program 2019-09-27 05:17:30 +02:00
Sebastian Gniazdowski 6d4ced3064 -whatis.ch: Use print instead of echo 2019-09-27 05:16:45 +02:00
Sebastian Gniazdowski 7cb5e6936e -whatis.ch: Use LANG=C with whatis 2019-09-27 05:15:48 +02:00
Sebastian Gniazdowski d5da3dc023 -whatis.ch: Correct use of cache 2019-09-27 05:12:48 +02:00
Sebastian Gniazdowski a8868e473f -whatis.ch: Add emulate to the callback 2019-09-27 05:11:24 +02:00
Sebastian Gniazdowski 05381e1f98 -whatis.ch: Use FAST_HIGHLIGHT for cache 2019-09-27 04:04:54 +02:00
Sebastian Gniazdowski 85ce204cfc -zplugin.ch: New ice `reset' 2019-09-10 00:20:01 +02:00
Sebastian Gniazdowski 6b8a14e966 main.zunit: Add test 2019-09-04 11:38:59 +02:00
Sebastian Gniazdowski 715736398e main.zuinit: Add tests 2019-09-04 06:59:20 +02:00
Sebastian Gniazdowski 57fbac0462 -zplugin.ch: Recognize wrap-track'' ice 2019-08-30 22:29:07 +02:00
Sebastian Gniazdowski c75ee58003 Revert "*-highlight: Use [[ -v ... ]] test instead of $parameters"
This reverts commit aff7531bfa.

Plus also the same change for the math mode highlighting.

Issue #152
2019-08-21 22:10:00 +02:00
Sebastian Gniazdowski 581e75761c plugin.zsh: Shorter and nicer widget name prefix 2019-08-08 07:30:33 +02:00
Sebastian Gniazdowski cb0ee1755b *highlight: Add the new style `subtle-separator' to the no-theme setup
Issue #151
2019-08-07 15:38:37 +02:00
Grigorii Horos 4d895e05d4 Add posibility to set colors for user/host separator in ssh chroma 2019-08-07 15:33:54 +02:00
Sebastian Gniazdowski 89fa57b49a -zplugin.ch: Highlight the strings glued to the ice-mods
https://github.com/zdharma/zplugin/issues/88
2019-08-06 21:36:43 +02:00
Sebastian Gniazdowski e89ff7ea02 plugin.zsh: Update the $0 handling so that it fully follows the standard 2019-08-06 21:32:44 +02:00
Sebastian Gniazdowski 70b7686f63
Create FUNDING.yml 2019-08-06 21:18:33 +02:00
Sebastian Gniazdowski 6857cde2a7 *highlight: Usle zle -R not zle .redisplay 2019-08-06 19:38:50 +02:00
Sebastian Gniazdowski 37c9f9fac6 -git.ch: Directory is a correct `checkout' argument
Issue #150
2019-07-31 03:41:34 +02:00
Sebastian Gniazdowski 785abb5d3a plugin.zsh: Limit default colors to the first 8 if termcap[Co] < 256 2019-07-26 13:41:50 +02:00
Sebastian Gniazdowski 465a5b1776 -git.ch: Make `diff' accept also directories 2019-07-24 10:59:34 +02:00
Sebastian Gniazdowski ab78177ee2 -git.ch: Make the commit message length limit configurable (#149, #25)
via FAST_HIGHLIGHT[git-cmsg-len] field.
2019-07-20 21:27:23 +02:00
Sebastian Gniazdowski aa1d87f174 tests/main.zunit 2019-07-18 05:34:23 +02:00
Sebastian Gniazdowski c906d2dfdb *-highlight: Allow underscores in the exec's variable name 2019-07-18 05:10:53 +02:00
Sebastian Gniazdowski 1a5ab22665 zunit: First test for extended version of zunit (patch sent to upstream) 2019-07-18 03:07:26 +02:00
Sebastian Gniazdowski b16bf9d05d -git.ch: Temporary fix to `commit' – intepret -am like -m
Issue #147
2019-07-15 22:49:32 +02:00
Sebastian Gniazdowski 432057f306 -whatis.ch: zle -R is actually sufficient – optimize out zle .redisplay
Issue #145
2019-07-15 21:04:11 +02:00
Sebastian Gniazdowski 13e959c3be -whatis.ch: Fixed the zle .redisplay eating up a line of the display
Issue #145
2019-07-15 20:55:37 +02:00
Sebastian Gniazdowski 45b6516fad *-highlight: Math-mode highlighting now recognizes empty non-$ variables 2019-07-15 07:04:50 +02:00
Sebastian Gniazdowski 6ce9315064 -whatis.ch: Refactor <(...) code after an unsuccesful debug of #145 2019-07-15 04:15:35 +02:00
Sebastian Gniazdowski 75bf780bc5 plugin.zsh: Apply the non-256 color terminal detection to initial theme 2019-07-15 04:13:54 +02:00
Sebastian Gniazdowski 594c57bae1 plugin.zsh: /fshdbg() 2019-07-15 04:12:36 +02:00
Sebastian Gniazdowski 991bd292cf -sh.ch: Don't recurse if the -c argument comes from PREBUFFER
Issue #108
2019-07-14 22:58:47 +02:00
Sebastian Gniazdowski 0be7423875 *-highlight: Optimize-out 2 comparisons on /usr/bin/$var etc. support 2019-07-13 19:01:46 +02:00
Sebastian Gniazdowski 330615e98a *-highlight: Support for ${var} in e.g. /usr/bin/${var} 2019-07-13 18:55:34 +02:00
Sebastian Gniazdowski 36e7074df0 *-highlight: Support ${var:-val} expression on command position 2019-07-13 18:46:58 +02:00
Sebastian Gniazdowski 422ee87077 *-higlight: Divide long line in *-math-string 2019-07-13 18:38:31 +02:00
Sebastian Gniazdowski aff7531bfa *-highlight: Use [[ -v ... ]] test instead of $parameters 2019-07-13 18:36:46 +02:00
Sebastian Gniazdowski 056e2929dd *-highlight: Treat parameter declarations as assignments – for math mode 2019-07-13 18:35:28 +02:00
Sebastian Gniazdowski f3e094bdb8 -ssh.ch; Remove unneded `local mbegin mend match reply' 2019-07-13 08:29:57 +02:00
Sebastian Gniazdowski 77fc581dae *-highlight: Fix the problem with first letter being red also for eval
Issue #143
2019-07-13 08:08:28 +02:00
Sebastian Gniazdowski c4e8afd55b *-highlight: Also fix the first-red-letter problem for eval
Issue #143
2019-07-13 08:05:56 +02:00
Sebastian Gniazdowski 07e94544be *-highlight: Additional guards against running processings on PREBUFFER
Issue #108
2019-07-13 06:14:50 +02:00
Sebastian Gniazdowski ef78ab1799 *-highlight: Don't recurse if the string is from PREBUFFER
Issue #108
2019-07-13 06:12:21 +02:00
Sebastian Gniazdowski a4452c7504 -zplugin.ch: Explicit `delete' support with options --all, --clean 2019-07-13 05:13:40 +02:00
Sebastian Gniazdowski bed0e3a8a3 Updated README.md (added IRC Channel) 2019-07-10 00:18:55 +02:00
Sebastian Gniazdowski b168f61e57 -zplugin.ch: Include the dynamically added ices from ZPLG_EXTS 2019-07-09 07:35:36 +02:00
Sebastian Gniazdowski 24bc6eb3d5 -zplugin.ch: `update' has now its options (--all,-r,--reset) recognized 2019-07-04 23:42:12 +02:00
Sebastian Gniazdowski 08184b727d *-highlight: Fix `case' highlighting when the condition is (x) not x)
Issue #112
2019-07-04 21:52:59 +02:00
Sebastian Gniazdowski 47849ff7e8 *-highlight: Fix the problem with the literal NUL character (i.e. ^@)
Issue #137
2019-07-04 21:17:18 +02:00
Sebastian Gniazdowski 7043081a1b *-highlight: Do a recursive-highlighting of the backticks
Issue #143
2019-07-04 19:01:51 +02:00
Sebastian Gniazdowski 6fd28cbf89 -git.ch: Fix `checkout' highlighting – first arg can be of course a file 2019-07-03 20:16:13 +02:00
Sebastian Gniazdowski 03e341235f -zplugin.ch: Fix load & other subcommands (were always highlighting OK) 2019-07-02 00:31:33 +02:00
Sebastian Gniazdowski 092566a8e9 -zplugin.ch: Add incorrect-subtle highlighting for unmatched opts & args 2019-07-02 00:23:52 +02:00
Sebastian Gniazdowski 9a27ed7846 -zplugin.ch: Exact `snippet' highlighting 2019-07-01 21:36:21 +02:00
Sebastian Gniazdowski 9cc5786558 -zplugin.ch,*-higlight: Exact zplugin's `ice' highlighting & gathering 2019-07-01 21:35:17 +02:00
Sebastian Gniazdowski e72ec50f3f -zplugin.ch: Remove old -git.ch code 2019-07-01 21:32:23 +02:00
Sebastian Gniazdowski 848ae08fe1 Revert "-whatis.ch: Use man not whatis as it searches more paths; bases on $PATH"
This reverts commit c41b1557b0.
2019-07-01 21:03:36 +02:00
Sebastian Gniazdowski bc2654eb14 -zplugin.ch: Support for `uncompile' subcommand 2019-07-01 20:33:32 +02:00
Sebastian Gniazdowski 1fe6e68ceb -zplugin.ch: Exact highlighting to the unload' & report' subcommands 2019-07-01 16:26:51 +02:00
Sebastian Gniazdowski b6a0fca5b7 main-chroma: Small uplift to the debug messages 2019-07-01 16:24:22 +02:00
Sebastian Gniazdowski 10c3589a7c -zplugin.ch,*-highlight,plugin.zsh: Exact zplugin highlighing 2019-07-01 16:16:41 +02:00
Sebastian Gniazdowski ecad26700c -git.ch: `pull': fix recognition of --recurse-submodules option 2019-06-27 08:00:42 +02:00
Sebastian Gniazdowski 399f1b4302 -ogit.ch,plugin.zsh: Restore support for the old git chroma function
Issue #108
2019-06-26 12:56:56 +02:00
Sebastian Gniazdowski 1d2a86e2aa Updated README.md 2019-06-25 16:38:22 +02:00
61 changed files with 2594 additions and 1334 deletions

View file

@ -5,7 +5,7 @@
local -a TARGETS
_make-expandVars() {
.make-expandVars() {
local open close var val front='' rest=$1
while [[ $rest == (#b)[^$]#($)* ]]; do
@ -18,7 +18,7 @@ _make-expandVars() {
rest=${rest[3,-1]}
continue
;;
(\() # Variable of the form $(foobar)
(\() # Variable of the form $(foobar)
open='('
close=')'
;;
@ -71,7 +71,7 @@ _make-expandVars() {
}
_make-parseMakefile () {
.make-parseMakefile () {
local input var val target dep TAB=$'\t' tmp IFS=
while read input
@ -80,17 +80,51 @@ _make-parseMakefile () {
# TARGET: dependencies
# TARGET1 TARGET2 TARGET3: dependencies
([[*?[:alnum:]$][^$TAB:=%]#:[^=]*)
target=$(_make-expandVars ${input%%:*})
target=$(.make-expandVars ${input%%:*})
TARGETS+=( ${(z)target} )
;;
esac
done
}
if [[ -z "${FAST_HIGHLIGHT[chroma-make-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-make-cache-born-at] )) -gt 7 ]]; then
_make-parseMakefile
FAST_HIGHLIGHT[chroma-make-cache-born-at]="$EPOCHSECONDS"
FAST_HIGHLIGHT[chroma-make-cache]="${(j:;:)TARGETS}"
# Cache generated parsing for 1sec per session or globally if configured, per Makefile path.
if [[ -n "${FAST_HIGHLIGHT[chroma-make-cache-global]}" ]]; then
# Determine Makefile path.
# TODO: find a way to expand path and resolve alias - this cause deduplicated cache file.
local makefile_path
makefile_path=${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}
# If not absolute, resolve to absolute path
[[ $makefile_path != /* ]] && makefile_path="$PWD/$makefile_path"
# Generate a safe hash for the cache file name using sha1sum
local makefile_hash
makefile_hash=$(print -n -- "$makefile_path" | sha1sum | awk '{print $1}')
# Generate a sha1sum hash from the input variable
local input var val target dep TAB=$'\t' tmp IFS=
local input_hash
input_hash=$(print -n -- "$input" | sha1sum | awk '{print $1}')
# Generate the cache file path.
local cache_file
cache_file="/tmp/fast-highlight-make-cache-${makefile_hash}-${input_hash}"
if [[ ! -f $cache_file ]]; then
# Clean up old cache files.
rm -rf /tmp/fast-highlight-make-cache-${makefile_hash}-*
# Generate new cache file.
.make-parseMakefile "$input"
print -r -- "${(j:;:)TARGETS}" >| "$cache_file"
fi
FAST_HIGHLIGHT[chroma-make-cache]="$(<$cache_file)"
FAST_HIGHLIGHT[chroma-make-cache-born-at]="0"
else
if [[ -z "${FAST_HIGHLIGHT[chroma-make-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[chroma-make-cache-born-at] )) -gt 7 ]]; then
.make-parseMakefile
FAST_HIGHLIGHT[chroma-make-cache-born-at]="$EPOCHSECONDS"
FAST_HIGHLIGHT[chroma-make-cache]="${(j:;:)TARGETS}"
fi
fi
reply2=( "${(s:;:)FAST_HIGHLIGHT[chroma-make-cache]}" )

View file

@ -1,13 +1,13 @@
# Copyright (c) 2018 Sebastian Gniazdowski
#
# $1 - path to the ini file to parse
# $2 - name of output hash
# $3 - prefix for keys in the hash
# $2 - name of output hash (INI by default)
# $3 - prefix for keys in the hash (can be empty)
#
# Writes to given hash under keys built in following way: ${3}<section>_field.
# Values are values from ini file.
local __ini_file="$1" __out_hash="$2" __key_prefix="$3"
local __ini_file="$1" __out_hash="${2:-INI}" __key_prefix="$3"
local IFS='' __line __cur_section="void" __access_string
local -a match mbegin mend
@ -27,4 +27,4 @@ done < "$__ini_file"
return 0
# vim:ft=zsh:et
# vim:ft=zsh:sw=4:sts=4:et

View file

@ -26,11 +26,24 @@
typeset -ga __lines_list
local -a __response
if [[ -z "${FAST_HIGHLIGHT[$2-cache]}" || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then
FAST_HIGHLIGHT[$2-cache-born-at]="$EPOCHSECONDS"
if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
if [[ $1 == --status ]] {
integer __status=1
shift
}
if [[ -z ${FAST_HIGHLIGHT[$2-cache]} || $(( EPOCHSECONDS - FAST_HIGHLIGHT[$2-cache-born-at] )) -gt ${4:-5} ]]; then
FAST_HIGHLIGHT[$2-cache-born-at]=$EPOCHSECONDS
if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = true ]]; then
__response=( ${${(f)"$(command ${(Qz)${1#+}} 2>/dev/null)"}#$3} )
[[ "$1" = "+"* ]] && __lines_list+=( "${__response[@]}" ) || __lines_list=( "${__response[@]}" )
integer retval=$?
if (( __status )) {
__response=( $retval )
__lines_list=( $retval )
} else {
[[ "$1" = "+"* ]] && \
__lines_list+=( "${__response[@]}" ) || \
__lines_list=( "${__response[@]}" )
}
else
__lines_list=()
fi

38
.github/workflows/linting.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: Lint
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: |
brew install shellcheck shfmt zsh
pip3 install --user linkify-it-py mdformat mdformat-config mdformat-gfm mdformat-shfmt mdformat-tables mdformat-toc
- name: run mdformat
run: find . -name '*.md' -type f -print0 | xargs -0 -n1 -P4 python3 -m mdformat --check --wrap 120
- name: run shfmt
run: find . -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shfmt -bn -ci -d -i 2 -ln bash -s -sr
- name: run shellcheck
run: find . -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shellcheck
- name: "run zsh"
run: find . -name '*.zsh' -type f -print0 | xargs -0 -n1 -P4 zsh -n
- name: "run zcompile"
run: find . -name '*.zsh' -type f -exec zsh -fc "zcompile {}" \;

31
.github/workflows/zunit.yaml vendored Normal file
View file

@ -0,0 +1,31 @@
name: zunit
on: [push, pull_request]
jobs:
zunit:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt install -y zsh
mkdir bin
curl -fsSL https://raw.githubusercontent.com/molovo/revolver/v0.2.4/revolver > bin/revolver
curl -fsSL https://raw.githubusercontent.com/molovo/color/d8f91ab5fcfceb623ae45d3333ad0e543775549c/color.zsh > bin/color
git clone https://github.com/zunit-zsh/zunit.git zunit.git
cd zunit.git
git checkout b86c006f62db138a119e9be3a4b41e28876889b2
./build.zsh
cd ..
mv ./zunit.git/zunit bin
chmod u+x bin/{color,revolver,zunit}
- name: Unit tests
run: |
export PATH="$PWD/bin:$PATH"
zunit

8
.zunit.yml Normal file
View file

@ -0,0 +1,8 @@
tap: false
directories:
tests: tests
output: tests/_output
support: tests/_support
time_limit: 0
fail_fast: false
allow_risky: false

View file

@ -2,14 +2,14 @@
**2018-08-09**
Added ideal string highlighting FSH now handles any legal quoting and combination of `"`,`'` and `\` when
highlighting program arguments. See the introduction for an example (item #14).
Added ideal string highlighting FSH now handles any legal quoting and combination of `"`,`'` and `\` when highlighting
program arguments. See the introduction for an example (item #14).
**2018-08-02**
Global aliases are now supported:
![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/global-alias.png)
![image](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/global-alias.png)
**2018-08-01**
@ -27,74 +27,77 @@ set_fast_theme() {
}
```
If you have set theme before an update of styles (e.g. recent addition of bracket highlighting)
then please repeat `fast-theme {theme}` call to regenerate theme files. (**2018-08-09**: FSH
now has full user-theme support, refer to [appropriate section of README](#customization)).
If you have set theme before an update of styles (e.g. recent addition of bracket highlighting) then please repeat
`fast-theme {theme}` call to regenerate theme files. (**2018-08-09**: FSH now has full user-theme support, refer to
[appropriate section of README](#customization)).
**2018-07-30**
Ideal highlighting of brackets (pairing, etc.) no quoting can disturb the result:
![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif)
![image](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/brackets.gif)
`FAST_HIGHLIGHT[use_brackets]=1` to enable this feature (**2018-07-31**: not needed anymore, this highlighting is active by default).
`FAST_HIGHLIGHT[use_brackets]=1` to enable this feature (**2018-07-31**: not needed anymore, this highlighting is active
by default).
**2018-07-21**
Chroma architecture now supports aliases. You can have `alias mygit="git commit"` and when `mygit`
will be invoked everything will work as expected (Git chroma will be ran).
Chroma architecture now supports aliases. You can have `alias mygit="git commit"` and when `mygit` will be invoked
everything will work as expected (Git chroma will be ran).
**2018-07-11**
There were problems with Ctrl-C not working when using FSH. After many days I've found a fix
for this, it's pushed to master.
There were problems with Ctrl-C not working when using FSH. After many days I've found a fix for this, it's pushed to
master.
Second, asynchronous path checking (useful on e.g. slow network drives, or when there are many files in directory)
is now optional. Set `FAST_HIGHLIGHT[use_async]=1` to enable it. This saves some users from Zshell crashes
there's an unknown bug in Zsh.
Second, asynchronous path checking (useful on e.g. slow network drives, or when there are many files in directory) is
now optional. Set `FAST_HIGHLIGHT[use_async]=1` to enable it. This saves some users from Zshell crashes there's an
unknown bug in Zsh.
**2018-06-09**
New chroma functions: `awk`, `make`, `perl`, `vim`. Checkout the [video](https://asciinema.org/a/186234),
it shows functionality of `awk` compiling of code and NOT running it. Perl can do this too:
New chroma functions: `awk`, `make`, `perl`, `vim`. Checkout the [video](https://asciinema.org/a/186234), it shows
functionality of `awk` compiling of code and NOT running it. Perl can do this too:
[video](https://asciinema.org/a/186098).
**2018-06-06**
FSH gained a new architecture "chroma functions". They are similar to "completion functions", i.e. they
are defined **per-command**, but instead of completing that command, they colorize it. Two chroma exist,
for `Git` ([video](https://asciinema.org/a/185707), [video](https://asciinema.org/a/185811)) and for `grep`
FSH gained a new architecture "chroma functions". They are similar to "completion functions", i.e. they are defined
**per-command**, but instead of completing that command, they colorize it. Two chroma exist, for `Git`
([video](https://asciinema.org/a/185707), [video](https://asciinema.org/a/185811)) and for `grep`
([video](https://asciinema.org/a/185942)). Checkout
[example chroma](https://github.com/zdharma/fast-syntax-highlighting/blob/master/chroma/-example.ch) if you
would like to highlight a command.
[example chroma](https://github.com/zdharma/fast-syntax-highlighting/blob/master/chroma/-example.ch) if you would like
to highlight a command.
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/git_chroma.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/git_chroma.png)
**2018-06-01**
Highlighting of command substitution (i.e. `$(...)`) with alternate theme two themes at once! It was just white before:
Highlighting of command substitution (i.e. `$(...)`) with alternate theme two themes at once! It was just white
before:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cmdsubst.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/cmdsubst.png)
To select which theme to use for `$(...)` set the key `secondary=` in [theme ini file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini#L7).
All shipped themes have this key set (only the `default` theme doesn't use second theme).
To select which theme to use for `$(...)` set the key `secondary=` in
[theme ini file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini#L7). All shipped themes
have this key set (only the `default` theme doesn't use second theme).
Also added correct highlighting of descriptor-variables passed to `exec`:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/execfd.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/execfd.png)
**2018-05-30**
For-loop is highlighted, it has separate settings in [theme file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini).
For-loop is highlighted, it has separate settings in
[theme file](https://github.com/zdharma/fast-syntax-highlighting/blob/master/themes/free.ini).
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/for-loop.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/for-loop.png)
**2018-05-27**
Added support for 256-color themes. There are six themes shipped with FSH. The command to
switch theme is `fast-theme {theme-name}`, it has a completion which lists available themes
and options. Checkout [asciinema recording](https://asciinema.org/a/183814) that presents
the themes.
Added support for 256-color themes. There are six themes shipped with FSH. The command to switch theme is
`fast-theme {theme-name}`, it has a completion which lists available themes and options. Checkout
[asciinema recording](https://asciinema.org/a/183814) that presents the themes.
**2018-05-25**
@ -110,18 +113,18 @@ FAST_BLIST_PATTERNS[/mount/disk2/*]=1
Assign colorizing now spans to variables defined by `typeset`, `export`, `local`, etc.:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/typeset.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/typeset.png)
Also, `zcalc` has a separate math mode and specialized highlighting no more light-red colors because of
treating `zcalc` like a regular command-line:
Also, `zcalc` has a separate math mode and specialized highlighting no more light-red colors because of treating
`zcalc` like a regular command-line:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/zcalc.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/zcalc.png)
**2018-05-22**
Array assignments were still boring, so I throwed in bracked colorizing:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/array-assign.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/array-assign.png)
**2018-05-22**<a name="assign-update"></a>
@ -131,14 +134,14 @@ Assignments are no more one-colour default-white. When used in assignment, highl
- strings (double-quoted and single-quoted),
- math-mode (`val=$(( ... ))`).
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/assign.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/assign.png)
**2018-01-06**
Math mode is highlighted  expressions `(( ... ))` and `$(( ... ))`. Empty variables are colorized as red.
There are 3 style names (fields of
[FAST_HIGHLIGHT_STYLES](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L34)
hash) for math-variable, number and empty variable (error): `mathvar`, `mathnum`, `matherr`. You can set
them (like the animation below shows) to change colors.
Math mode is highlighted expressions `(( ... ))` and `$(( ... ))`. Empty variables are colorized as red. There are 3
style names (fields of
[FAST_HIGHLIGHT_STYLES](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L34) hash) for
math-variable, number and empty variable (error): `mathvar`, `mathnum`, `matherr`. You can set them (like the animation
below shows) to change colors.
![animation](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/math.gif)
![animation](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/math.gif)

View file

@ -1,441 +0,0 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
- [2018-08-14, received $30](#2018-08-14-received-30)
- [2018-08-03, received $8](#2018-08-03-received-8)
- [2018-08-02, received $3 from Patreon](#2018-08-02-received-3-from-patreon)
- [2018-07-31, received $7](#2018-07-31-received-7)
- [2018-07-28, received $2](#2018-07-28-received-2)
- [2018-07-25, received $3](#2018-07-25-received-3)
- [2018-07-20, received $3](#2018-07-20-received-3)
- [2018-06-17, received ~$155 (200 CAD)](#2018-06-17-received-155-200-cad)
- [2018-06-10, received $10](#2018-06-10-received-10)
- [2018-05-25, received $50](#2018-05-25-received-50)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Below are reports about what is being done with donations, i.e. which commits
are created thanks to them, which new features are added, etc. From the money
I receive I buy myself coffee and organize the time to work on the requested
features, sometimes many days in a row.
## 2018-08-14, received $30
* **Project**: **[Zplugin](https://github.com/zdharma/zplugin)**
* **Goal**: Create a binary Zsh module with one Zplugin optimization and optionally some
other features.
* **Status**: The job is done.
Thanks to this donation I have finally started to code **[binary Zplugin module](
https://github.com/zdharma/zplugin#quick-start-module-only)**, which is a big step onward
in evolution of Zplugin. I've implemented and published the module with 3 complete
features: 1) `load` optimization, 2) autocompilation of scripts, 3) profiling of script
load times.
Commit list:
```
2018-08-22 7b96fad doc: mod-install.sh
2018-08-22 ba1ba64 module: Update zpmod usage text
2018-08-22 b0d72e8 zplugin,*autoload: `module' command, manages new zdharma/zplugin module
2018-08-22 706bbb3 Update Zsh source files to latest
2018-08-20 b77426f module: source-study builds report with milliseconds without fractions
2018-08-20 c3cc09b module: Updated zpmod_usage, i.a. with `source-study' sub-command
2018-08-20 6190295 module: Go back to subcommand-interface to `zpmod'; simple option parser
2018-08-20 881005f module: Report on sourcing times is shown on `zpmod -S`. Done generation
2018-08-19 e5d046a module: Correct conditions on zwc file vs. script file (after stats)
2018-08-19 1282c21 module: Duration of sourcing a file is measured and stored into a hash
2018-08-18 e080153 module: Overload both `source' and `.' builtins
2018-08-18 580efb8 module: Invoke bin_zcompile with -U option (i.e. no alias expansion)
2018-08-18 b7d9836 module: Custom `source' ensures script is compiled, compiles if not
2018-08-18 1e75a47 module: Code cleanup, vim folding
2018-08-18 a4a02f3 module: Finally working `source'/`.' overload (used options translating)
2018-08-16 99bba56 module: zpmod_usage gained content
2018-08-16 04703cd module: Add the main builtin zpmod with report-append which is working
2018-08-16 cd6dc19 module: my_ztrdup_glen, zp_unmetafy_zalloc
2018-08-16 6d44e36 module: Cleanup, `source' overload after patron leoj3n restarted module
```
## 2018-08-03, received $8
* **Project**: **[zdharma/history-search-multi-word](https://github.com/zdharma/history-search-multi-word)**
* **Goal**: Allow calling `zle reset-prompt` (Zshell feature).
* **Status**: The job is done.
A user wanted to be able to call `reset-prompt` Zshell widget without disturbing my project
`history-search-multi-word`. I've implemented the necessary changes to HSMW.
Commit list:
```
2018-08-04 9745d3d hsmw: reset-prompt-protect zstyle allow users to run zle reset-prompt
2018-08-04 ce48a53 hsmw: More typo-like lackings of % substitution
2018-08-04 7e2d79b hsmw: A somewhat typo, missing % substitution
```
## 2018-08-02, received $3 from Patreon
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: No goal set up.
* **Status**: Bug-fixing work.
I did bug-fixing run on `fast-syntax-highlighting`, spotted many small and sometimes important things to
improve. Did one bigger thing added global-aliases functionality.
Commit list:
```
2018-08-02 1e854f5 -autoload.ch: Don't check existence for arguments that are variables
2018-08-02 14cdc5e *-string-*: Support highlighter cooperation in presence of $PREBUFFER
2018-08-02 2d8f0e4 *-highlight: Correctly highlight $VAR, $~VAR, ${+VAR}, etc. in strings
2018-08-02 e3032d9 *-highlight: ${#PREBUFFER} -> __PBUFLEN, equal performance
2018-08-02 f0a7121 *-highlight: Make case conditions and brackets highlighter compatible
2018-08-02 781f68e *-highlight: Recognize more case-item-end tokens
2018-08-02 206c122 *-highlight: Remove unused 4th __arg_type
2018-08-02 c6da477 *-string-*: Handle 'abc\' no slash-quoting here. Full quoting support
2018-08-02 52e0176 *-string-*: Fix bug, third level was getting wrong style
2018-08-02 5edbfae -git.ch: Support "--message=..." syntax (commit)
2018-08-02 669d4b7 -git.ch: Handle "--" argument (stops options)
2018-08-02 4fae1f2 -make.ch: Handle make's -f option
2018-08-02 3fd32fe -make.ch: Handle make's -C option
2018-08-02 31751f5 -make.ch: Recognize options that obtain argument
2018-08-02 e480f18 -make.ch: Fix reply-var clash, gained consistency
2018-08-02 0e8bc1e Updated README.md
2018-08-02 eee0034 images: global-alias.png
2018-08-02 00b41ef *-highlight,themes,fast-theme: Support for global aliases #41
```
## 2018-07-31, received $7
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: Implement ideal brackets highlighting.
* **Status**: The job is done.
When a source code is edited e.g. in `Notepad++` or some IDE, then most often brackets are somehow matched to
each other, so that the programmer can detect mistakes. `Fast-syntax-highlighting` too gained that feature. It
was done in such a way that FSH cannot make any mistake, colors will perfectly match brackets to each other.
Commit list:
```
2018-07-31 2889860 *-highlight: Correct place to initialize $_FAST_COMPLEX_BRACKETS
2018-07-31 2bde2a9 Performance status -15/8/8
2018-07-31 5078261 *-highlight,README: Brackets highlighter active by default
2018-07-31 2ee3073 *-highlight,*string-*: Brackets in [[..]], ((..)), etc. handled normally
2018-07-31 776b12d plugin.zsh: $_ZSH_HIGHLIGHT_MAIN_CACHE -> $_FAST_MAIN_CACHE
2018-07-30 2867712 plugin.zsh: Fix array parameter created without declaring #43
2018-07-30 cbe5fc8 Updated README.md
2018-07-30 2bd3291 images: brackets.gif
2018-07-30 ef23a96 *-string-*: Bug-fix, correctly use theme styles
2018-07-30 9046f82 plugin.zsh: Attach the new brackets highlighter; F_H[use_brackets]=1
2018-07-30 b33a5fd fast-theme: Support 4 new styles (for brackets)
2018-07-30 a03f004 themes: Add 4 new styles (brackets)
2018-07-30 2448cdc *-string-*: Additional highlight of bracket under cursor; more styles
2018-07-30 5e1795e *-string-*: Highlighter for brackets, handles all quotings; detached
```
## 2018-07-28, received $2
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: Distinguish file and directory when highlighting
* **Status**: The job is done.
A user requested that when `fast-syntax-highlighting` colorizes the command line it should use different
styles (e.g. colors) for token that's a *file* and that's a *directory*. It was a reasonable idea and I've
implemented it.
Commit list:
```
2018-07-28 7f48e04 themes: Extend all themes with new style `path-to-dir'
2018-07-28 c7c6a91 fast-theme: Support for new style `path-to-dir'
2018-07-28 264676c *-highlight: Differentiate path and to-dir path. New style: path-to-dir
```
## 2018-07-25, received $3
* **Project**: **[zdharma/zshelldoc](https://github.com/zdharma/zshelldoc)**
* **Goal**: Implement documenting of used environment variables.
* **Status**: The job is done.
Zshelldoc generates code-documentation like Doxygen or Javadoc, etc. User requested a
new feature: the generated docs should enumerate environment variables used and/or
exported by every function. Everything went fine and this feature has been implemented.
Commit list:
```
2018-07-26 f63ea25 Updated README.md
2018-07-26 3af0cf7 *detect: Get `var' from ${var:-...} and ${...:+${var}} and other subst
2018-07-25 2932510 *adoc: Better language in output document (about exported vars) #5
2018-07-25 f858dd8 *adoc: Include (in the output document) data on env-vars used #5
2018-07-25 80e3763 *adoc: Include data on exports (environment) in the output document #5
2018-07-25 ca576e2 *detect: Detect which env-vars are used, store meta-data in data/ #5
2018-07-25 f369dcc *detect: Function `find-variables' reported "$" as a variable, fixed #5
2018-07-25 e243dab *detect: Function `find-variables' #5
2018-07-25 5b34bb1 *transform: Detect exports done by function/script-body, store #5
```
## 2018-07-20, received $3
* **Project**: **[zdharma/zshelldoc](https://github.com/zdharma/zshelldoc)**
* **Goal**: Implement stripping of leading `#` char from functions' descriptions.
* **Status**: The job is done.
A user didn't like that functions' descriptions in the JavaDoc-like document (generated with Zshelldoc) all
contain a leading `#` character. I've added stripping of this character (it is there in the processed source
code) controlled by a new Zshelldoc option.
Commit list:
```
2018-07-20 172c220 zsd,*adoc,README: Option --scomm to strip "#" from function descriptions
```
## 2018-06-17, received ~$155 (200 CAD)
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: No goal set up.
* **Status**: Done intense research.
I've created 2 new branches: `Hue-optimization` (33 commits) and `Tidbits-feature` (22 commits). Those were
branches with architectural changes and extraordinary features. The changes yielded to be too slow, and I had
to withdraw the merge. Below are fixing and optimizing commits (i.e. the valuable ones) that I've restored
from the two branches into master.
Commit list:
```
2018-07-21 dab6576 *-highlight: Merge-restore: remove old comments
2018-07-21 637521f *-highlight: Merge-restore: a threshold on # of zle .redisplay calls
2018-07-21 4163d4d *-highlight: Merge-restore: optimize four $__arg[1] = ... cases
2018-07-21 0f01195 *-highlight: Merge-restore: can remove one (Q) dequoting
2018-07-21 39a4ec6 *-highlight: Merge-restore: $v = A* is faster than $v[1] = A, tests:
2018-07-21 99d6b33 *-highlight: Merge-restore: optimize-out ${var:1} Bash syntax
2018-07-21 719c092 *-highlight: Merge-restore: allow $V/cmd, "$V/cmd, "$V/cmd", "${V}/cmd"
2018-07-21 026941d *-highlight: Merge-restore: stack pop in single instruction, not two
2018-07-21 3467e3d *-highlight: Merge-restore: more reasonable redirection-detecting code
2018-07-21 00d25ee *-highlight: Merge-restore: one active_command="$__arg" not needed (?)
2018-07-21 1daa6b3 *-highlight: Merge-restore: simplify ; and \n code short-paths
2018-07-21 55d65be *-highlight: Merge-restore: proc_buf advancement via patterns (not (i))
2018-07-21 cc55546 *-highlight: Merge-restore: pattern matching to replace (i) flag
```
## 2018-06-10, received $10
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: No goal set up.
* **Status**: Done intense experimenting.
I was working on *chromas* command-specific colorization. I've added `which` and
`printf` colorization, then added asynchronous path checking (needed on slow network
drives), then coded experimental `ZPath` feature for chromas, but it couldn't be optimized
so I had to resign of it.
Commit list:
```
2018-06-12 c4ed1c6 Optimization the same idea as in previous patch, better method
2018-06-12 c36feef Optimization a) don't index large buffer, b) with negative index
2018-06-12 2f03829 Performance status 2298 / 1850
2018-06-12 14f5159 New working feature ZPath. It requires optimization
2018-06-12 e027c40 -which.ch: One of commands can apparently return via stderr (#27)
2018-06-11 5b8004f New chroma `ruby', works like chroma `perl', checks syntax via -ce opts
2018-06-10 ca2e18b *-highlight: Async path checking has now 8-second cache
2018-06-10 e071469 *-highlight: Remove path-exists queue clearing
2018-06-10 5a6684c *-highlight: Support for asynchronous path checking
2018-06-10 1d7d6f5 New chroma: `printf', highlights special sequences like %s, %20s, etc.
2018-06-10 8f59868 -which.ch: Update main comment on purpose of this chroma
2018-06-10 5f4ece2 -which.ch: Added `whatis', it has only 1st line if output used
2018-06-10 e2d173e -which.ch: Uplift: handle `which' called on a function, /usr/bin/which
```
## 2018-05-25, received $50
* **Project**: **[zdharma/fast-syntax-highlighting](https://github.com/zdharma/fast-syntax-highlighting)**
* **Goal**: No goal set up.
* **Status**: New ideas and features.
I was working from May, 25 to June, 9 and came up with key ideas and implemented them. First were *themes*
that were very special because they were using `INI` files instead of some Zsh-script format. Creating themes
for `fast-syntax-highlighting` is thus easy and fun. Then I came up with *chromas*, command-specific
highlighting, which redefine how syntax-highlighting for Zshell works detailed highlighting for e.g. Git
became possible, the user is informed about e.g. a mistake even before running a command. Overall 178 commits
in 16 days.
```
2018-06-09 3f72e6c -git.ch: `revert' works almost like `checkout', attach `revert' there
2018-06-09 b892743 Updated CHROMA_GUIDE.adoc
2018-06-09 f05643d Revert "Revert "Updated CHROMA_GUIDE.md""
2018-06-09 729bf7f Revert "Revert "CHROMA_GUIDE: Remove redundant comments, uplift""
2018-06-09 48a4e0c Revert "CHROMA_GUIDE: Remove redundant comments, uplift"
2018-06-09 55ede0a Revert "Updated CHROMA_GUIDE.md"
2018-06-09 17a28ba New chroma `-docker.ch' that verifies image ID passed to `image rm'
2018-06-09 868812a -make.ch,*-make-targets: Check Makefile exists, use 7 second cache, #24
2018-06-09 73df278 -sh.ch: Attach fish, has -c option, though different syntax, let's try
2018-06-09 3a73b8e Updated CHROMA_GUIDE.md
2018-06-09 29d04c8 CHROMA_GUIDE: Remove redundant comments, uplift
2018-06-09 22ce1d8 -sh.ch,*-highlight: Attach to 2 other shells, Zsh and Bash
2018-06-09 f54e44f New chroma `-sh.ch', colorizes code passed to `sh' with -c option
2018-06-09 f5d2375 CHROMA_GUIDE: Add example code block (rendered broken in mdown)
2018-06-09 08f4b28 CHROMA_GUIDE: Switch to asciidoc (rename)
2018-06-09 4e03609 CHROMA_GUIDE.md
2018-06-09 bbcf2d6 -source.ch: Word "source" should be highlighted as builtin
2018-06-09 6739b8b New chroma `source' to handle . and source builtins
2018-06-09 b961211 gitignore: ignore more paths
2018-06-09 59d5d09 Updated README.md
2018-06-09 f6d4d19 Updated README.md
2018-06-09 eb31324 Update README.md (figlet logo)
2018-06-09 71dcc5f Performance status 298 / 479
2018-06-09 00c5f8f *-highlight: Add comments
2018-06-09 232903c -awk.ch: Highlight `sub' function, not working {, } highlighting
2018-06-09 b5241ba *-highlight: Much better $( ) recursion, would say problems-free, maybe
2018-06-08 6c69437 *-highlight: Larger buffer (110 -> 250) for $( ) matching
2018-06-08 f2b7a96 -awk.ch: Syntax check code passed to awk. Awk is very forgiving, though
2018-06-08 c53d8ba -vim.ch: Pass almost everything to big-loop, check if vim exists
2018-06-08 7fbf7cd chroma: New chroma `vim', shows last opened files under prompt
2018-06-08 06e4570 gitignore: Extend .gitignore
2018-06-08 3184ba1 chroma: All chroma functions end chroma mode on e.g. | and similar
2018-06-08 070077d *-highlight,-example.ch: Rename arg_type -> __arg_type, use it to end
2018-06-08 6c2411e -awk.ch: Use the new theme style `subtle-bg'
2018-06-08 9ec8d63 themes: All themes (remaining 4) to support `subtle-bg' style
2018-06-08 66e848b fast-theme: New theme key `subtle-bg', default & clean.ini support it
2018-06-08 1e794f9 -awk.ch: More keywords highlighted
2018-06-08 f3bbaca -awk.ch: Don't highlight keywords when they only contain proper keyword
2018-06-08 e4d5283 -awk.ch: Fix mistake (indices), was highlighting 1 extra trailing letter
2018-06-08 eebbb19 -awk.ch: Initialize FSH_LIST
2018-06-08 8ec24ca *-highlight: Missing math function for awk
2018-06-08 d8e423a -awk.ch: Highlight more keywords, via more general code
2018-06-07 ee26e66 Commit missing -fast-make-targets
2018-06-07 9d4f2b5 New chroma `-awk.ch', colorizes regex characters and a keyword (print)
2018-06-07 def5133 -example.ch: Add comments
2018-06-07 f31a2d0 New chroma -make.ch, verifies if target is correct
2018-06-07 623b8ce -perl.ch: Use correct keys in FAST_HIGHLIGHT hash
2018-06-07 090f420 themes: Make all themes provide {in,}correct-subtle styles
2018-06-07 2201fb6 New -perl.ch chroma, syntax-checks perl code; 2 new theme entries
2018-06-06 4b9598e *-highlight: Fix bug in math highlight allow variables starting with _
2018-06-06 708afec *-highlight: Fix FAST_BLIST_PATTERNS not expanding path to absolute one
2018-06-06 caef05a -example.ch: Update, fix typos, remove unused code
2018-06-06 3fb192a Updated README.md
2018-06-06 6de0c82 images: git_chroma.png
2018-06-06 2852fdd -grep.ch (new): Special highlighting for grep -grep.ch chroma function
2018-06-06 f216785 -example.ch: Added comments
2018-06-06 4ab5b36 -example.ch: Add comments
2018-06-06 380cd12 -example.ch: Added comments
2018-06-06 c8947cc -example.ch: Add comments
2018-06-06 f2e273e -example.ch: Add comments
2018-06-06 2f3565b plugin.zsh: Fix parse error
2018-06-06 4f1a9bd plugin.zsh: Added $fpath handling, to match what README contains
2018-06-06 cc9adb5 -example.ch: Change and extend comments
2018-06-06 3128fff -git.ch: More intelligent `checkout' highlighting ref is first
2018-06-06 4b6f54b -git.ch: Support for `checkout' subcommand
2018-06-06 1930d37 -example.ch: Added example chroma function
2018-06-05 d79cd85 -git.ch: Add comments
2018-06-05 1473c9e -git.ch: Add comments
2018-06-05 0cb1419 -git.ch: Message passed after -m is checked for the 72 chars boundary
2018-06-05 3f99944 -git.ch: Architectural uplift of git chroma
2018-06-05 e044d13 -git.ch: Single place to add entry to $reply (target: region_highlight)
2018-06-05 3a84364 -git.ch: Handle quoted non-option arguments, also partly quoted: "abc
2018-06-05 d635bf4 -fast-run-git-command, it handles cache automatically, decimates source
2018-06-05 102ea78 -git.ch: Smart handling of `git push', remotes and branches are verified
2018-06-04 be88850 Performance status [+] 39+77=116 / -26+24=-2
2018-06-04 0e033f8 Experimental chroma support, currently active only on command `git'
2018-06-04 43ae221 *-highlight: Emacs mode-line
2018-06-04 938ad29 test: New "-git" parsing option, test results, -git.ch included
2018-06-04 e433fbc fast-theme: Explicitly return 0; added Emacs mode-line
2018-06-04 66e9b3c *-highlight: Detection of $( ) now doesn't go for $(( )) as a candidate
2018-06-04 488a580 chroma: Empty chroma function for `git'
2018-06-04 f54d770 *-highlight: Rename $cur_cmd to $active_command
2018-06-04 3f24e68 *-highlight: Make sudo and always-block compatible with `case' handling
2018-06-02 cd82637 themes: forest.ini to support 3 new `case' styles
2018-06-02 e1e993e themes: safari.ini & zdharma.ini to support 3 new `case' styles
2018-06-02 2e78a02 themes: clean.ini & default.ini to support 3 new `case' styles
2018-06-02 c1c3aab themes: free.ini to support 3 new `case' styles
2018-06-02 70a7e18 fast-theme,*-highlight: 3 new styles for `case' higlighting
2018-06-02 8d90dc2 *-highlight: Support for `case' highlighting
2018-06-02 10d291c *-highlight: Softer state manipulation, less rigid =1 etc. assignments
2018-06-02 6159507 *-highlight: Don't highlight closing ) with style `assign'
2018-06-02 1fc2450 *-highlight: One complex math command optimization, top of the loop
2018-06-02 cc49247 *-highlight: Fix improper state after assignment (command | regular)
2018-06-02 02942b8 Updated README.md
2018-06-02 5e28259 images: eval_cmp.png
2018-06-02 df92fed *-highlight: Fix removal of trailing "/' when recursing in eval
2018-06-02 4f61938 Performance status 46 / 44
2018-06-02 a5ade0e *-highlight: Recursive highlighting of eval string argument
2018-06-02 e91847b *-highlight: Don't recurse when not at main *-process call
2018-06-02 fca8603 *-highlight: Support assignments of arrays when key is taken from array
2018-06-02 5d70f01 *-highlight: Math highlighting recognizes ${+VAR}
2018-06-02 c48eb0d *-highlight: Math colorizing recognizes variables in braces ${HISTISZE}
2018-06-02 53dd85a *-highlight: Allow -- for precommand modifiers command & exec
2018-06-02 d9fe110 *-highlight: Detect globbing also when `##' occurs
2018-06-02 55c923d Performance status 132 / 66
2018-06-02 3bd8f07 themes: safari.ini to have globbing color specifically selected
2018-06-02 2b55260 themes: free.ini to have globbing color specifically selected
2018-06-02 494868e themes: clean.ini to have globbing color specifically selected
2018-06-01 fca6b3d images: herestring.png #9
2018-06-01 f9842c1 themes: forest.ini to use underline instead of bg color #9
2018-06-01 c25c539 themes: Small tune-up of forest & zdharma themes for here-string #9
2018-06-01 988d504 themes: Rudimentary (all same) configuration of here-string tokens #9
2018-06-01 99842d2 fast-theme,*-highlight: Support for here-string, can use bg color #9
2018-06-01 f739c30 Updated README.md
2018-06-01 7fa8451 images: execfd.png execfd_cmp.png
2018-06-01 d7384f1 themes: All themes gained `exec-descriptor=` key, now supported by code
2018-06-01 d66d140 themes: Fix improper effect of s/red/.../ substitution in clean,forest
2018-06-01 f7ee5e2 fast-theme,*-highlight: Support highlighting of {FD} etc. passed to exec
2018-06-01 e5c5534 *-highlight: Proper states for precmd (command,exec) option handling
2018-06-01 647b198 images: New cmdsubst.png
2018-06-01 74bdc4c Updated README.md
2018-06-01 86eb15e images: theme.png
2018-06-01 5169e82 Updated README.md
2018-06-01 1c462b7 Updated README.md
2018-06-01 4c21da4 images: cmdsubst.png
2018-06-01 b39996e *-highlight: Switch theme to secondary when descending into $() #15
2018-06-01 bf96045 themes: Equip all themes with key `secondary' (an alternate theme) #15
2018-06-01 aa1b112 fast-theme: Generate secondary theme (from key `secondary' in theme) #15
2018-06-01 6dd3bd3 *-highlight: Support for multiple active themes #15
2018-06-01 8a32944 *-highlight: Fix "$() found?" comparison
2018-06-01 3651605 *-highlight: Significant change: the parser is called recursively on $()
2018-05-31 882d88b test,*-highlight: New -ooo performance test; highlighter takes arguments
2018-05-31 5ba1178 *-highlight: Optimization - compute __arg length once
2018-05-30 b2a0126 *-highlight: Allow multiple separate options for `command', `exec' (#10)
2018-05-30 5804e9a *-highlight: Correct state after option for precommand (#10)
2018-05-30 1247b64 *-highlight: Simpler and more accurate option-testing for exec, command (#10)
2018-05-30 d87fed4 *-highlight: Correctly highlight options for `command' and `exec' (#10)
2018-05-30 8c3e75e *-highlight: Double-hyphen (--) stops option recognition and colorizing
2018-05-30 1c5a56c *-highlight: Support ${VAR} at command position (not only $VAR)
2018-05-30 f19d761 Updated README.md
2018-05-30 4a27351 images: for-loop
2018-05-30 4d650de themes: zdharma.ini to support for-loop
2018-05-30 45cafbc themes: safari.ini to support for-loop
2018-05-30 8bb9ee0 themes: free.ini to support for-loop
2018-05-30 f25a059 themes: forest.ini to support for-loop
2018-05-29 093d79e themes: default.ini to support for-loop
2018-05-29 446cb7b clean.ini,fast-theme: Clean-theme & theme subsystem to support for-loop
2018-05-29 1bb701f *-highlight: Move $variable highlighting from case to if-block
2018-05-29 b8413e9 *-highlight: For-loop highlighting, working, needs few upgrades
2018-05-28 7bec6e5 *-highlight: Three more simple vs. complex math operation optimizations
2018-05-27 baae683 *-highlight: Optimise complex math command into single one with & and ~
2018-05-27 2dc3103 *-highlight: Optimise complex math command into single one with & and ~
2018-05-27 291f905 _fast-theme: Update -t/--test description
2018-05-27 ec305f6 fast-theme: Help message treats about -t/--test
2018-05-27 0e1d19a Updated README.md
2018-05-27 5c3c911 Updated README.md
2018-05-26 76af248 themes: A fix for zdharma theme, 61 -> 63, a lighter color for builtins
2018-05-26 8eca0f2 *fast-theme: Ability to test theme after setting it (-t/--test)
2018-05-26 d3a7922 *-highlight: Fix in_array_assignment setting when closing ) found
2018-05-26 796c482 *-highlight: Make parameters' names exotic blank-var detection to work
2018-05-26 ae3913f _fast-theme: Complete theme names
2018-05-26 d212945 *-highlight,plugin.zsh,default.ini: Uplift of fg=112-fix code
2018-05-26 ee56f65 *-highlight,plugin.zsh: Final fix for fg=112 assignment  use zstyle
2018-05-26 391f5a4 fast-theme: Set `theme' zstyle in `:plugin:fast...' to given theme
2018-05-26 e0dc086 plugin.zsh: Fix the fg=112 assignment done for `variable' style
2018-05-26 17c9286 Updated README.md
2018-05-26 4774c1c fast-theme: Add completion for this function
2018-05-26 d971f39 fast-theme: Detect lack of theme name in arguments
2018-05-26 74f0d4d fast-theme: Use standard option parsing (zparseopts) and typical options
2018-05-26 d9c6180 New theme: `forest'
2018-05-26 419c156 New theme: `zdharma'
2018-05-26 a7735df gitignore
2018-05-26 99db69a New theme: `free'
2018-05-26 73619ff New theme: `clean'
2018-05-25 52307fb Theme support, 1 extra theme `safari'
2018-05-25 41df55b *-highlight: (k) subscript flag is sufficient, no need for (K)
2018-05-25 cb21c05 Updated README.md
2018-05-25 a580cff *-highlight: FAST_BLIST_PATTERNS
```

115
README.md
View file

@ -1,16 +1,10 @@
[![paypal](https://img.shields.io/badge/-Donate-yellow.svg?longCache=true&style=for-the-badge)](https://www.paypal.me/ZdharmaInitiative)
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D54B3S7C6HGME)
[![patreon](https://img.shields.io/badge/-Patreon-orange.svg?longCache=true&style=for-the-badge)](https://www.patreon.com/psprint)
<br/>New: You can request a feature when donating, even fancy or advanced ones get implemented this way. [There are
reports](DONATIONS.md) about what is being done with the money received.
# Fast Syntax Highlighting (F-Sy-H)
# Fast Syntax Highlighting (F-Sy-H) [![Gitter][gitter-image]][gitter-link]
Feature rich syntax highlighting for Zsh.
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/highlight-much.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/highlight-much.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -24,18 +18,18 @@ Feature rich syntax highlighting for Zsh.
- [Performance](#performance)
### Other Contents
- [License](https://github.com/zdharma/fast-syntax-highlighting/blob/master/LICENSE)
- [Changelog](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHANGELOG.md)
- [Theme Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/THEME_GUIDE.md)
- [Chroma Guide](https://github.com/zdharma/fast-syntax-highlighting/blob/master/CHROMA_GUIDE.adoc)
- [License](https://github.com/zdharma-continuum/fast-syntax-highlighting/blob/master/LICENSE)
- [Changelog](https://github.com/zdharma-continuum/fast-syntax-highlighting/blob/master/CHANGELOG.md)
- [Theme Guide](https://github.com/zdharma-continuum/fast-syntax-highlighting/blob/master/THEME_GUIDE.md)
- [Chroma Guide](https://github.com/zdharma-continuum/fast-syntax-highlighting/blob/master/CHROMA_GUIDE.adoc)
# News
* 15-06-2019
- A new architecture for defining the highlighting for **specific commands**: it now
uses **abstract definitions** instead of **top-down, regular code**. The first effect
is the highlighting for the `git` command it is now **maximally faithful**, it
follows the `git` command almost completely.
- 15-06-2019
- A new architecture for defining the highlighting for **specific commands**: it now uses **abstract definitions**
instead of **top-down, regular code**. The first effect is the highlighting for the `git` command it is now
**maximally faithful**, it follows the `git` command almost completely. [Screencast](https://asciinema.org/a/253411)
# Installation
@ -44,19 +38,35 @@ Feature rich syntax highlighting for Zsh.
Clone the Repository.
```zsh
git clone https://github.com/zdharma/fast-syntax-highlighting ~/path/to/fsh
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting ~/path/to/fsh
```
And add the following to your `zshrc` file.
```zsh
source ~/path/to/fsh/fast-syntax-highlighting.plugin.zsh
```
### [Zplugin](https://github.com/psprint/zplugin) (Recommended)
### Zinit
Add the following to your `zshrc` file.
```zsh
zplugin light zdharma/fast-syntax-highlighting
zinit light zdharma-continuum/fast-syntax-highlighting
```
Here's an example of how to load the plugin together with a few other popular ones with the use of
[Turbo](https://zdharma-continuum.org/zinit/wiki/INTRODUCTION/#turbo_mode_zsh_62_53), i.e.: speeding up the Zsh startup
by loading the plugin right after the first prompt, in background:
```zsh
zinit wait lucid for \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
zdharma-continuum/fast-syntax-highlighting \
blockf \
zsh-users/zsh-completions \
atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions
```
### Antigen
@ -64,25 +74,33 @@ zplugin light zdharma/fast-syntax-highlighting
Add the following to your `zshrc` file.
```zsh
antigen bundle zdharma/fast-syntax-highlighting
antigen bundle zdharma-continuum/fast-syntax-highlighting
```
### Fig
[Fig](https://fig.io) adds apps, shortcuts, and autocomplete to your existing terminal.
Install `fast-syntax-highlighting` in just one click.
<a href="https://fig.io/plugins/other/fast-syntax-highlighting_zdharma-continuum" target="_blank"><img src="https://fig.io/badges/install-with-fig.svg" /></a>
### Zgen
Add the following to your `.zshrc` file in the same place you're doing
your other `zgen load` calls in.
Add the following to your `.zshrc` file in the same place you're doing your other `zgen load` calls in.
```zsh
zgen load zdharma-continuum/fast-syntax-highlighting
```
zgen load zdharma/fast-syntax-highlighting
```
### Oh-My-Zsh
Clone the Repository.
```
git clone https://github.com/zdharma/fast-syntax-highlighting.git \
~/.oh-my-zsh/custom/plugins/fast-syntax-highlighting
```zsh
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
```
And add `fast-syntax-highlighting` to your plugin list.
@ -95,7 +113,7 @@ Switch themes via `fast-theme {theme-name}`.
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/theme.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/theme.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -111,7 +129,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/parameter.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/parameter.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -119,7 +137,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/in_string.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/in_string.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -129,7 +147,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/brackets.gif"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/brackets.gif"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -141,7 +159,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cplx_cond.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/cplx_cond.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -153,18 +171,17 @@ Exact highlighting that recognizes quotings.
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/ideal-string.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/ideal-string.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
</div>
### here-strings
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/herestring.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/herestring.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -176,7 +193,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/execfd_cmp.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/execfd_cmp.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -186,7 +203,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/for-loop-cmp.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/for-loop-cmp.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -198,7 +215,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper 2 lines)
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/function.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/function.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -210,7 +227,7 @@ Comparing to the project `zsh-users/zsh-syntax-highlighting` (the upper line):
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/eval_cmp.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/eval_cmp.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -222,21 +239,21 @@ Highlighting that is specific for a given command.
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/git_chroma.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/git_chroma.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
</div>
The [chromas](https://github.com/zdharma/fast-syntax-highlighting/tree/master/chroma)
that are enabled by default can be found
[here](https://github.com/zdharma/fast-syntax-highlighting/blob/master/fast-highlight#L166).
The [chromas](https://github.com/zdharma-continuum/fast-syntax-highlighting/tree/master/%E2%86%92chroma) that are
enabled by default can be found
[here](https://github.com/zdharma-continuum/fast-syntax-highlighting/blob/master/fast-highlight#L166).
### Math-mode highlighting
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/math.gif"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/math.gif"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
@ -246,13 +263,14 @@ that are enabled by default can be found
<div style="width:100%;background-color:black;border:3px solid black;border-radius:6px;margin:5px 0;padding:2px 5px">
<img
src="https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/zcalc.png"
src="https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/zcalc.png"
alt="image could not be loaded"
style="color:red;background-color:black;font-weight:bold"
/>
</div>
# Performance
Performance differences can be observed in this Asciinema recording, where a `10 kB` function is being edited.
<div style="width:100%;background-color:#121314;border:3px solid #121314;border-radius:6px;margin:5px 0;padding:2px 5px">
@ -260,3 +278,6 @@ Performance differences can be observed in this Asciinema recording, where a `10
<img src="https://asciinema.org/a/112367.png" alt="asciicast">
</a>
</div>
[gitter-image]: https://badges.gitter.im/zdharma-continuum/community.svg
[gitter-link]: https://gitter.im/zdharma-continuum/community

View file

@ -1,14 +1,13 @@
# Theme Guide for F-Sy-H
`fast-theme` tool is used to select a theme. There are 6 shipped themes, they can be listed with `fast-theme -l`.
Themes are basic [INI files](https://github.com/zdharma/fast-syntax-highlighting/tree/master/themes) where each
key is a *style*.
Besides shipped themes, user can point this tool to any other theme, by simple `fast-theme ~/mytheme.ini`. To
`fast-theme` tool is used to select a theme. There are 6 shipped themes, they can be listed with `fast-theme -l`. Themes
are basic [INI files](https://github.com/zdharma/fast-syntax-highlighting/tree/master/themes) where each key is a
*style*. Besides shipped themes, user can point this tool to any other theme, by simple `fast-theme ~/mytheme.ini`. To
obtain template to work on when creating own theme, issue `fast-theme --copy-shipped-theme {theme-name}`.
To alter just a few styles and not create a whole new theme, use **overlay**. What is overlay? It is in the same
format as full theme, but can have only a few styles defined, and these styles will overwrite styles in main-theme.
Example overlay file:
To alter just a few styles and not create a whole new theme, use **overlay**. What is overlay? It is in the same format
as full theme, but can have only a few styles defined, and these styles will overwrite styles in main-theme. Example
overlay file:
```ini
; overlay.ini
@ -32,8 +31,8 @@ HOME: = ~/.fsh/
OPT: = /opt/local/share/fsh/
```
So for example, issue `fast-theme XDG:overlay` to load `~/.config/fsh/overlay.ini` as overlay. The `.ini`
extension is optional.
So for example, issue `fast-theme XDG:overlay` to load `~/.config/fsh/overlay.ini` as overlay. The `.ini` extension is
optional.
## Secondary Theme
@ -50,27 +49,25 @@ unknown-token = red,bold
secondary = zdharma
```
Secondary theme (`zdharma` in the example) will be used for highlighting of argument for `eval`
and of `$( ... )` interior (i.e. of interior of command substitution). Basically, recursive
highlighting uses alternate theme to make the highlighted code distinct:
Secondary theme (`zdharma` in the example) will be used for highlighting of argument for `eval` and of `$( ... )`
interior (i.e. of interior of command substitution). Basically, recursive highlighting uses alternate theme to make the
highlighted code distinct:
![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/cmdsubst.png)
![sshot](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/cmdsubst.png)
In the above screen-shot the interior of `$( ... )` uses different colors than the rest of the
code. Example for `eval`:
In the above screen-shot the interior of `$( ... )` uses different colors than the rest of the code. Example for `eval`:
![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/master/images/eval_cmp.png)
![image](https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/images/eval_cmp.png)
First line doesn't use recursive highlighting, highlights `eval` argument as regular string.
Second line switches theme to `zdharma` and does full recursive highlighting of eval argument.
First line doesn't use recursive highlighting, highlights `eval` argument as regular string. Second line switches theme
to `zdharma` and does full recursive highlighting of eval argument.
## Custom Working Directory
Set `$FAST_WORK_DIR` before loading the plugin to have e.g. processed theme files (ready to
load, in Zsh format, not INI) kept under specified location. This is handy if e.g. you install
Fast-Syntax-Highlighting system-wide (e.g. from AUR on ArchLinux) and want to have per-user
theme setup.
Set `$FAST_WORK_DIR` before loading the plugin to have e.g. processed theme files (ready to load, in Zsh format, not
INI) kept under specified location. This is handy if e.g. you install Fast-Syntax-Highlighting system-wide (e.g. from
AUR on ArchLinux) and want to have per-user theme setup.
You can use "~" in the path, e.g. `FAST_WORK_DIR=~/.fsh` and also the `XDG:`, `LOCAL:`, `OPT:`,
etc. short-hands, so e.g. `FAST_WORK_DIR=XDG` or `FAST_WORK_DIR=XDG:` is allowed (in this case
it will be changed to `$HOME/.config/fsh` by default by F-Sy-H loader).
You can use "~" in the path, e.g. `FAST_WORK_DIR=~/.fsh` and also the `XDG:`, `LOCAL:`, `OPT:`, etc. short-hands, so
e.g. `FAST_WORK_DIR=XDG` or `FAST_WORK_DIR=XDG:` is allowed (in this case it will be changed to `$HOME/.config/fsh` by
default by F-Sy-H loader).

View file

@ -14,14 +14,24 @@ arguments=(
{-h,--help}'[display help text]'
{-l,--list}'[list available themes]'
{-r,--reset}'[unset any theme (revert to default highlighting)]'
{-R,--ov-reset}'[unset overlay, use styles only from main-theme (requires restart)]'
{-q,--quiet}'[no default messages]'
{-s,--show}'[get and display the theme currently being set]'
{-v,--verbose}'[more messages during operation]'
{-t,--test}'[test theme after setting it (show example code)]'
{-p,--palette}'[just print all 256 colors and exit (useful when creating a theme)]'
{-w,--workdir}'[cd into $FAST_WORK_DIR (if not set, then into the plugin directory)]'
)
typeset -a themes
themes=( "$FAST_WORK_DIR"/themes/*.ini(:t:r) )
if [[ -d ${XDG_CONFIG_HOME:-$HOME/.config}/fsh ]] {
typeset -a themes2
themes2=( "${XDG_CONFIG_HOME:-$HOME/.config}"/fsh/*.ini(:t:r) )
themes+=( XDG:${^themes2[@]} )
}
_wanted themes expl "Themes" \
compadd "$@" -a - themes && ret=0
_arguments -s $arguments && ret=0

View file

@ -1,248 +0,0 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 Sebastian Gniazdowski
# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub)
# All rights reserved.
#
# The only licensing for this file follows.
#
# 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.
# -------------------------------------------------------------------------------------------------
chroma/-subversion.ch/parse-revision() {
setopt local_options extendedglob warn_create_global typeset_silent
local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end
case $__wrd in
(r|)[0-9]##) __style=${FAST_THEME_NAME}mathnum ;;
(HEAD|BASE|COMITTED|PREV)) __style=${FAST_THEME_NAME}correct-subtle ;;
'{'[^}]##'}') __style=${FAST_THEME_NAME}subtle-bg ;;
*) __style=${FAST_THEME_NAME}incorrect-subtle ;;
esac
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
}
chroma/-subversion.ch/parse-target() {
setopt local_options extendedglob warn_create_global typeset_silent
local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end
if [[ $__wrd == *@[^/]# ]]
then
local place=${__wrd%@[^/]#}
local rev=$__wrd[$(($#place+2)),$#__wrd]
if [[ -e $place ]]; then
local __style
[[ -d $place ]] && __style="${FAST_THEME_NAME}path-to-dir" || __style="${FAST_THEME_NAME}path"
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-$#rev-1, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
fi
(( __start=__start_pos-${#PREBUFFER}+$#place, __end=__end_pos-${#PREBUFFER}-$#rev, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}")
chroma/-subversion.ch/parse-revision $rev $((__start_pos+$#place+1)) $__end_pos
else
return 1
fi
}
chroma/-subversion.ch() {
setopt local_options extendedglob warn_create_global
# Keep chroma-takever state meaning: until ;, handle highlighting via chroma.
# So the below 8192 assignment takes care that next token will be routed to chroma.
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style
integer __idx1 __idx2
(( __first_call )) && {
# Called for the first time - new command.
# FAST_HIGHLIGHT is used because it survives between calls, and
# allows to use a single global hash only, instead of multiple
# global string variables.
FAST_HIGHLIGHT[subversion-command]=$__wrd
FAST_HIGHLIGHT[subversion-option-argument]=
FAST_HIGHLIGHT[subversion-subcommand]=
FAST_HIGHLIGHT[subversion-subcommand-arguments]=0
# Set style for region_highlight entry. It is used below in
# '[[ -n "$__style" ]] ...' line, which adds highlight entry,
# like "10 12 fg=green", through `reply' array.
#
# Could check if command `example' exists and set `unknown-token'
# style instead of `command'
__style=${FAST_THEME_NAME}command
} || {
# Following call, i.e. not the first one
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \
__style=${FAST_THEME_NAME}single-hyphen-option
case $FAST_HIGHLIGHT[subversion-command]/$FAST_HIGHLIGHT[subversion-subcommand] in
svn/)
case $__wrd in
--username|-u) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--password|-p) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--config-(dir|option)) FAST_HIGHLIGHT[subversion-option-argument]=any;;
esac
;;
svn/?*)
case $__wrd in
--accept) FAST_HIGHLIGHT[subversion-option-argument]=accept;;
--change|-c) FAST_HIGHLIGHT[subversion-option-argument]=revision;;
--changelist|--cl) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--(set-|)depth) FAST_HIGHLIGHT[subversion-option-argument]=depth;;
--diff(3|)-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;;
--editor-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;;
--encoding) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--file) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--limit|-l) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--message|-m) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--native-eol) FAST_HIGHLIGHT[subversion-option-argument]=eol;;
--new|--old) FAST_HIGHLIGHT[subversion-option-argument]=target;;
--revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;;
--show-revs) FAST_HIGHLIGHT[subversion-option-argument]=show-revs;;
--strip) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--with-revprop) FAST_HIGHLIGHT[subversion-option-argument]=revprop;;
esac
;;
svnadmin/*)
case $__wrd in
--config-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--fs-type) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--memory-cache-size|-M) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--parent-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;;
esac
;;
svndumpfilter/*)
case $__wrd in
--targets) FAST_HIGHLIGHT[subversion-option-argument]=any;;
esac
;;
esac
elif [[ -n $FAST_HIGHLIGHT[subversion-option-argument] ]]; then
case $FAST_HIGHLIGHT[subversion-option-argument] in
any)
FAST_HIGHLIGHT[subversion-option-argument]=
return 1
;;
accept)
[[ $__wrd = (p(|ostpone)|e(|dit)|l(|aunch)|base|working|recommended|[mt][cf]|(mine|theirs)-(conflict|full)) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
depth)
[[ $__wrd = (empty|files|immediates|infinity) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
number)
[[ $__wrd = [0-9]## ]] \
&& __style=${FAST_THEME_NAME}mathnum \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
eol)
[[ $__wrd = (CR(|LF)|LF) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
show-revs)
[[ $__wrd = (merged|eligible) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
revision)
chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos
;;
revision-pair)
local -a match mbegin mend
if [[ $__wrd = (#b)(\{[^}]##\}|[^:]##)(:)(*) ]]; then
chroma/-subversion.ch/parse-revision $match[1] $__start_pos $(( __end_pos - ( mend[3]-mend[2] ) - 1 ))
chroma/-subversion.ch/parse-revision $match[3] $(( __start_pos + ( mbegin[3]-mbegin[1] ) )) $__end_pos
(( __start=__start_pos-${#PREBUFFER}+(mbegin[2]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[3]-mend[2]), __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}")
else
chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos
fi
;;
target)
chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $?
;;
cmd)
this_word=1
return 1
;;
esac
FAST_HIGHLIGHT[subversion-option-argument]=
elif [[ -z $FAST_HIGHLIGHT[subversion-subcommand] ]]
then
FAST_HIGHLIGHT[subversion-subcommand]=$__wrd
local subcmds
case $FAST_HIGHLIGHT[subversion-command] in
svn) subcmds='(add|auth|blame|praise|annotate|ann|cat|changelist|cl|checkout|co|cleanup|commit|ci|copy|cp|delete|del|remove|rm|diff|di|export|help|\?|h|import|info|list|ls|lock|log|merge|mergeinfo|mkdir|move|mv|rename|ren|patch|propdel|pdel|pd|propedit|pedit|pe|propget|pget|pg|proplist|plist|pl|propset|pset|ps|relocate|resolve|resolved|revert|status|stat|st|switch|sw|unlock|update|up|upgrade|x-shelf-diff|x-shelf-drop|x-shelf-list|x-shelves|x-shelf-list-by-paths|x-shelf-log|x-shelf-save|x-shelve|x-unshelve)' ;;
svnadmin) subcmds="(crashtest|create|delrevprop|deltify|dump|dump-revprops|freeze|help|\?|h|hotcopy|info|list-dblogs|list-unused-dblogs|load|load-revprops|lock|lslocks|lstxns|pack|recover|rmlocks|rmtxns|setlog|setrevprop|setuuid|unlock|upgrade|verify)";;
svndumpfilter) subcmds='(include|exclude|help|\?)';;
esac
[[ $FAST_HIGHLIGHT[subversion-subcommand] = $~subcmds ]] \
&& __style=${FAST_THEME_NAME}subcommand \
|| __style=${FAST_THEME_NAME}incorrect-subtle
FAST_HIGHLIGHT[subversion-subcommand-arguments]=0
else
(( FAST_HIGHLIGHT[subversion-subcommand-arguments]+=1 ))
if [[ ( $FAST_HIGHLIGHT[subversion-subcommand] == (checkout|co|export|log|merge|switch|sw) && $FAST_HIGHLIGHT[subversion-subcommand-arguments] -eq 1 ) \
|| $FAST_HIGHLIGHT[subversion-subcommand] == (blame|praise|annotate|ann|cat|copy|cp|diff|info|list|ls|mergeinfo) ]]; then
chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $?
else
return 1
fi
fi
}
# Add region_highlight entry (via `reply' array).
# If 1 will be added to __start_pos, this will highlight "oken".
# If 1 will be subtracted from __end_pos, this will highlight "toke".
# $PREBUFFER is for specific situations when users does command \<ENTER>
# i.e. when multi-line command using backslash is entered.
#
# This is a common place of adding such entry, but any above code can do
# it itself (and it does in other chromas) and skip setting __style to
# this way disable this code.
[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
# We aren't passing-through, do obligatory things ourselves.
# _start_pos=$_end_pos advainces pointers in command line buffer.
#
# To pass through means to `return 1'. The highlighting of
# this single token is then done by fast-syntax-highlighting's
# main code and chroma doesn't have to do anything.
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
# vim:ft=zsh:et:sw=4
}

View file

@ -1,7 +1,7 @@
# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
# Copyright (c) 2016-2018 Sebastian Gniazdowski (modifications)
# Copyright (c) 2016-2019 Sebastian Gniazdowski (modifications)
# All rights reserved.
#
# The only licensing for this file follows.
@ -33,7 +33,10 @@ typeset -g FAST_WORK_DIR
: ${FAST_WORK_DIR:=$FAST_BASE_DIR}
FAST_WORK_DIR=${~FAST_WORK_DIR}
() {
setopt localoptions extendedglob
# We must not use emulate -o if we want to keep compatibility with Zsh < v.5.0
# See https://github.com/zdharma-continuum/fast-syntax-highlighting/pull/7
emulate -L zsh
setopt extendedglob
local -A map
map=( "XDG:" "${XDG_CONFIG_HOME:-$HOME/.config}/fsh/"
"LOCAL:" "/usr/local/share/fsh/"
@ -105,8 +108,9 @@ zstyle :plugin:fast-syntax-highlighting theme default
: ${FAST_HIGHLIGHT_STYLES[double-paren]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[correct-subtle]:=fg=12}
: ${FAST_HIGHLIGHT_STYLES[incorrect-subtle]:=fg=red}
: ${FAST_HIGHLIGHT_STYLES[subtle-separator]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[subtle-bg]:=bg=18}
: ${FAST_HIGHLIGHT_STYLES[secondary]:=}
: ${FAST_HIGHLIGHT_STYLES[secondary]:=free}
fi
# This can overwrite some of *_STYLES fields
@ -164,107 +168,115 @@ typeset -gA FAST_HIGHLIGHT
: ${FAST_HIGHLIGHT[use_brackets]:=1}
FAST_HIGHLIGHT+=(
chroma-fast-theme chroma/-fast-theme.ch
chroma-alias chroma/-alias.ch
chroma-autoload chroma/-autoload.ch
chroma-autorandr chroma/-autorandr.ch
chroma-docker chroma/-docker.ch
chroma-example chroma/-example.ch
chroma-ionice chroma/-ionice.ch
chroma-make chroma/-make.ch
chroma-nice chroma/-nice.ch
chroma-nmcli chroma/-nmcli.ch
chroma-node chroma/-node.ch
chroma-perl chroma/-perl.ch
chroma-printf chroma/-printf.ch
chroma-ruby chroma/-ruby.ch
chroma-scp chroma/-scp.ch
chroma-ssh chroma/-ssh.ch
chroma-fast-theme →chroma/-fast-theme.ch
chroma-alias →chroma/-alias.ch
chroma-autoload →chroma/-autoload.ch
chroma-autorandr →chroma/-autorandr.ch
chroma-docker →chroma/-docker.ch
chroma-example →chroma/-example.ch
chroma-ionice →chroma/-ionice.ch
chroma-make →chroma/-make.ch
chroma-nice →chroma/-nice.ch
chroma-nmcli →chroma/-nmcli.ch
chroma-node →chroma/-node.ch
chroma-perl →chroma/-perl.ch
chroma-podman →chroma/-podman.ch
chroma-printf →chroma/-printf.ch
chroma-ruby →chroma/-ruby.ch
chroma-scp →chroma/-scp.ch
chroma-ssh →chroma/-ssh.ch
chroma-git chroma/main-chroma.ch%git
chroma-hub chroma/-hub.ch
chroma-lab chroma/-lab.ch
chroma-svn chroma/-subversion.ch
chroma-svnadmin chroma/-subversion.ch
chroma-svndumpfilter chroma/-subversion.ch
chroma-git chroma/main-chroma.ch%git
chroma-hub chroma/-hub.ch
chroma-lab chroma/-lab.ch
chroma-svn chroma/-subversion.ch
chroma-svnadmin chroma/-subversion.ch
chroma-svndumpfilter chroma/-subversion.ch
chroma-egrep chroma/-grep.ch
chroma-fgrep chroma/-grep.ch
chroma-grep chroma/-grep.ch
chroma-egrep chroma/-grep.ch
chroma-fgrep chroma/-grep.ch
chroma-grep chroma/-grep.ch
chroma-awk chroma/-awk.ch
chroma-gawk chroma/-awk.ch
chroma-mawk chroma/-awk.ch
chroma-awk →chroma/-awk.ch
chroma-gawk →chroma/-awk.ch
chroma-goawk →chroma/-awk.ch
chroma-mawk →chroma/-awk.ch
chroma-source chroma/-source.ch
chroma-. chroma/-source.ch
chroma-source chroma/-source.ch
chroma-. chroma/-source.ch
chroma-bash chroma/-sh.ch
chroma-fish chroma/-sh.ch
chroma-sh chroma/-sh.ch
chroma-zsh chroma/-sh.ch
chroma-bash chroma/-sh.ch
chroma-fish chroma/-sh.ch
chroma-sh chroma/-sh.ch
chroma-zsh chroma/-sh.ch
chroma-whatis chroma/-whatis.ch
chroma-man chroma/-whatis.ch
chroma-whatis chroma/-whatis.ch
chroma-man chroma/-whatis.ch
chroma-- chroma/-precommand.ch
chroma-xargs chroma/-precommand.ch
chroma-nohup chroma/-precommand.ch
chroma-- →chroma/-precommand.ch
chroma-xargs →chroma/-precommand.ch
chroma-nohup →chroma/-precommand.ch
chroma-strace →chroma/-precommand.ch
chroma-ltrace →chroma/-precommand.ch
chroma-hg chroma/-subcommand.ch
chroma-cvs chroma/-subcommand.ch
chroma-pip chroma/-subcommand.ch
chroma-pip2 chroma/-subcommand.ch
chroma-pip3 chroma/-subcommand.ch
chroma-gem chroma/-subcommand.ch
chroma-bundle chroma/-subcommand.ch
chroma-yard chroma/-subcommand.ch
chroma-cabal chroma/-subcommand.ch
chroma-npm chroma/-subcommand.ch
chroma-nvm chroma/-subcommand.ch
chroma-yarn chroma/-subcommand.ch
chroma-brew chroma/-subcommand.ch
chroma-port chroma/-subcommand.ch
chroma-yum chroma/-subcommand.ch
chroma-dnf chroma/-subcommand.ch
chroma-tmux chroma/-subcommand.ch
chroma-pass chroma/-subcommand.ch
chroma-aws chroma/-subcommand.ch
chroma-apt chroma/-subcommand.ch
chroma-apt-get chroma/-subcommand.ch
chroma-apt-cache chroma/-subcommand.ch
chroma-aptitude chroma/-subcommand.ch
chroma-keyctl chroma/-subcommand.ch
chroma-systemctl chroma/-subcommand.ch
chroma-asciinema chroma/-subcommand.ch
chroma-ipfs chroma/-subcommand.ch
chroma-zplugin chroma/-subcommand.ch
chroma-aspell chroma/-subcommand.ch
chroma-bspc chroma/-subcommand.ch
chroma-cryptsetup chroma/-subcommand.ch
chroma-diskutil chroma/-subcommand.ch
chroma-exercism chroma/-subcommand.ch
chroma-gulp chroma/-subcommand.ch
chroma-i3-msg chroma/-subcommand.ch
chroma-openssl chroma/-subcommand.ch
chroma-solargraph chroma/-subcommand.ch
chroma-subliminal chroma/-subcommand.ch
chroma-svnadmin chroma/-subcommand.ch
chroma-travis chroma/-subcommand.ch
chroma-udisksctl chroma/-subcommand.ch
chroma-xdotool chroma/-subcommand.ch
chroma-zmanage chroma/-subcommand.ch
chroma-zsystem chroma/-subcommand.ch
chroma-zypper chroma/-subcommand.ch
chroma-hg chroma/-subcommand.ch
chroma-cvs chroma/-subcommand.ch
chroma-pip chroma/-subcommand.ch
chroma-pip2 chroma/-subcommand.ch
chroma-pip3 chroma/-subcommand.ch
chroma-gem chroma/-subcommand.ch
chroma-bundle chroma/-subcommand.ch
chroma-yard chroma/-subcommand.ch
chroma-cabal chroma/-subcommand.ch
chroma-npm chroma/-subcommand.ch
chroma-nvm chroma/-subcommand.ch
chroma-yarn chroma/-subcommand.ch
chroma-brew chroma/-subcommand.ch
chroma-port chroma/-subcommand.ch
chroma-yum chroma/-subcommand.ch
chroma-dnf chroma/-subcommand.ch
chroma-tmux chroma/-subcommand.ch
chroma-pass chroma/-subcommand.ch
chroma-aws chroma/-subcommand.ch
chroma-apt chroma/-subcommand.ch
chroma-apt-get chroma/-subcommand.ch
chroma-apt-cache chroma/-subcommand.ch
chroma-aptitude chroma/-subcommand.ch
chroma-keyctl chroma/-subcommand.ch
chroma-systemctl chroma/-subcommand.ch
chroma-asciinema chroma/-subcommand.ch
chroma-ipfs chroma/-subcommand.ch
chroma-zinit chroma/main-chroma.ch%zinit
chroma-aspell chroma/-subcommand.ch
chroma-bspc chroma/-subcommand.ch
chroma-cryptsetup chroma/-subcommand.ch
chroma-diskutil chroma/-subcommand.ch
chroma-exercism chroma/-subcommand.ch
chroma-gulp chroma/-subcommand.ch
chroma-i3-msg chroma/-subcommand.ch
chroma-openssl chroma/-subcommand.ch
chroma-solargraph chroma/-subcommand.ch
chroma-subliminal chroma/-subcommand.ch
chroma-svnadmin chroma/-subcommand.ch
chroma-travis chroma/-subcommand.ch
chroma-udisksctl chroma/-subcommand.ch
chroma-xdotool chroma/-subcommand.ch
chroma-zmanage chroma/-subcommand.ch
chroma-zsystem chroma/-subcommand.ch
chroma-zypper chroma/-subcommand.ch
chroma-fpath+=\( chroma/-fpath_peq.ch
chroma-fpath=\( chroma/-fpath_peq.ch
chroma-FPATH+= chroma/-fpath_peq.ch
chroma-FPATH= chroma/-fpath_peq.ch
#chroma-which chroma/-which.ch
#chroma-vim chroma/-vim.ch
chroma-fpath+=\( chroma/-fpath_peq.ch
chroma-fpath=\( chroma/-fpath_peq.ch
chroma-FPATH+= chroma/-fpath_peq.ch
chroma-FPATH= chroma/-fpath_peq.ch
#chroma-which chroma/-which.ch
#chroma-vim chroma/-vim.ch
)
if [[ $OSTYPE == darwin* ]] {
noglob unset FAST_HIGHLIGHT[chroma-man] FAST_HIGHLIGHT[chroma-whatis]
}
# Assignments seen, to know if math parameter exists
typeset -gA FAST_ASSIGNS_SEEN
@ -287,7 +299,7 @@ typeset -ga ZLAST_COMMANDS
if zmodload -e zsh/parameter; then
if (( $+aliases[(e)$1] )); then
REPLY=alias
elif (( ${+galiases[(e)$1]} )); then
elif (( ${+galiases[(e)${(Q)1}]} )); then
REPLY="global alias"
elif (( $+functions[(e)$1] )); then
REPLY=function
@ -359,7 +371,7 @@ typeset -ga ZLAST_COMMANDS
-fast-highlight-process()
{
emulate -L zsh
setopt extendedglob bareglobqual nonomatch noksharrays typesetsilent
setopt extendedglob bareglobqual nonomatch typesetsilent
[[ $CONTEXT == "select" ]] && return 0
@ -433,6 +445,9 @@ typeset -ga ZLAST_COMMANDS
FAST_HIGHLIGHT[chroma-autoload-elements]=""
# Restart FPATH elements gathering
FAST_HIGHLIGHT[chroma-fpath_peq-elements]=""
# Restart svn zinit's ICE gathering
FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0
FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]=""
[[ -n $ZCALC_ACTIVE ]] && {
_start_pos=0; _end_pos=__len; __arg=$__buf
@ -546,7 +561,7 @@ typeset -ga ZLAST_COMMANDS
elif (( this_word & 64 )); then
[[ $__arg = -[pvV-]## && $active_command = "command" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 ))
[[ $__arg = -[cla-]## && $active_command = "exec" ]] && (( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 ))
[[ $__arg = \{[a-zA-Z][a-zA-Z0-9]#\} && $active_command = "exec" ]] && {
[[ $__arg = \{[a-zA-Z_][a-zA-Z0-9_]#\} && $active_command = "exec" ]] && {
# Highlight {descriptor} passed to exec
(( this_word = (this_word & ~1) | 2, next_word = (next_word | 65) & ~2 ))
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}exec-descriptor]}")
@ -602,19 +617,17 @@ typeset -ga ZLAST_COMMANDS
if (( __arg_type == 1 )); then
__style=${FAST_THEME_NAME}precommand
[[ $__arg = "command" || $__arg = "exec" ]] && (( next_word = next_word | 64 ))
elif [[ $__arg = "sudo" ]]; then
elif [[ $__arg = (sudo|doas) ]]; then
__style=${FAST_THEME_NAME}precommand
(( next_word = (next_word & ~2) | 4 | 1 ))
else
_mybuf=${${(Q)__arg}#\"}
if (( ${+parameters} )) && \
[[ $_mybuf = (#b)\$([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) || \
$_mybuf = (#b)\$\{([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)\}(*) || \
$_mybuf = (#b)(*)(*)\$([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) ]] && \
(( ${+parameters[${match[1]}]} || ${+parameters[${match[3]}]} )); then
[[ -n "${match[3]}" ]] && \
-fast-highlight-main-type ${match[1]}${match[2]}${(P)match[3]}${match[4]} || \
-fast-highlight-main-type ${(P)match[1]}${match[2]}
[[ $_mybuf = (#b)(*)(*)\$([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##)(*) || \
$_mybuf = (#b)(*)(*)\$\{([a-zA-Z_][a-zA-Z0-9_:-]#|[0-9]##)(*) ]] && \
(( ${+parameters[${match[3]%%:-*}]} ))
then
-fast-highlight-main-type ${match[1]}${match[2]}${(P)match[3]%%:-*}${match[4]#\}}
elif [[ $braces_stack = T* ]]; then # T - typedef, etc.
REPLY=none
else
@ -627,11 +640,13 @@ typeset -ga ZLAST_COMMANDS
[[ $__arg = "[[" ]] && __style=${FAST_THEME_NAME}double-sq-bracket || __style=${FAST_THEME_NAME}reserved-word
if [[ $__arg == $'\x7b' ]]; then # Y - '{'
braces_stack='Y'$braces_stack
elif [[ $__arg == $'\x7d' && $braces_stack = Y* ]]; then # Y - '}'
# We're at command word, so no need to check right_brace_is_recognised_everywhere
braces_stack=${braces_stack#Y}
__style=${FAST_THEME_NAME}reserved-word
(( next_word = next_word | 16 ))
elif [[ $__arg == "[[" ]]; then # A - [[
braces_stack='A'$braces_stack
@ -639,14 +654,17 @@ typeset -ga ZLAST_COMMANDS
_FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) )
elif [[ $__arg == "for" ]]; then
(( next_word = next_word | 32 )) # BIT_for
elif [[ $__arg == "case" ]]; then
(( next_word = BIT_case_preamble ))
elif [[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]]; then
braces_stack='T'$braces_stack
fi
;;
'suffix alias') __style=${FAST_THEME_NAME}suffix-alias;;
'global alias') __style=${FAST_THEME_NAME}global-alias;;
alias)
if [[ $__arg = ?*'='* ]]; then
# The so called (by old code) "insane_alias"
@ -657,6 +675,7 @@ typeset -ga ZLAST_COMMANDS
[[ ${__FAST_HIGHLIGHT_TOKEN_TYPES[$alias_target]} = "1" && $__arg_type != "1" ]] && __FAST_HIGHLIGHT_TOKEN_TYPES[$__arg]="1"
fi
;;
builtin) [[ $__arg = "[" ]] && {
__style=${FAST_THEME_NAME}single-sq-bracket
_FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) )
@ -665,14 +684,19 @@ typeset -ga ZLAST_COMMANDS
[[ $__arg = (typeset|declare|local|float|integer|export|readonly) ]] && braces_stack='T'$braces_stack
[[ $__arg = eval ]] && (( next_word = next_word | 256 ))
;;
function) __style=${FAST_THEME_NAME}function;;
command) __style=${FAST_THEME_NAME}command;;
hashed) __style=${FAST_THEME_NAME}hashed-command;;
dirpath) __style=${FAST_THEME_NAME}path-to-dir;;
none) # Assign?
if [[ $__arg == [a-zA-Z_][a-zA-Z0-9_]#(|\[[^\]]#\])(|[^\]]#\])(|[+])=* || $__arg == [0-9]##(|[+])=* || ( $braces_stack = T* && ${__arg_type} != 3 ) ]]; then
if [[ $__arg == [a-zA-Z_][a-zA-Z0-9_]#(|\[[^\]]#\])(|[^\]]#\])(|[+])=* || $__arg == [0-9]##(|[+])=* || ( $braces_stack = T* && ${__arg_type} != 3 ) ]] {
__style=${FAST_THEME_NAME}assign
[[ $__arg = ?*[=]* ]] && FAST_ASSIGNS_SEEN[${__arg%%=*}]=1
FAST_ASSIGNS_SEEN[${__arg%%=*}]=1
# Handle array assignment
[[ $__arg = (#b)*=(\()*(\))* || $__arg = (#b)*=(\()* ]] && {
@ -714,15 +738,19 @@ typeset -ga ZLAST_COMMANDS
} || -fast-highlight-string;
(( _start_pos = _start_pos - itmp + 1, 1 > 0 ))
}
elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]]; then
} elif [[ $__arg = ${histchars[1]}* && -n ${__arg[2]} ]] {
__style=${FAST_THEME_NAME}history-expansion
elif [[ $__arg == ${histchars[2]}* ]]; then
} elif [[ $__arg == ${histchars[2]}* ]] {
__style=${FAST_THEME_NAME}history-expansion
elif (( __arg_type == 3 )); then
} elif (( __arg_type == 3 )) {
# This highlights empty commands (semicolon follows nothing) as an error.
# Zsh accepts them, though.
(( this_word & 3 )) && __style=${FAST_THEME_NAME}commandseparator
elif [[ $__arg[1,2] == '((' ]]; then
} elif [[ $__arg[1,2] == '((' ]] {
# Arithmetic evaluation.
#
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@ -750,25 +778,30 @@ typeset -ga ZLAST_COMMANDS
# Counting complex brackets (for brackets-highlighter): 7. )) for as-command ((
_FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) )
}
elif [[ $__arg == '()' ]]; then
} elif [[ $__arg == '()' ]] {
_FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) $(( _start_pos-__PBUFLEN + 1 )) )
# anonymous function
__style=${FAST_THEME_NAME}reserved-word
elif [[ $__arg == $'\x28' ]]; then
} elif [[ $__arg == $'\x28' ]] {
# subshell '(', stack: letter 'R'
__style=${FAST_THEME_NAME}reserved-word
braces_stack='R'$braces_stack
elif [[ $__arg == $'\x29' ]]; then
} elif [[ $__arg == $'\x29' ]] {
# ')', stack: letter 'R' for subshell
[[ $braces_stack = R* ]] && { braces_stack=${braces_stack#R}; __style=${FAST_THEME_NAME}reserved-word; }
elif (( this_word & 14 )); then
} elif (( this_word & 14 )) {
__style=${FAST_THEME_NAME}default
elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )); then
} elif [[ $__arg = (';;'|';&'|';|') ]] && (( this_word & BIT_case_code )) {
(( next_word = (next_word | BIT_case_item) & ~(BIT_case_code+3) ))
__style=${FAST_THEME_NAME}default
elif [[ $__arg = \$\([^\(]* ]]; then
} elif [[ $__arg = \$\([^\(]* ]] {
already_added=1
fi
}
;;
*)
# ADD
@ -852,6 +885,7 @@ typeset -ga ZLAST_COMMANDS
already_added=1
;;
[\"\']*|[^\"\\]##([\\][\\])#\"*|[^\'\\]##([\\][\\])#\'*)
# 256 is eval-mode
if (( this_word & 256 )) && [[ $__arg = [\'\"]* ]]; then
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}recursive-base]}")
@ -863,7 +897,8 @@ typeset -ga ZLAST_COMMANDS
else
__idx=0
fi
-fast-highlight-process "$PREBUFFER" ${${__arg%[\'\"]}#[\'\"]} $(( _start_pos + 1 ))
(( _start_pos-__PBUFLEN >= 0 )) && \
-fast-highlight-process "$PREBUFFER" "${${__arg%[\'\"]}#[\'\"]}" $(( _start_pos + 1 ))
(( __idx )) && FAST_THEME_NAME=$_mybuf
already_added=1
else
@ -930,7 +965,22 @@ typeset -ga ZLAST_COMMANDS
# Counting complex brackets (for brackets-highlighter): 10. )) for as-argument $((
_FAST_COMPLEX_BRACKETS+=( $__start $(( __start + 1 )) )
;;
'`'*) __style=${FAST_THEME_NAME}back-quoted-argument;;
'`'*)
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-quoted-argument]}")
if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then
__idx=1
_mybuf=$FAST_THEME_NAME
FAST_THEME_NAME=${${${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]}:t:r}#(XDG|LOCAL|HOME|OPT):}
(( ${+FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}default]} )) || source $FAST_WORK_DIR/secondary_theme.zsh
else
__idx=0
fi
(( _start_pos-__PBUFLEN >= 0 )) && \
-fast-highlight-process "$PREBUFFER" "${${__arg%[\`]}#[\`]}" $(( _start_pos + 1 ))
(( __idx )) && FAST_THEME_NAME=$_mybuf
already_added=1
;;
'((') # 'F' - (( after for
(( this_word & 32 )) && {
braces_stack='F'$braces_stack
@ -1016,7 +1066,7 @@ typeset -ga ZLAST_COMMANDS
__style=${FAST_THEME_NAME}commandseparator
elif (( in_redirection == 2 )); then
__style=${FAST_THEME_NAME}redirection
elif (( ${+galiases[(e)$__arg]} )); then
elif (( ${+galiases[(e)${(Q)__arg}]} )); then
__style=${FAST_THEME_NAME}global-alias
else
if [[ ${FAST_HIGHLIGHT[no_check_paths]} != 1 ]]; then
@ -1081,16 +1131,37 @@ typeset -ga ZLAST_COMMANDS
if (( this_word & BIT_case_nempty_item == 0 )) && [[ $__arg = "esac" ]]; then
(( next_word = 1 ))
__style=${FAST_THEME_NAME}reserved-word
elif [[ $__arg = [\)\(] ]]; then
__style=${FAST_THEME_NAME}case-parentheses
[[ $__arg = \) ]] && (( next_word = BIT_case_code | 1 )) || (( next_word = BIT_case_item | BIT_case_nempty_item ))
elif [[ $__arg = (\(*\)|\)|\() ]]; then
[[ $__arg = *\) ]] && (( next_word = BIT_case_code | 1 )) || (( next_word = BIT_case_item | BIT_case_nempty_item ))
_FAST_COMPLEX_BRACKETS+=( $(( _start_pos-__PBUFLEN )) )
(( ${#__arg} > 1 )) && {
_FAST_COMPLEX_BRACKETS+=( $(( _start_pos+${#__arg}-1-__PBUFLEN )) )
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}")
(( __start=_start_pos+1-__PBUFLEN, __end=_end_pos-1-__PBUFLEN, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}")
already_added=1
} || {
__style=${FAST_THEME_NAME}case-parentheses
}
else
(( next_word = BIT_case_item | BIT_case_nempty_item ))
__style=${FAST_THEME_NAME}case-condition
fi
fi
fi
if [[ $__arg = (#b)*'#'(([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])|([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))(|[^[:alnum:]]*) || $__arg = (#b)*'rgb('(([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)),([0-9a-fA-F][0-9a-fA-F](#c0,1)))* ]]; then
if [[ -n $match[2] ]]; then
if [[ $match[2] = ?? || $match[3] = ?? || $match[4] = ?? ]]; then
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#${(l:2::0:)match[2]}${(l:2::0:)match[3]}${(l:2::0:)match[4]}")
else
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[2]$match[3]$match[4]")
fi
else
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end bg=#$match[5]$match[6]$match[7]")
fi
already_added=1
fi
# ADD
(( already_added == 0 )) && [[ ${FAST_HIGHLIGHT_STYLES[$__style]} != "none" ]] && (( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
@ -1160,8 +1231,16 @@ typeset -ga ZLAST_COMMANDS
done
# Run on fake buffer with replaced parentheses: ")" into "x"
__inputs=( ${(0)${(S)_mybuf//(#b)*\$\(([^\)]#)(\)|(#e))/${mbegin[1]};${mend[1]}${__nul}}%$__nul*} )
if [[ ${__inputs[1]} != $_mybuf ]]; then
if [[ "$_mybuf" = *$__nul* ]]; then
# Try to avoid conflict with the \0, however
# we have to split at *some* character - \7
# is ^G, so one cannot have null and ^G at
# the same time on the command line
__nul=$'\7'
fi
__inputs=( ${(ps:$__nul:)${(S)_mybuf//(#b)*\$\(([^\)]#)(\)|(#e))/${mbegin[1]};${mend[1]}${__nul}}%$__nul*} )
if [[ "${__inputs[1]}" != "$_mybuf" && -n "${__inputs[1]}" ]]; then
if [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}secondary]} ]]; then
__idx=1
__tmp=$FAST_THEME_NAME
@ -1185,6 +1264,8 @@ typeset -ga ZLAST_COMMANDS
-fast-highlight-check-path()
{
(( _start_pos-__PBUFLEN >= 0 )) || \
{ [[ $1 != "noasync" ]] && print -r -- "- $_start_pos $_end_pos"; return 1; }
[[ $1 != "noasync" ]] && {
print -r -- ${sysparams[pid]}
# This is to fill cache
@ -1229,7 +1310,7 @@ typeset -ga ZLAST_COMMANDS
val=${FAST_HIGHLIGHT[path-queue]}
val[idx-1,idx+${#stripped}]=""
FAST_HIGHLIGHT[path-queue]=$val
[[ ${FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]%D} = 1 && ${#val} -le 27 ]] && zle .redisplay
[[ ${FAST_HIGHLIGHT[cache-path-${(q)val}-${stripped%% *}]%D} = 1 && ${#val} -le 27 ]] && zle -R
}
fi
fi
@ -1257,6 +1338,7 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
# $1 - additional style to glue-in to added style
-fast-highlight-string()
{
(( _start_pos-__PBUFLEN >= 0 )) || return 0
_mybuf=$__arg
__idx=_start_pos
@ -1292,6 +1374,7 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
# Parameters used: _mybuf, __idx, _end_idx, __style
-fast-highlight-math-string()
{
(( _start_pos-__PBUFLEN >= 0 )) || return 0
_mybuf=$__arg
__idx=_start_pos
@ -1303,7 +1386,9 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
[[ ${match[1]} = [0-9]* ]] && __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]} || {
[[ ${match[1]} = [a-zA-Z_]* ]] && {
[[ -n ${(P)match[1]} || ${FAST_ASSIGNS_SEEN[${match[1]}]} = 1 ]] && __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathvar]} || __style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]}
[[ ${+parameters[${match[1]}]} = 1 || ${FAST_ASSIGNS_SEEN[${match[1]}]} = 1 ]] && \
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathvar]} || \
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]}
} || {
[[ ${match[1]} = "$"* ]] && {
match[1]=${match[1]//[\{\}+]/}
@ -1327,13 +1412,16 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
# Highlight special chars inside dollar-quoted strings
-fast-highlight-dollar-string()
{
(( _start_pos-__PBUFLEN >= 0 )) || return 0
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=${FAST_THEME_NAME}back-dollar-quoted-argument
for (( c = i + 1 ; c <= _end_pos - _start_pos ; c += 1 )); do
@ -1341,13 +1429,13 @@ zle -N -- fast-highlight-check-path-handler -fast-highlight-check-path-handler
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}"
if [[ "$AA" == (#m)(#s)(x|X)[0-9a-fA-F](#c1,2)
|| "$AA" == (#m)(#s)[0-7](#c1,3)
|| "$AA" == (#m)(#s)u[0-9a-fA-F](#c1,4)
|| "$AA" == (#m)(#s)U[0-9a-fA-F](#c1,8)
]]; then
(( k += $#MATCH ))
(( i += $#MATCH ))
(( k += MEND ))
(( i += MEND ))
else
if (( __asize > i+1 )) && [[ $__arg[i+1] == [xXuU] ]]; then
# \x not followed by hex digits is probably an error

View file

@ -15,18 +15,18 @@ function -fast-highlight-string-process {
pair_map=( "(" ")" "{" "}" "[" "]" )
while [[ $_mybuf = (#b)[^"{}()[]\\\"'"]#((["({[]})\"'"])|[\\](*))(*) ]]; do
[[ -n ${match[3]} ]] && {
__idx+=${mbegin[1]}
while [[ $_mybuf = (#b)([^"{}()[]\\\"'"]#)((["({[]})\"'"])|[\\](*))(*) ]]; do
if [[ -n ${match[4]} ]] {
__idx+=${mbegin[2]}
[[ $__quoting = \' ]] && _mybuf=${match[3]} || { _mybuf=${match[3]:1}; (( ++ __idx )); }
} || {
__idx+=${mbegin[1]}
[[ $__quoting = \' ]] && _mybuf=${match[4]} || { _mybuf=${match[4]:1}; (( ++ __idx )); }
} else {
__idx+=${mbegin[2]}
[[ -z $__quoting && -z ${_FAST_COMPLEX_BRACKETS[(r)$((__idx-${#PREBUFFER}-1))]} ]] && {
if [[ ${match[1]} = ["({["] ]]; then
if [[ ${match[2]} = ["({["] ]]; then
pos_to_level[$__idx]=$(( ++__level ))
level_to_pos[$__level]=$__idx
elif [[ ${match[1]} = ["]})"] ]]; then
elif [[ ${match[2]} = ["]})"] ]]; then
if (( __level > 0 )); then
__pair_idx=${level_to_pos[$__level]}
pos_to_level[$__idx]=$(( __level -- ))
@ -40,10 +40,21 @@ function -fast-highlight-string-process {
fi
}
[[ ${match[1]} = \" && $__quoting != \' ]] && { [[ $__quoting = '"' ]] && __quoting="" || __quoting='"'; }
[[ ${match[1]} = \' && $__quoting != \" ]] && { [[ $__quoting = "'" ]] && __quoting="" || __quoting="'"; }
_mybuf=${match[4]}
if [[ ${match[2]} = \" && $__quoting != \' ]] {
[[ $__quoting = '"' ]] && __quoting="" || __quoting='"';
}
if [[ ${match[2]} = \' && $__quoting != \" ]] {
if [[ $__quoting = ("'"|"$'") ]] {
__quoting=""
} else {
if [[ $match[1] = *\$ ]] {
__quoting="\$'";
} else {
__quoting="'";
}
}
}
_mybuf=${match[5]}
}
done

View file

@ -1,6 +1,6 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
# Copyright (c) 2017 Sebastian Gniazdowski (modifications)
# Copyright (c) 2017-2019 Sebastian Gniazdowski (modifications)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
@ -33,23 +33,30 @@
# regardless of functionargzero and posixargzero,
# and with an option for a plugin manager to alter
# the plugin directory (i.e. set ZERO parameter)
# http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
typeset -g FAST_HIGHLIGHT_VERSION=1.55
typeset -g FAST_BASE_DIR="${0:h}"
typeset -ga _FAST_MAIN_CACHE
# Holds list of indices pointing at brackets that
# are complex, i.e. e.g. part of "[[" in [[ ... ]]
typeset -ga _FAST_COMPLEX_BRACKETS
typeset -g FAST_WORK_DIR
: ${FAST_WORK_DIR:=$FAST_BASE_DIR}
typeset -g FAST_WORK_DIR=${FAST_WORK_DIR:-${XDG_CACHE_HOME:-~/.cache}/fast-syntax-highlighting}
: ${FAST_WORK_DIR:=${FAST_BASE_DIR-}}
# Expand any tilde in the (supposed) path.
FAST_WORK_DIR=${~FAST_WORK_DIR}
if [[ -z "$ZPLG_CUR_PLUGIN" && "${fpath[(r)$FAST_BASE_DIR]}" != $FAST_BASE_DIR ]]; then
fpath+=( "$FAST_BASE_DIR" )
# Last (currently, possibly) loaded plugin isn't "fast-syntax-highlighting"?
# And FPATH isn't containing plugin dir?
if [[ ${zsh_loaded_plugins[-1]-} != */fast-syntax-highlighting && -z ${fpath[(r)${0:h}]-} ]]
then
fpath+=( "${0:h}" )
fi
if [[ "$FAST_WORK_DIR" = /usr/* || ( "$FAST_WORK_DIR" = /opt/* && ! -w "$FAST_WORK_DIR" ) ]]; then
if [[ ! -w $FAST_WORK_DIR ]]; then
FAST_WORK_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/fsh"
command mkdir -p "$FAST_WORK_DIR"
fi
@ -68,7 +75,9 @@ _zsh_highlight()
return $ret
fi
setopt localoptions warncreateglobal noksharrays noshwordsplit extendedglob typesetsilent nokshglob
emulate -LR zsh
setopt extendedglob warncreateglobal typesetsilent noshortloops
local REPLY # don't leak $REPLY into global scope
local -a reply
@ -208,15 +217,19 @@ _zsh_highlight_cursor_moved()
# $1 is name of widget to call
_zsh_highlight_call_widget()
{
builtin zle "$@" && _zsh_highlight
integer ret
builtin zle "$@"
ret=$?
_zsh_highlight
return $ret
}
# Rebind all ZLE widgets to make them invoke _zsh_highlights.
_zsh_highlight_bind_widgets()
{
setopt localoptions noksharrays
typeset -F SECONDS
local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once
local -F2 SECONDS
local prefix=orig-s${SECONDS/./}-r$(( RANDOM % 1000 )) # unique each time, in case we're sourced more than once
# Load ZSH module zsh/zleparameter, needed to override user defined widgets.
zmodload zsh/zleparameter 2>/dev/null || {
@ -226,7 +239,7 @@ _zsh_highlight_bind_widgets()
# Override ZLE widgets to make them invoke _zsh_highlight.
local -U widgets_to_bind
widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank)})
widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank|zle-line-pre-redraw|zle-keymap-select)})
# Always wrap special zle-line-finish widget. This is needed to decide if the
# current line ends and special highlighting logic needs to be applied.
@ -239,7 +252,7 @@ _zsh_highlight_bind_widgets()
local cur_widget
for cur_widget in $widgets_to_bind; do
case $widgets[$cur_widget] in
case ${widgets[$cur_widget]-} in
# Already rebound event: do nothing.
user:_zsh_highlight_widget_*);;
@ -266,7 +279,7 @@ _zsh_highlight_bind_widgets()
# Incomplete or nonexistent widget: Bind to z-sy-h directly.
*)
if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
if [[ $cur_widget == zle-* ]] && [[ -z ${widgets[$cur_widget]-} ]]; then
_zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
zle -N -- $cur_widget _zsh_highlight_widget_$cur_widget
else
@ -301,21 +314,27 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
print -r -- >&2 'zsh-syntax-highlighting: failed loading add-zsh-hook.'
}
ZSH_HIGHLIGHT_MAXLENGTH=10000
/fshdbg() {
print -r -- "$@" >>! /tmp/reply
}
typeset -g ZSH_HIGHLIGHT_MAXLENGTH=10000
# Load zsh/parameter module if available
zmodload zsh/parameter 2>/dev/null
zmodload zsh/system 2>/dev/null
autoload -Uz -- is-at-least fast-theme fast-read-ini-file -fast-run-git-command -fast-make-targets \
-fast-run-command -fast-zts-read-all
autoload -Uz -- chroma/-git.ch chroma/-hub.ch chroma/-lab.ch chroma/-example.ch chroma/-grep.ch chroma/-perl.ch chroma/-make.ch \
chroma/-awk.ch chroma/-vim.ch chroma/-source.ch chroma/-sh.ch chroma/-docker.ch \
chroma/-autoload.ch chroma/-ssh.ch chroma/-scp.ch chroma/-which.ch chroma/-printf.ch \
chroma/-ruby.ch chroma/-whatis.ch chroma/-alias.ch chroma/-subcommand.ch \
chroma/-autorandr.ch chroma/-nmcli.ch chroma/-fast-theme.ch chroma/-node.ch \
chroma/-fpath_peq.ch chroma/-precommand.ch chroma/-subversion.ch chroma/-ionice.ch \
chroma/-nice.ch chroma/main-chroma.ch
autoload -Uz -- is-at-least fast-theme .fast-read-ini-file .fast-run-git-command \
.fast-make-targets .fast-run-command .fast-zts-read-all
autoload -Uz -- →chroma/-git.ch →chroma/-hub.ch →chroma/-lab.ch →chroma/-example.ch \
→chroma/-grep.ch →chroma/-perl.ch →chroma/-make.ch →chroma/-awk.ch \
→chroma/-vim.ch →chroma/-source.ch →chroma/-sh.ch →chroma/-docker.ch →chroma/-podman.ch \
→chroma/-autoload.ch →chroma/-ssh.ch →chroma/-scp.ch →chroma/-which.ch \
→chroma/-printf.ch →chroma/-ruby.ch →chroma/-whatis.ch →chroma/-alias.ch \
→chroma/-subcommand.ch →chroma/-autorandr.ch →chroma/-nmcli.ch \
→chroma/-fast-theme.ch →chroma/-node.ch →chroma/-fpath_peq.ch \
→chroma/-precommand.ch →chroma/-subversion.ch →chroma/-ionice.ch \
→chroma/-nice.ch →chroma/main-chroma.ch →chroma/-ogit.ch →chroma/-zinit.ch
source "${0:h}/fast-highlight"
source "${0:h}/fast-string-highlight"
@ -323,7 +342,13 @@ source "${0:h}/fast-string-highlight"
local __fsyh_theme
zstyle -s :plugin:fast-syntax-highlighting theme __fsyh_theme
[[ ( "${+termcap}" != 1 || "${termcap[Co]}" != <-> || "${termcap[Co]}" -lt "256" ) && "$__fsyh_theme" = default ]] && {
[[ ( "${+termcap}" != 1 || "${termcap[Co]}" != <-> || "${termcap[Co]}" -lt "256" ) && "$__fsyh_theme" = (default|) ]] && {
FAST_HIGHLIGHT_STYLES[defaultvariable]="none"
FAST_HIGHLIGHT_STYLES[defaultglobbing-ext]="fg=blue,bold"
FAST_HIGHLIGHT_STYLES[defaulthere-string-text]="bg=blue"
FAST_HIGHLIGHT_STYLES[defaulthere-string-var]="fg=cyan,bg=blue"
FAST_HIGHLIGHT_STYLES[defaultcorrect-subtle]="bg=blue"
FAST_HIGHLIGHT_STYLES[defaultsubtle-bg]="bg=blue"
[[ "${FAST_HIGHLIGHT_STYLES[variable]}" = "fg=113" ]] && FAST_HIGHLIGHT_STYLES[variable]="none"
[[ "${FAST_HIGHLIGHT_STYLES[globbing-ext]}" = "fg=13" ]] && FAST_HIGHLIGHT_STYLES[globbing-ext]="fg=blue,bold"
[[ "${FAST_HIGHLIGHT_STYLES[here-string-text]}" = "bg=18" ]] && FAST_HIGHLIGHT_STYLES[here-string-text]="bg=blue"
@ -337,3 +362,23 @@ unset __fsyh_theme
alias fsh-alias=fast-theme
-fast-highlight-fill-option-variables
if [[ ! -e $FAST_WORK_DIR/secondary_theme.zsh ]] {
if { type curl &>/dev/null } {
curl -fsSL -o "$FAST_WORK_DIR/secondary_theme.zsh" \
https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/share/free_theme.zsh \
&>/dev/null
} elif { type wget &>/dev/null } {
wget -O "$FAST_WORK_DIR/secondary_theme.zsh" \
https://raw.githubusercontent.com/zdharma-continuum/fast-syntax-highlighting/master/share/free_theme.zsh \
&>/dev/null
}
touch "$FAST_WORK_DIR/secondary_theme.zsh"
}
if [[ $(uname -a) = (#i)*darwin* ]] {
typeset -gA FAST_HIGHLIGHT
FAST_HIGHLIGHT[chroma-man]=
}
[[ ${COLORTERM-} == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || zmodload zsh/nearcolor &>/dev/null || true

View file

@ -97,12 +97,13 @@ local MATCH; integer MBEGIN MEND
print -r -- " fast-theme [-r/--reset] [-l/--list] [-s/--show] [-p/--palette] [-w/--workdir]"
print -r -- " fast-theme --copy-shipped-theme {theme-name} [destination-path]"
print -r -- ""
print -r -- "Default action (after providing <theme-name> or <theme-path>) is to switch current session"
print -r -- "and any future sessions to the new theme. Using <theme-path>, i.e. a path to an ini file"
print -r -- "means using custom, own theme. The path can use an \"XDG:\" shorthand (e.g. \"XDG:mytheme\")"
print -r -- "that will point to ~/.config/fsh/<theme>.ini (or \$XDG_CONFIG_HOME/fsh/<theme>.ini in general"
print -r -- "if the variable is set in the environment). If the INI file pointed in the path is \"*overlay*\","
print -r -- "then it is not a full theme, but an additional theme-snippet that overwrites only selected"
print -r -- "Default action (after providing <theme-name> or <theme-path>) is to switch"
print -r -- "current session and any future sessions to the new theme. Using <theme-path>,"
print -r -- "i.e.: a path to an ini file means using custom, own theme. The path can use an"
print -r -- "\"XDG:\" shorthand (e.g.: \"XDG:mytheme\") that will point to ~/.config/fsh/<theme>.ini"
print -r -- "(or \$XDG_CONFIG_HOME/fsh/<theme>.ini in general if the variable is set in the"
print -r -- "environment). If the INI file pointed in the path is \"*overlay*\", then it is"
print -r -- "not a full theme, but an additional theme-snippet that overwrites only selected"
print -r -- "styles of the main theme."
print -r -- ""
print -r -- "Other path-shorthands:"
@ -117,10 +118,13 @@ local MATCH; integer MBEGIN MEND
print -r -- "-s/--show - get and display the theme currently being set"
print -r -- "-p/--palette - just print all 256 colors and exit (useful when creating a theme)"
print -r -- "-w/--workdir - cd into \$FAST_WORK_DIR (if not set, then into the plugin directory)"
print -r -- "-v/--verbose - more messages during operation"
print -r -- "-q/--quiet - no default messages"
print -r -- ""
print -r -- "The option --copy-shipped-theme allows easy copying of one of the 6 shipped themes into given"
print -r -- "destination path. Normal use means changing directory to e.g. ~/.config/fsh, and then issuing"
print -r -- "e.g. \`fast-theme --copy-shipped-theme clean mytheme', to obtain a template for own new theme."
print -r -- "The option --copy-shipped-theme allows easy copying of one of the 6 shipped"
print -r -- "themes into given destination path. Normal use means changing directory to"
print -r -- "e.g.: ~/.config/fsh, and then issuing e.g.: \`fast-theme --copy-shipped-theme"
print -r -- "clean mytheme', to obtain a template for own new theme."
return 0
}
@ -176,6 +180,7 @@ map=(
case-condition "- correct-subtle"
correct-subtle "-"
incorrect-subtle "-"
subtle-separator "- commandseparator"
subtle-bg "- correct-subtle"
path-to-dir "- path"
paired-bracket "- subtle-bg correct-subtle"
@ -200,7 +205,7 @@ order=(
back-dollar-quoted-argument assign redirection comment variable mathvar
mathnum matherr assign-array-bracket for-loop-variable for-loop-number for-loop-operator
for-loop-separator exec-descriptor here-string-tri here-string-text here-string-var secondary
case-input case-parentheses case-condition correct-subtle incorrect-subtle subtle-bg
case-input case-parentheses case-condition correct-subtle incorrect-subtle subtle-separator subtle-bg
path-to-dir paired-bracket bracket-level-1 bracket-level-2 bracket-level-3
global-alias subcommand single-sq-bracket double-sq-bracket double-paren
optarg-string optarg-number recursive-base
@ -229,13 +234,13 @@ if [[ "$1" = */* || "$1" = (XDG|LOCAL|HOME|OPT):* ]]; then
[[ ! -r "$1" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; }
THEME_NAME="${1:t:r}"
fast-read-ini-file "$1" out ""
.fast-read-ini-file "$1" out ""
else
[[ ! -f "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "No such theme \`$1', aborting"; return 1; }
[[ ! -r "$FAST_BASE_DIR/themes/$1.ini" ]] && { print -u2 "Theme \`$1' unreadable, aborting"; return 1; }
THEME_NAME="$1"
fast-read-ini-file "$FAST_BASE_DIR/themes/$1.ini" out ""
.fast-read-ini-file "$FAST_BASE_DIR/themes/$1.ini" out ""
fi
[[ -z "$OPT_SECONDARY" ]] && { [[ "$THEME_NAME" = *"overlay"* ]] && local outfile="theme_overlay.zsh" || local outfile="current_theme.zsh"; } || local outfile="secondary_theme.zsh"

BIN
images/203654.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

61
share/free_theme.zsh Normal file
View file

@ -0,0 +1,61 @@
: ${FAST_HIGHLIGHT_STYLES[freedefault]:=none}
: ${FAST_HIGHLIGHT_STYLES[freeunknown-token]:=fg=red,bold}
: ${FAST_HIGHLIGHT_STYLES[freereserved-word]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freealias]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freesuffix-alias]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freebuiltin]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freefunction]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freecommand]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freeprecommand]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freecommandseparator]:=none}
: ${FAST_HIGHLIGHT_STYLES[freehashed-command]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freepath]:=fg=166}
: ${FAST_HIGHLIGHT_STYLES[freepath_pathseparator]:=}
: ${FAST_HIGHLIGHT_STYLES[freeglobbing]:=fg=112}
: ${FAST_HIGHLIGHT_STYLES[freeglobbing-ext]:=fg=118}
: ${FAST_HIGHLIGHT_STYLES[freehistory-expansion]:=fg=blue,bold}
: ${FAST_HIGHLIGHT_STYLES[freesingle-hyphen-option]:=fg=110}
: ${FAST_HIGHLIGHT_STYLES[freedouble-hyphen-option]:=fg=110}
: ${FAST_HIGHLIGHT_STYLES[freeback-quoted-argument]:=none}
: ${FAST_HIGHLIGHT_STYLES[freesingle-quoted-argument]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freedouble-quoted-argument]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freedollar-quoted-argument]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freeback-or-dollar-double-quoted-argument]:=fg=110}
: ${FAST_HIGHLIGHT_STYLES[freeback-dollar-quoted-argument]:=fg=110}
: ${FAST_HIGHLIGHT_STYLES[freeassign]:=none}
: ${FAST_HIGHLIGHT_STYLES[freeredirection]:=none}
: ${FAST_HIGHLIGHT_STYLES[freecomment]:=fg=black,bold}
: ${FAST_HIGHLIGHT_STYLES[freevariable]:=none}
: ${FAST_HIGHLIGHT_STYLES[freemathvar]:=fg=blue,bold}
: ${FAST_HIGHLIGHT_STYLES[freemathnum]:=fg=166}
: ${FAST_HIGHLIGHT_STYLES[freematherr]:=fg=red}
: ${FAST_HIGHLIGHT_STYLES[freeassign-array-bracket]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freefor-loop-variable]:=none}
: ${FAST_HIGHLIGHT_STYLES[freefor-loop-number]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freefor-loop-operator]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freefor-loop-separator]:=fg=109}
: ${FAST_HIGHLIGHT_STYLES[freeexec-descriptor]:=fg=yellow,bold}
: ${FAST_HIGHLIGHT_STYLES[freehere-string-tri]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[freehere-string-text]:=bg=19}
: ${FAST_HIGHLIGHT_STYLES[freehere-string-var]:=fg=110,bg=19}
: ${FAST_HIGHLIGHT_STYLES[freesecondary]:=zdharma}
: ${FAST_HIGHLIGHT_STYLES[freecase-input]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freecase-parentheses]:=fg=116}
: ${FAST_HIGHLIGHT_STYLES[freecase-condition]:=bg=19}
: ${FAST_HIGHLIGHT_STYLES[freecorrect-subtle]:=bg=55}
: ${FAST_HIGHLIGHT_STYLES[freeincorrect-subtle]:=bg=52}
: ${FAST_HIGHLIGHT_STYLES[freesubtle-separator]:=none}
: ${FAST_HIGHLIGHT_STYLES[freesubtle-bg]:=bg=18}
: ${FAST_HIGHLIGHT_STYLES[freepath-to-dir]:=fg=166,underline}
: ${FAST_HIGHLIGHT_STYLES[freepaired-bracket]:=bg=blue}
: ${FAST_HIGHLIGHT_STYLES[freebracket-level-1]:=fg=130}
: ${FAST_HIGHLIGHT_STYLES[freebracket-level-2]:=fg=70}
: ${FAST_HIGHLIGHT_STYLES[freebracket-level-3]:=fg=69}
: ${FAST_HIGHLIGHT_STYLES[freeglobal-alias]:=bg=19}
: ${FAST_HIGHLIGHT_STYLES[freesubcommand]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freesingle-sq-bracket]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freedouble-sq-bracket]:=fg=180}
: ${FAST_HIGHLIGHT_STYLES[freedouble-paren]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freeoptarg-string]:=fg=150}
: ${FAST_HIGHLIGHT_STYLES[freeoptarg-number]:=fg=166}
: ${FAST_HIGHLIGHT_STYLES[freerecursive-base]:=fg=183}

0
tests/_output/.gitkeep Normal file
View file

0
tests/_support/.gitkeep Normal file
View file

2
tests/_support/bootstrap Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env zsh
# Write your bootstrap code here

15
tests/example.zunit Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env zunit
@setup {
load "../fast-highlight"
}
@test 'ls /usr/bin' {
PREBUFFER=""
BUFFER="ls /usr/bin"
run -fast-highlight-process "$PREBUFFER" "$BUFFER" 0 \; print -rl -- \$reply
assert "$lines[1]" same_as "0 2 fg=green"
assert "$lines[2]" same_as "3 11 fg=magenta,underline"
}
# vim:ft=zsh:sw=4:sts=4:et

148
tests/main.zunit Normal file
View file

@ -0,0 +1,148 @@
#!/usr/bin/env zunit
@setup {
load "../fast-highlight"
setopt interactive_comments
-fast-highlight-fill-option-variables
# Chromas are autoloaded functions; the plugin file does this at startup.
fpath+=( "$PWD" )
autoload -Uz -- '→chroma/-ssh.ch'
}
@test 'ls /usr/bin' {
reply=()
PREBUFFER=""
BUFFER="ls /usr/bin"
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}"
assert "$reply[2]" same_as "3 11 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path-to-dir]}"
assert "$reply[3]" same_as ""
}
@test 'ls /bin/df' {
reply=()
PREBUFFER=""
BUFFER="ls /bin/df"
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}"
assert "$reply[2]" same_as "3 10 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]}"
assert "$reply[3]" same_as ""
}
@test 'ls /bin/ls\\n # a comment\\nls /usr/bin' {
reply=()
PREBUFFER=""
BUFFER=$'ls /bin/df\n # a comment\nls /usr/bin'
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
assert "$reply[1]" same_as "0 2 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}"
assert "$reply[2]" same_as "3 10 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]}"
assert "$reply[3]" same_as "12 23 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}comment]}"
assert "$reply[4]" same_as "24 26 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}"
assert "$reply[5]" same_as "27 35 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path-to-dir]}"
assert "$reply[6]" same_as ""
}
@test 'exec {FD}< <( ls /bin )' {
reply=()
PREBUFFER=""
BUFFER=$'exec {FD}< <( ls /bin )'
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
assert "$reply[1]" same_as "0 4 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}precommand]}"
assert "$reply[2]" same_as "5 9 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}exec-descriptor]}"
assert "$reply[3]" same_as ""
}
@test 'case x in x) a;; (y) ;; esac' {
reply=()
PREBUFFER=""
BUFFER=$'case x in\nx) a;;\n(y)\n;;\nesac'
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
assert "$reply[1]" same_as "0 4 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]}"
assert "$reply[2]" same_as "5 6 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-input]}"
assert "$reply[3]" same_as "7 9 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}"
assert "$reply[4]" same_as "10 11 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}"
assert "$reply[5]" same_as "11 12 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}"
assert "$reply[6]" same_as "13 14 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}unknown-token]}"
assert "$reply[7]" same_as "17 18 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}"
assert "$reply[8]" same_as "18 19 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-condition]}"
assert "$reply[9]" same_as "19 20 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}case-parentheses]}"
assert "$reply[10]" same_as "24 28 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}reserved-word]}"
assert "$reply[11]" same_as ""
}
@test '-fast-highlight-process "$PREBUFFER" "$BUFFER" 0' {
reply=()
PREBUFFER=""
BUFFER='-fast-highlight-process "$PREBUFFER" "$BUFFER" 0'
evl -fast-highlight-process "\$PREBUFFER" "\$BUFFER" 0
assert "$reply[1]" same_as "0 23 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}function]}"
assert "$reply[2]" same_as "24 36 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}"
assert "$reply[3]" same_as "25 35 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}"
assert "$reply[4]" same_as "37 46 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}"
assert "$reply[5]" same_as "38 45 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}"
assert "$reply[6]" same_as ""
}
@test 'tr : \\\\n <<<$PATH' {
reply=()
PREBUFFER=""
BUFFER='command tr : \\n <<<test$PATH'
evl -fast-highlight-process "\$PREBUFFER" "\$BUFFER" 0
assert "$reply[1]" same_as "0 7 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}precommand]}"
assert "$reply[2]" same_as "8 10 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}command]}"
assert "$reply[3]" same_as "16 19 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-tri]}"
# BUG?: the text spans over non-text (i.e. var) part
assert "$reply[4]" same_as "19 28 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-text]}"
assert "$reply[5]" same_as "23 28 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}here-string-var]}"
assert "$reply[6]" same_as ""
}
@test 'local var1; (( var + var1 + $var + $var1 + 123 ))' {
reply=()
PREBUFFER=""
BUFFER='local var1; (( var + var1 + $var + $var1 + 123 ))'
evl -fast-highlight-process "\$PREBUFFER" "\$BUFFER" 0
# Should actually be `reserved-word', but the type -w call returns `builtin'…
assert "$reply[1]" same_as "0 5 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}builtin]}"
assert "$reply[2]" same_as "12 14 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}"
assert "$reply[3]" same_as "15 18 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]}"
assert "$reply[4]" same_as "21 25 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathvar]}"
assert "$reply[5]" same_as "28 32 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}matherr]}"
assert "$reply[6]" same_as "35 40 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}back-or-dollar-double-quoted-argument]}"
assert "$reply[7]" same_as "43 46 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}mathnum]}"
assert "$reply[8]" same_as "47 49 ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-paren]}"
assert "$reply[9]" same_as ""
}
@test 'ssh -R 5037:localhost:5037 devbox' {
reply=()
PREBUFFER=""
BUFFER="ssh -R 5037:localhost:5037 devbox"
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
# -R takes an argument, so the forward spec is not the hostname and its
# trailing :5037 is not a port passed to a hostspec.
assert "${FAST_HIGHLIGHT[chroma-ssh-message]}" same_as ""
}
@test 'ssh devbox:22' {
reply=()
PREBUFFER=""
BUFFER="ssh devbox:22"
evl -fast-highlight-process "$PREBUFFER" "$BUFFER" 0
# A port really passed in the hostspec is still reported.
assert "${FAST_HIGHLIGHT[chroma-ssh-message]}" same_as "Format of hostname incorrect, use -p to pass port number"
}
# vim:ft=zsh:sw=4:sts=4:et

82
themes/base16.ini Normal file
View file

@ -0,0 +1,82 @@
[base]
default = none
unknown-token = 1,bold
commandseparator = none
redirection = none
here-string-tri = 14
here-string-text = bg:11
here-string-var = 1,bg:11
exec-descriptor = 9,bold
comment = 8
correct-subtle = 12
incorrect-subtle = 1
subtle-separator = 12
subtle-bg = bg:10
; secondary =
; recursive-base =
[command-point]
reserved-word = 5
subcommand = 6
alias = 4
suffix-alias = 4
global-alias = 4,bg:11
builtin = 4
function = 4
command = 4
precommand = 6
hashed-command = 4
single-sq-bracket = 4
double-sq-bracket = 4
double-paren = 5
[paths]
path = 9
pathseparator =
path-to-dir = 9,underline
globbing = 6
globbing-ext = 6,bold
[brackets]
paired-bracket = bg:8
bracket-level-1 = 3,bold
bracket-level-2 = 6,bold
bracket-level-3 = 2,bold
[arguments]
single-hyphen-option = 3
double-hyphen-option = 3
back-quoted-argument = none
single-quoted-argument = 2
double-quoted-argument = 2
dollar-quoted-argument = 2
[in-string]
; backslash in $'...'
back-dollar-quoted-argument = 6
; backslash or $... in "..."
back-or-dollar-double-quoted-argument = 1
[other]
variable = 1
assign = none
assign-array-bracket = 5
history-expansion = 6,bold
[math]
mathvar = 1
mathnum = 9
matherr = 1,bold
[for-loop]
forvar = 1
fornum = 9
; operator
foroper = none
; separator
forsep = none
[case]
case-input = 1
case-parentheses = 5
case-condition = bg:10

View file

@ -12,8 +12,9 @@ exec-descriptor = yellow,bold
comment = black,bold
correct-subtle = 12
incorrect-subtle = red
subtle-separator = green
subtle-bg = bg:18
secondary =
secondary = free
; recursive-base =
[command-point]

View file

@ -7,7 +7,9 @@ local __first_call="$1" __wrd="${2%%=*}" __start_pos="$3" __end_pos="$4"
if (( __first_call )) || [[ "$2" = -* ]]; then
return 1
else
if (( $+aliases[(e)$__wrd] )) || (( ${+galiases[(e)$__wrd]} )); then
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif (( $+aliases[(e)$__wrd] )) || (( ${+galiases[(e)$__wrd]} )); then
(( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
elif (( $+functions[(e)$__wrd] )) || (( $+builtins[(e)$__wrd] )) || (( $+commands[(e)$__wrd] )) || (( $reswords[(Ie)$__wrd] )); then

View file

@ -34,6 +34,9 @@ local -a __results __deserialized __noshsplit
__style=${FAST_THEME_NAME}command
} || {
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
(( FAST_HIGHLIGHT[chroma-autoload-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-autoload-counter-all] ))
# Following call, i.e. not the first one.

View file

@ -7,6 +7,9 @@ local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
if (( __first_call )) || [[ "$__wrd" = -* ]]; then
return 1
else
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/autorandr/$__wrd" ]] then
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")

View file

@ -27,6 +27,10 @@ integer __idx1 __idx2
} || {
# Following call, i.e. not the first one.
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2

View file

@ -38,6 +38,10 @@ local -a __lines_list
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-docker-got-subcommand]} -eq 0 ]]; then
__style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
else
@ -57,7 +61,7 @@ local -a __lines_list
if (( __idx1 == 2 )); then
__style=${FAST_THEME_NAME}subcommand
elif (( __idx1 == 3 )); then
-fast-run-command "docker images -q" chroma-docker-list ""
.fast-run-command "docker images -q" chroma-docker-list ""
[[ -n "${__lines_list[(r)$__wrd]}" ]] && {
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")

View file

@ -69,6 +69,10 @@ integer __idx1 __idx2
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \

View file

@ -8,6 +8,8 @@ local __style
if (( __first_call )); then
FAST_HIGHLIGHT[chroma-fast-theme-first]=0
return 1
elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif (( ${FAST_HIGHLIGHT[chroma-fast-theme-first]} )) || [[ $__wrd = -* ]]; then
return 1
else

View file

@ -17,20 +17,22 @@ fsh__git__chroma__def=(
subcmd:NULL "NULL_0_opt"
NULL_0_opt "(-C|--exec-path=|--git-dir=|--work-tree=|--namespace=|--super-prefix=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| -c
<<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP
<<>> __style=\${FAST_THEME_NAME}optarg-string // NO-OP
|| (--version|--help|--html-path|--man-path|--info-path|-p|--paginate|
-P|--no-pager|--no-replace-objects|--bare)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
"subcommands" "::chroma/-git-get-subcommands" # run a function (the :: causes this) and use `reply'
"subcommands" "::chroma/-git-get-subcommands" # run a function (the :: causes this) and use `reply'
#"subcommands" "(fetch|pull)" # run a function (the :: causes this) and use `reply'
"subcmd-hook" "chroma/-git-check-if-alias"
"subcmd-hook" "→chroma/-git-check-if-alias"
"subcommands-blacklist" "mv,other"
## }}}
@ -68,8 +70,8 @@ fsh__git__chroma__def=(
--refmap=|--recurse-submodules=|-j|--jobs=|--submodule-prefix=|
--recurse-submodules-default=|-o|--server-option=|--upload-pack|
--negotiation-tip=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--help|--all|-a|--append|--unshallow|--update-shallow|--dry-run|-f|--force|
-k|--keep|--multiple|-p|--prune|-n|--no-tags|-t|--tags|--no-recurse-submodules|
-u|--update-head-ok|-q|--quiet|-v|--verbose|--progress|
@ -82,16 +84,16 @@ fsh__git__chroma__def=(
# is set to be argument-less. The argument is a) -o/--option argument
# and b) -o/--option=argument.
REMOTE_GR_1_arg "NO-OP // ::chroma/-git-verify-remote-or-group" # This definition is generic, reused later
"REF_#_arg" "NO-OP // ::chroma/-git-verify-ref" # This too
"REMOTE_GR_#_arg" "NO-OP // ::chroma/-git-verify-remote-or-group" # and this too
REMOTE_GR_1_arg "NO-OP // ::chroma/-git-verify-remote-or-group" # This definition is generic, reused later
"REF_#_arg" "NO-OP // ::chroma/-git-verify-ref" # This too
"REMOTE_GR_#_arg" "NO-OP // ::chroma/-git-verify-remote-or-group" # and this too
# The hash `#' above denotes: an argument at any position
# It will nicely match any following (above the first explicitly
# numbered ones) arguments passed when using --multiple
# A generic action
NO_MATCH_#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
NO_MATCH_#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
## }}}
@ -105,8 +107,8 @@ fsh__git__chroma__def=(
PUSH_0_opt "
(--receive-pack=|--exec=|--repo=|--push-option=|--signed=|
--force-with-lease=|--signed=|--recurse-submodules=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--help|--all|--mirror|--tags|--follow-tags|--atomic|-n|--dry-run|
--porcelain|--delete|--tags|--follow-tags|--signed|--no-signed|
--atomic|--no-atomic|-o|--push-option|--force-with-lease|
@ -115,7 +117,7 @@ fsh__git__chroma__def=(
--verify|--no-verify|-4|--ipv4|-6|--ipv6)
<<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP"
REMOTE_1_arg "NO-OP // ::chroma/-git-verify-remote" # This definition is generic, reused later
REMOTE_1_arg "NO-OP // ::chroma/-git-verify-remote" # This definition is generic, reused later
### }}}
@ -131,8 +133,8 @@ fsh__git__chroma__def=(
--strategy-option=|--rebase=|--depth=|--deepen=|--shallow-exclude=|
--shallow-since=|--negotiation-tip|--upload-pack|-o|--server-option=|
--no-recurse-submodules=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--help|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules|
--commit|--no-commit|--edit|--no-edit|--ff|--no-ff|--ff-only|
--log|--no-log|--signoff|--no-signoff|--stat|-n|--no-stat|--squash|
@ -140,7 +142,7 @@ fsh__git__chroma__def=(
--no-summary|--allow-unrelated-histories|-r|--rebase|--no-rebase|
--autostash|--no-autostash|--all|-a|--append|--unshallow|
--update-shallow|-f|--force|-k|--keep|--no-tags|-u|--update-head-ok|
--progress|-4|--ipv4|-6|--ipv6|recurse-submodules)
--progress|-4|--ipv4|-6|--ipv6|--recurse-submodules)
<<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP"
## }}}
@ -153,23 +155,23 @@ fsh__git__chroma__def=(
subcmd:commit "COMMIT_#_opt // FILE_#_arg // NO_MATCH_#_opt"
"COMMIT_#_opt" "
(-m|--message=)
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
(-m|--message=|--message|-am)
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
|| (--help|-a|--all|-p|--patch|--reset-author|--short|--branch|
--porcelain|--long|-z|--null|-s|--signoff|-n|--no-verify|
--allow-empty|--allow-empty-message|-e|--edit|--no-edit|
--amend|--no-post-rewrite|-i|--include|-o|--only|--untracked-files|
-v|--verbose|-q|--quiet|--dry-run|--status|--no-status|--no-gpg-sign)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (-C|--reuse-message=|-c|--reedit-message=|--fixup=|--squash=|
-F|--file=|--author=|--date=|-t|--template=|--cleanup=|
-u|--untracked-files=|-S|--gpg-sign=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action"
# A generic action
"FILE_#_arg" "NO-OP // ::chroma/-git-verify-file"
"FILE_#_arg" "NO-OP // ::chroma/-git-verify-file"
## }}}
@ -181,20 +183,20 @@ fsh__git__chroma__def=(
subcmd:merge "MERGE_0_opt // COMMIT_#_arg"
MERGE_0_opt
"(-m)
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
(-S|--gpg-sign=|--log=|-e|--strategy=|-X|--strategy-option=|-F|
--file)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--help|--commit|--no-commit|-e|--edit|--no-edit|--ff|--no-ff|--ff-only|
--log|--no-log|--signoff|--no-signoff|-n|--stat|--no-stat|--squash|
--no-squash|--verify-signatures|--no-verify-signatures|--summary|
--no-summary|-q|--quiet|-v|--verbose|--progress|--no-progress|
--allow-unrelated-histories|--rerere-autoupdate|--no-rerere-autoupdate|
--abort|--continue)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
COMMIT_#_arg "NO-OP // ::chroma/-git-verify-commit"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
COMMIT_\#_arg "NO-OP // ::chroma/-git-verify-commit"
## }}}
@ -206,7 +208,7 @@ fsh__git__chroma__def=(
subcmd:reset "RESET_0_opt^ // RESET_0_opt // RESET_#_arg // NO_MATCH_#_opt"
"RESET_0_opt^" "
(--soft|--mixed|--hard|--merge|--keep)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (--soft|--mixed|--hard|--merge|--keep):del
<<>> RESET_0_opt // RESET_#_arg
|| (--soft|--mixed|--hard|--merge|--keep):add
@ -215,11 +217,11 @@ fsh__git__chroma__def=(
RESET_0_opt "
(-q|-p|--patch)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
RESET_1_arg "NO-OP // ::chroma/-git-verify-commit"
RESET_1_arg "NO-OP // ::chroma/-git-verify-commit"
"RESET_#_arg" "NO-OP // ::chroma/-git-RESET-verify-commit-or-file"
"RESET_#_arg" "NO-OP // ::chroma/-git-RESET-verify-commit-or-file"
## }}}
@ -232,20 +234,20 @@ fsh__git__chroma__def=(
subcmd:revert "REVERT_SEQUENCER_0_opt^ // REVERT_0_opt // REVERT_#_arg // NO_MATCH_#_opt"
REVERT_0_opt "
(-m|--mainline|-S|--gpg-sign=|--strategy=|-X|--strategy-option=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (-e|--edit|--no-edit|-n|--no-commit|-s|--signoff)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
"REVERT_SEQUENCER_0_opt^" "
(--continue|--quit|--abort)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (--continue|--quit|--abort):del
<<>> REVERT_0_opt // REVERT_#_arg
|| (--continue|--quit|--abort):add
<<>> NO_MATCH_#_arg"
"REVERT_#_arg" "NO-OP // ::chroma/-git-verify-commit"
"REVERT_#_arg" "NO-OP // ::chroma/-git-verify-commit"
## }}}
@ -256,13 +258,13 @@ fsh__git__chroma__def=(
## git appends the previous file name to it good to implement this too
## {{{
subcmd:diff "DIFF_NO_INDEX_0_opt^ // DIFF_0_opt // COMMIT_FILE_#_arg // NO_MATCH_#_opt"
subcmd:diff "DIFF_NO_INDEX_0_opt^ // DIFF_0_opt // COMMIT_FILE_DIR_#_arg // NO_MATCH_#_opt"
"DIFF_NO_INDEX_0_opt^" "
--no-index
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| --no-index:del
<<>> COMMIT_FILE_#_arg
<<>> COMMIT_FILE_DIR_#_arg
|| --no-index:add
<<>> FILE_1_arg // FILE_2_arg // NO_MATCH_#_arg"
DIFF_0_opt "
@ -273,8 +275,8 @@ fsh__git__chroma__def=(
--diff-filter=|-S|-G|--find-object=|--relative=|-O|--relative=|
--inter-hunk-context=|--ignore-submodules=|--src-prefix=|--dst-prefix=|
--line-prefix=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (-p|--patch|-u|-s|--no-patch|--raw|--patch-with-raw|--indent-heuristic|
--no-indent-heuristic|--minimal|--patience|--histogram|--stat|
--compact-summary|--numstat|--shortstat|--dirstat|--summary|
@ -288,16 +290,38 @@ fsh__git__chroma__def=(
--ext-diff|--no-ext-diff|--textconv|--no-textconv|--ignore-submodules|
--no-prefix|--ita-invisible-in-index|-1|--base|-2|--ours|-3|--theirs|
-0|--cached)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
# A generic action
"COMMIT_FILE_#_arg" "NO-OP // ::chroma/-git-verify-commit-or-file"
"COMMIT_FILE_DIR_#_arg" "NO-OP // ::chroma/-git-verify-commit-or-file-or-dir"
# A generic action
"FILE_1_arg" "NO-OP // ::chroma/-git-verify-file"
"FILE_1_arg" "NO-OP // ::chroma/-git-verify-file"
# A generic action
"FILE_2_arg" "NO-OP // ::chroma/-git-verify-file"
"FILE_2_arg" "NO-OP // ::→chroma/-git-verify-file"
## }}}
##
## ADD
##
## {{{
subcmd:add "ADD_0_opt // FILE_OR_DIR_#_arg // NO_MATCH_#_opt"
ADD_0_opt "
--chmod=
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
|| (-v|--verbose|-f|--force|-i|--interactive|-n|--dry-run|
-p|--patch|-e|--edit|--all|--no-all|-A|--all|--no-all|
--ignore-removal|--no-ignore-removal|-u|--update|-N|
--intent-to-add|--refresh|--ignore-errors|--ignore-missing|
--renormalize|--no-warn-embedded-repo)
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
FILE_OR_DIR_#_arg "NO-OP // ::→chroma/-git-verify-file-or-dir"
## }}}
@ -307,36 +331,37 @@ fsh__git__chroma__def=(
## {{{
subcmd:checkout "CHECKOUT_BRANCH_0_opt^ //
CHECKOUT_0_opt // COMMIT_1_arg // FILE_#_arg //
CHECKOUT_0_opt // FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg //
FILE_#_arg // NO_MATCH_#_opt"
"CHECKOUT_BRANCH_0_opt^" "
(-b|-B|--orphan)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (-b|-B|--orphan):del
<<>> COMMIT_1_arg // FILE_#_arg // FILE_#_arg
<<>> FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // FILE_#_arg
|| (-b|-B|--orphan):add
<<>> NEW_BRANCH_1_arg // COMMIT_2_arg // NO_MATCH_#_arg"
NEW_BRANCH_1_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
NEW_BRANCH_1_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
COMMIT_2_arg "NO-OP // ::chroma/-git-verify-commit"
COMMIT_2_arg "NO-OP // ::chroma/-git-verify-commit"
CHECKOUT_0_opt "
--conflict=
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (-q|--quiet|--progress|--no-progress|-f|--force|--ours|--theirs|
-b|-B|-t|--track|--no-track|-l|--detach|--orphan|
--ignore-skip-worktree-bits|-m|--merge|-p|--patch|
--ignore-other-worktrees|--no-ignore-other-worktrees)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
# A generic action
COMMIT_1_arg "NO-OP // ::chroma/-git-verify-commit"
COMMIT_1_arg "NO-OP // ::chroma/-git-verify-commit"
# Unused
FILE_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::chroma/-git-file-or-ubranch-or-commit-verify"
FILE_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-ubranch-or-commit-verify"
FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-dir-or-ubranch-or-commit-verify"
## }}}
@ -351,7 +376,7 @@ fsh__git__chroma__def=(
REMOTE_PRUNE_1_arg // REMOTE_UPDATE_1_arg"
REMOTE_0_opt "(-v|--verbose)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_ADD_1_arg "add ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
add:REMOTE_ADD_OPTS_1_opt // REMOTE_A_NAME_2_arg //
@ -392,53 +417,53 @@ fsh__git__chroma__def=(
REMOTE_ADD_OPTS_1_opt "
(-t|-m|--mirror=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (-f|--tags|--no-tags)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_SET_HEAD_OPTS_1_opt "
(-a|--auto|-d|--delete)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_SET_HEAD_OPTS_2_opt "
(-a|--auto|-d|--delete)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_SET_BRANCHES_OPTS_1_opt "
--add
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_GET_URL_OPTS_1_opt "
(--push|--all)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
"REMOTE_SET_URL_OPTS_1_opt^" "
--push|--add|--delete
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (--add|--delete):del
<<>> REMOTE_A_URL_4_arg"
REMOTE_SHOW_OPTS_1_opt "
-n
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_PRUNE_OPTS_1_opt "
(-n|--dry-run)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_UPDATE_OPTS_1_opt "
(-p|--prune)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
REMOTE_A_NAME_2_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
REMOTE_A_NAME_3_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
REMOTE_A_URL_3_arg "NO-OP // ::chroma/main-chroma-std-verify-url"
REMOTE_A_URL_4_arg "NO-OP // ::chroma/main-chroma-std-verify-url"
BRANCH_3_arg "NO-OP // ::chroma/-git-verify-branch"
BRANCH_#_arg "NO-OP // ::chroma/-git-verify-branch"
REMOTE_2_arg "NO-OP // ::chroma/-git-verify-remote"
REMOTE_#_arg "NO-OP // ::chroma/-git-verify-remote"
REMOTE_A_NAME_2_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
REMOTE_A_NAME_3_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
REMOTE_A_URL_3_arg "NO-OP // ::chroma/main-chroma-std-verify-url"
REMOTE_A_URL_4_arg "NO-OP // ::chroma/main-chroma-std-verify-url"
BRANCH_3_arg "NO-OP // ::chroma/-git-verify-branch"
BRANCH_\#_arg "NO-OP // ::chroma/-git-verify-branch"
REMOTE_2_arg "NO-OP // ::chroma/-git-verify-remote"
REMOTE_\#_arg "NO-OP // ::chroma/-git-verify-remote"
## }}}
@ -460,8 +485,8 @@ fsh__git__chroma__def=(
--find-renames=|-C|--find-copies=|-l|--diff-filter=|-S|-G|--find-object=|
--relative=|-O|--relative=|--inter-hunk-context=|--ignore-submodules=|
--src-prefix=|--dst-prefix=|--line-prefix=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--follow|--decorate|--no-decorate|--source|--use-mailmap|--full-diff|
--log-size|--all-match|--invert-grep|-i|--regexp-ignore-case|--basic-regexp|
@ -487,9 +512,9 @@ fsh__git__chroma__def=(
--ignore-blank-lines|-W|--function-context|--ext-diff|--no-ext-diff|
--textconv|--no-textconv|--ignore-submodules|--no-prefix|
--ita-invisible-in-index)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
LOG_1_arg "NO-OP // ::chroma/-git-verify-rev-range-or-file"
LOG_1_arg "NO-OP // ::chroma/-git-verify-rev-range-or-file"
##
## TAG
@ -499,65 +524,65 @@ fsh__git__chroma__def=(
"TAG_0_opt^" "
(-u|--local-user=|--cleanup=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| -m
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-action
<<>> NO-OP // ::chroma/-git-commit-msg-opt-ARG-action
|| (-F|--file)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/-git-verify-file
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/-git-verify-file
|| (-a|--annotate|-s|--sign|-f|-e|--edit)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| (-u|--local-user=|--cleanup=|-m|-F|--file|-a|--annotate|-s|--sign|
-f|-e|--edit):add
<<>> TAG_NEW_1_arg // COMMIT_2_arg // NO_MATCH_#_arg //
NO_MATCH_#_opt"
TAG_NEW_1_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
TAG_NEW_1_arg "NO-OP // ::chroma/-git-verify-correct-branch-name"
TAG_1_arg "NO-OP // ::chroma/-git-verify-tag-name"
TAG_1_arg "NO-OP // ::chroma/-git-verify-tag-name"
"TAG_D_0_opt^" "
(-d)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| -d:add
<<>> TAG_#_arg // NO_MATCH_#_opt
|| -d:del
<<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
"TAG_#_arg" "NO-OP // ::chroma/-git-verify-tag-name"
"TAG_#_arg" "NO-OP // ::chroma/-git-verify-tag-name"
"TAG_L_0_opt^" "
(-l)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| -l:add
<<>> TAG_L_0_opt // TAG_PAT_#_arg // NO_MATCH_#_opt
|| -l:del
<<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
"TAG_L_0_opt" "
TAG_L_0_opt "
(-n|--contains|--no-contains|--points-at|--column=|--sort=|--format=|
--color=)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action
|| (--column|--no-column|--create-reflog|--merged|--no-merged|--color|-i)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action"
"TAG_PAT_#_arg" "NO-OP // ::chroma/main-chroma-std-verify-pattern"
"TAG_PAT_#_arg" "NO-OP // ::chroma/main-chroma-std-verify-pattern"
"TAG_V_0_opt^" "
(-v)
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
|| -v:add
<<>> TAG_V_0_opt // TAG_#_arg // NO_MATCH_#_opt
|| -v:del
<<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
"TAG_V_0_opt" "
TAG_V_0_opt "
--format=
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action"
<<>> NO-OP // ::chroma/main-chroma-std-aopt-action
<<>> NO-OP // ::chroma/main-chroma-std-aopt-ARG-action"
##
## All remaining subcommands
@ -565,13 +590,13 @@ fsh__git__chroma__def=(
## {{{
"subcmd:*" "CATCH_ALL_#_opt"
"CATCH_ALL_#_opt" "* <<>> NO-OP // ::chroma/main-chroma-std-aopt-SEMI-action"
"CATCH_ALL_#_opt" "* <<>> NO-OP // ::chroma/main-chroma-std-aopt-SEMI-action"
## }}}
)
# Called after entering just "git" on the command line
chroma/-git-first-call() {
chroma/-git-first-call() {
# Called for the first time - new command
# FAST_HIGHLIGHT is used because it survives between calls, and
# allows to use a single global hash only, instead of multiple
@ -591,23 +616,23 @@ chroma/-git-first-call() {
return 1
}
chroma/-git-check-if-alias() {
chroma/-git-check-if-alias() {
local _wrd="$1"
local -a _result
typeset -ga fsh__chroma__git__aliases
_result=( ${(M)fsh__chroma__git__aliases[@]:#${_wrd}[[:space:]]##*} )
chroma/main-chroma-print "Got is-alias-_result: $_result"
chroma/main-chroma-print "Got is-alias-_result: $_result"
[[ -n "$_result" ]] && \
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="${${${_result#* }## ##}%% *}"
}
# A hook that returns the list of git's
# available subcommands in $reply
chroma/-git-get-subcommands() {
chroma/-git-get-subcommands() {
local __svalue
integer __ivalue
LANG=C -fast-run-command "git help -a" chroma-${FAST_HIGHLIGHT[chroma-current]}-subcmd-list "" $(( 15 * 60 ))
LANG=C .fast-run-command "git help -a" chroma-${FAST_HIGHLIGHT[chroma-current]}-subcmd-list "" $(( 15 * 60 ))
if [[ "${__lines_list[1]}" = See* ]]; then
# (**)
# git >= v2.20, the aliases in the `git help -a' command
@ -623,7 +648,7 @@ chroma/-git-get-subcommands() {
# This allows to check if the command is an alias - we want to
# highlight the aliased command just like the target command of
# the alias
-fast-run-command "+git config --get-regexp 'alias.*'" chroma-${FAST_HIGHLIGHT[chroma-current]}-alias-list "[[:space:]]#alias." $(( 15 * 60 ))
.fast-run-command "+git config --get-regexp 'alias.*'" chroma-${FAST_HIGHLIGHT[chroma-current]}-alias-list "[[:space:]]#alias." $(( 15 * 60 ))
fi
__tmp=${#__lines_list}
@ -635,9 +660,9 @@ chroma/-git-get-subcommands() {
}
# A generic handler
chroma/-git-verify-remote() {
chroma/-git-verify-remote() {
local _wrd="$4"
-fast-run-git-command "git remote" "chroma-git-remotes-$PWD" "" $(( 2 * 60 ))
.fast-run-git-command "git remote" "chroma-git-remotes-$PWD" "" 10
[[ -n ${__lines_list[(r)$_wrd]} ]] && {
__style=${FAST_THEME_NAME}correct-subtle; return 0
} || {
@ -646,66 +671,142 @@ chroma/-git-verify-remote() {
}
# A generic handler - checks if given ref is correct
chroma/-git-verify-ref() {
chroma/-git-verify-ref() {
local _wrd="$4"
_wrd="${_wrd%%:*}"
-fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-refs-$PWD" "refs/heads" $(( 2 * 60 ))
.fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-refs-$PWD" "refs/heads" 10
[[ -n ${__lines_list[(r)$_wrd]} ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
}
# A generic handler - checks if given remote or group is correct
chroma/-git-verify-remote-or-group() {
chroma/-git-verify-remote "$@" && return 0
chroma/-git-verify-remote-or-group() {
chroma/-git-verify-remote "$@" && return 0
# The check for a group is to follow below
integer _start="$2" _end="$3"
local _scmd="$1" _wrd="$4"
}
# A generic handler - checks whether the file exists
chroma/-git-verify-file() {
local _wrd="$4"
→chroma/-git-verify-file() {
integer _start="$2" _end="$3" __pos __start __end
local _wrd="$4" bg
[[ -f "$_wrd" ]] && { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
[[ -f $_wrd ]] && {
(( __start=_start, __end=_end, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*}
((1))
} || {
(( __start=_start, __end=_end, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*}
}
[[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \
${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \
${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}
]] && \
for (( __pos = 1; __pos <= (_end-_start); __pos++ )) {
[[ ${_wrd[__pos]} == "/" ]] && {
[[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && {
(( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}")
((1))
} || {
(( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}")
}
}
}
}
chroma/-git-verify-branch() {
local _wrd="$4"
-fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches-$PWD" "refs/heads" $(( 2 * 60 ))
[[ -n ${__lines_list[(r)$_wrd]} ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
# A generic handler - checks whether the file exists
→chroma/-git-verify-file-or-dir() {
integer _start="$2" _end="$3" __pos __start __end retval
local _wrd="$4" bg
__style=
[[ -f $_wrd || -d $_wrd ]] && {
(( __start=_start, __end=_end, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*}
((1))
} || {
(( __start=_start, __end=_end, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*}
retval=1
}
[[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \
${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \
${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}
]] && \
for (( __pos = 1; __pos <= (_end-_start); __pos++ )) {
[[ ${_wrd[__pos]} == "/" ]] && {
[[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && {
(( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}")
((1))
} || {
(( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}")
}
}
}
return $retval
}
chroma/-git-verify-also-unfetched-ref() {
chroma/-git-verify-branch() {
local _wrd="$4"
-fast-run-git-command "git config --get checkout.defaultRemote" \
"chroma-git-defaultRemote-$PWD" "" $(( 2 * 60 ))
.fast-run-git-command "git for-each-ref --format='%(refname:short)'" "chroma-git-branches-$PWD" "refs/heads" 10
if [[ -n ${__lines_list[(r)$_wrd]} ]] {
__style=${FAST_THEME_NAME}correct-subtle; return 0
} elif [[ -n ${__lines_list[(r)origin/$_wrd]} ]] {
__style=${FAST_THEME_NAME}correct-subtle; return 0
} else {
__style=${FAST_THEME_NAME}incorrect-subtle; return 1
}
}
→chroma/-git-verify-also-unfetched-ref() {
local _wrd="$4"
.fast-run-git-command "git config --get checkout.defaultRemote" \
"chroma-git-defaultRemote-$PWD" "" 10
local remote="${__lines_list[1]:-origin}"
-fast-run-git-command "git rev-list --count --no-walk
.fast-run-git-command "git rev-list --count --no-walk
--glob=\"refs/remotes/$remote/$_wrd\"" \
"chroma-git-unfetched-ref-$PWD" "" $(( 2 * 60 ))
"chroma-git-unfetched-ref-$PWD" "" 10
(( __lines_list[1] )) && { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
}
# A generic handler
chroma/-git-file-or-ubranch-or-commit-verify() {
chroma/-git-verify-commit "$@" && return
chroma/-git-verify-file "$@" && return
chroma/-git-verify-also-unfetched-ref "$@"
→chroma/-git-file-or-ubranch-or-commit-verify() {
→chroma/-git-verify-commit "$@" && return
→chroma/-git-verify-file "$@" && return
→chroma/-git-verify-branch "$@" && return
→chroma/-git-verify-also-unfetched-ref "$@"
}
# A generic handler
chroma/-git-verify-correct-branch-name() {
→chroma/-git-file-or-dir-or-ubranch-or-commit-verify() {
→chroma/-git-verify-commit "$@" && return
→chroma/-git-verify-file-or-dir "$@" && return
→chroma/-git-verify-branch "$@" && return
→chroma/-git-verify-also-unfetched-ref "$@"
}
# A generic handler
→chroma/-git-verify-correct-branch-name() {
local _wrd="$4"
chroma/-git-verify-commit "$@" && \
chroma/-git-verify-commit "$@" && \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 0; }
chroma/-git-verify-remote "$@" && \
chroma/-git-verify-remote "$@" && \
{ __style=${FAST_THEME_NAME}incorrect-subtle; return 0; }
[[ "$_wrd" != ./* && "$_wrd" != *..* && "$_wrd" != *[~\^\ $'\t']* &&
@ -715,11 +816,12 @@ chroma/-git-verify-correct-branch-name() {
}
# A generic handler that checks if given commit reference is correct
chroma/-git-verify-commit() {
chroma/-git-verify-commit() {
local _wrd="$4"
__lines_list=()
-fast-run-git-command "git rev-parse --verify --quiet \"$_wrd\"" "chroma-git-commits-$PWD-$_wrd" "" $(( 1.5 * 60 ))
if (( ${#__lines_list} )); then
.fast-run-git-command --status "git rev-parse --verify --quiet \"$_wrd\"" \
"chroma-git-commits-$PWD-$_wrd" "" $(( 1.5 * 60 ))
if (( __lines_list[1] == 0 )); then
__style=${FAST_THEME_NAME}correct-subtle
return 0
fi
@ -729,21 +831,28 @@ chroma/-git-verify-commit() {
# A generic handler that checks if given commit reference
# is correct or if it's a file that exists
chroma/-git-verify-commit-or-file() {
chroma/-git-verify-commit "$@" && return
chroma/-git-verify-file "$@"
→chroma/-git-verify-commit-or-file() {
→chroma/-git-verify-commit "$@" && return
→chroma/-git-verify-file "$@"
}
# A generic handler that checks if given commit reference
# is correct or if it's a file or directives that exists
→chroma/-git-verify-commit-or-file-or-dir() {
→chroma/-git-verify-commit "$@" && return
→chroma/-git-verify-file-or-dir "$@"
}
# A generic handler that checks if given revision range
# is correct or if a file of that name exists
chroma/-git-verify-rev-range-or-file() {
chroma/-git-verify-rev-range-or-file() {
local _wrd="$4"
chroma/-git-verify-commit "$@" && return 0
chroma/-git-verify-commit "$@" && return 0
if [[ "$_wrd" = *..* ]]; then
(( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] )) && {
chroma/-git-verify-file "$@" && return 0
chroma/-git-verify-file "$@" && return 0
__style=${FAST_THEME_NAME}unknown-token
return 1
}
@ -752,29 +861,29 @@ chroma/-git-verify-rev-range-or-file() {
return 0
fi
chroma/-git-verify-file "$@" && \
chroma/-git-verify-file "$@" && \
{ FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; }
__style=""
return 1
}
chroma/-git-verify-tag-name() {
chroma/-git-verify-tag-name() {
local _wrd="$4"
-fast-run-git-command "git tag" "chroma-git-tags-$PWD" "" $(( 2*60 ))
.fast-run-git-command "git tag" "chroma-git-tags-$PWD" "" $(( 2*60 ))
[[ -n ${__lines_list[(r)$_wrd]} ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
__style=${FAST_THEME_NAME}incorrect-subtle
}
# A handler for the commit's -m/--message options.Currently
# does the same what chroma/main-chroma-std-aopt-action does
chroma/-git-commit-msg-opt-action() {
chroma/main-chroma-std-aopt-action "$@"
# does the same what chroma/main-chroma-std-aopt-action does
chroma/-git-commit-msg-opt-action() {
chroma/main-chroma-std-aopt-action "$@"
}
# A handler for the commit's -m/--message options' argument
chroma/-git-commit-msg-opt-ARG-action() {
chroma/-git-commit-msg-opt-ARG-action() {
integer _start="$2" _end="$3"
local _scmd="$1" _wrd="$4"
@ -790,8 +899,10 @@ chroma/-git-commit-msg-opt-ARG-action() {
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}")
fi
if (( ${#_wrd} > 50 )); then
for (( __idx1 = 1, __idx2 = 1; __idx1 <= 50; ++ __idx1, ++ __idx2 )); do
integer length=${FAST_HIGHLIGHT[git-cmsg-len]:-50}
if (( ${#_wrd} > length )); then
for (( __idx1 = 1, __idx2 = 1; __idx1 <= length; ++ __idx1, ++ __idx2 )); do
# Use __arg from the fast-highlight-process's scope
while [[ "${__arg[__idx2]}" != "${_wrd[__idx1]}" ]]; do
(( ++ __idx2 ))
@ -811,9 +922,9 @@ chroma/-git-commit-msg-opt-ARG-action() {
# A RESET handler
# TODO: differentiate tree-ish from commit
chroma/-git-RESET-verify-commit-or-file() {
chroma/-git-verify-commit "$@" && {
chroma/-git-verify-file "$@" && {
chroma/-git-RESET-verify-commit-or-file() {
chroma/-git-verify-commit "$@" && {
chroma/-git-verify-file "$@" && {
# TODO: with -p/--patch, the <paths> are optional,
# and this argument will be taken as a commit in a
# specific circumstances
@ -832,7 +943,7 @@ chroma/-git-RESET-verify-commit-or-file() {
return 0
}
chroma/-git-verify-file "$@" && \
chroma/-git-verify-file "$@" && \
{ FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; }
return 1

View file

@ -26,6 +26,10 @@ integer __idx1 __idx2
} || {
# Following call, i.e. not the first one.
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2

View file

@ -8,8 +8,12 @@ if (( __first_call )); then
fi
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then
-fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 ))
.fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 ))
# Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix
__lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} )

View file

@ -60,6 +60,9 @@ local -a match mbegin mend
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if (( FAST_HIGHLIGHT[ionice-option-argument] )); then
(( FAST_HIGHLIGHT[ionice-option-argument] = 0 ))

View file

@ -12,8 +12,12 @@ if (( __first_call )); then
fi
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then
-fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 ))
.fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 ))
# Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix
__lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} )

View file

@ -38,6 +38,10 @@ local -a __lines_list reply2
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* || "$__wrd" = *=* ]]; then
[[ "$__wrd" = *=* ]] && {
__style=${FAST_THEME_NAME}variable
@ -68,9 +72,13 @@ local -a __lines_list reply2
__wrd="${__wrd//\`/x}"
__wrd="${(Q)__wrd}"
if [[ -f "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" ]] && \
-fast-make-targets < "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}"
then
if [[ -f "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" ]]; then
if [[ -n "${FAST_HIGHLIGHT[chroma-make-cache-global]}" ]]; then
make -f "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}" -Rrpq | awk '/^[a-zA-Z0-9][^$#\t=]*:/' | .fast-make-targets
else
.fast-make-targets < "${FAST_HIGHLIGHT[chroma-make-custom-dir]%/}/${FAST_HIGHLIGHT[chroma-make-custom-file]}"
fi
if [[ "${reply2[(r)$__wrd]}" ]]; then
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
else

View file

@ -61,6 +61,9 @@ local -a match mbegin mend
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if (( FAST_HIGHLIGHT[nice-increment-argument] )); then
(( FAST_HIGHLIGHT[nice-increment-argument] = 0 ))

View file

@ -20,6 +20,8 @@ if (( __first_call )); then
FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]=""
FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]=""
return 1
elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif [[ "$2" = -* ]]; then
return 1
elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]} ]]; then

View file

@ -7,6 +7,8 @@ local __style
if (( __first_call )); then
FAST_HIGHLIGHT[chroma-node-file]=1
elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif [[ "$__wrd" = -- ]]; then
FAST_HIGHLIGHT[chroma-node-file]=2
elif (( FAST_HIGHLIGHT[chroma-node-file] != 2 )) && [[ "$__wrd" = -* ]]; then

383
→chroma/-ogit.ch Normal file
View file

@ -0,0 +1,383 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2018 Sebastian Gniazdowski
# Copyright (c) 2018 plexigras
#
# The old chroma function for command `git'. It colorizes the part of command
# line that holds `git' invocation.
#
# $1 - 0 or 1, denoting if it's first call to the chroma, or following one
# $2 - the current token, also accessible by $__arg from the above scope -
# basically a private copy of $__arg
# $3 - a private copy of $_start_pos, i.e. the position of the token in the
# command line buffer, used to add region_highlight entry (see man),
# because Zsh colorizes by *ranges* in command line buffer
# $4 - a private copy of $_end_pos from the above scope
#
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style
integer __idx1 __idx2
local -a __lines_list chroma_git_remote_subcommands
chroma_git_remote_subcommands=(add rename remove set-head set-branches get-url set-url set-url set-url show prune update)
if (( __first_call )); then
# Called for the first time - new command
# FAST_HIGHLIGHT is used because it survives between calls, and
# allows to use a single global hash only, instead of multiple
# global variables
FAST_HIGHLIGHT[chroma-git-counter]=0
FAST_HIGHLIGHT[chroma-git-got-subcommand]=0
FAST_HIGHLIGHT[chroma-git-subcommand]=""
FAST_HIGHLIGHT[chrome-git-got-msg1]=0
FAST_HIGHLIGHT[chrome-git-got-anymsg]=0
FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0
FAST_HIGHLIGHT[chroma-git-checkout-new]=0
FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0
FAST_HIGHLIGHT[chroma-git-branch-change]=0
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0
return 1
else
# Following call, i.e. not the first one
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if [[ "$__wrd" = "--" ]]; then
FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=1
__style=${FAST_THEME_NAME}double-hyphen-option
elif [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-git-got-subcommand]} -eq 0 ]]; then
# Options occuring before a subcommand
if (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] == 0 )); then
if [[ "$__wrd" = -[^[:space:]-]#C ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2
elif [[ "$__wrd" = -[^[:space:]-]#c ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1
fi
fi
return 1
else
# If at e.g. '>' or destination/source spec (of the redirection)
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
# If at main git option taking argument in a separate word (-C and -c)
elif (( FAST_HIGHLIGHT[chroma-git-option-with-argument-active] > 0 && \
0 == FAST_HIGHLIGHT[chroma-git-got-subcommand] ))
then
# Remember the value
__idx2=${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}
# Reset the is-argument mark-field
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0
(( __idx2 == 2 )) && return 1
# Other options' args (i.e. arg of -c) aren't routed to the big-loop
# as they aren't paths and aren't handled in any special way there
elif (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then
FAST_HIGHLIGHT[chroma-git-got-subcommand]=1
# Check if the command is an alias - we want to highlight the
# aliased command just like the target command of the alias
.fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 10 * 60 ))
# Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix
__lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} )
if (( ${#__lines_list} > 0 )); then
# (*)
# First remove alias name (#*[[:space:]]) and the space after it, then
# remove any leading spaces from what's left (##[[:space:]]##), then
# remove everything except the first word that's in the left line
# (%%[[:space:]]##*, i.e.: "everything from right side up to any space")
FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}"
else
FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd"
fi
if (( __start_pos >= 0 )); then
# if subcommand exists
LANG=C .fast-run-command "git help -a" chroma-git-subcmd-list "" $(( 10 * 60 ))
# (s: :) will split on every space, but because the expression
# isn't double-quoted, the empty elements will be eradicated
# Some further knowledge-base: s-flag is special, it skips
# empty elements and creates an array (not a concatenated
# string) even when double-quoted. The normally needed @-flag
# that logically breaks the concaetnated string back into array
# in case of double-quoting has additional effect for s-flag:
# it finally blocks empty-elements eradication.
if [[ "${__lines_list[1]}" = See* ]]; then
# (**)
# git >= v2.20
__lines_list=( ${(M)${${${(M)__lines_list[@]:# [[:blank:]]#[a-z]*}##[[:blank:]]##}%%[[:blank:]]##*}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} )
else
# (**)
# git < v2.20
__lines_list=( ${(M)${(s: :)${(M)__lines_list[@]:# [a-z]*}}:#${FAST_HIGHLIGHT[chroma-git-subcommand]}} )
fi
# Above we've checked:
# 1) If given subcommand is an alias (*)
# 2) If the command, or command pointed by the alias, exists (**)
# 3) There's little problem, git v2.20 outputs aliases in git help -a,
# which means that alias will be recognized as correct if it will
# point at another alias or on itself. That's a minor problem, a
# TODO for future planned optimization for v2.20 Git
# 4) Notice that the above situation is better than the previous - the
# alias is being verified to point to a valid git subcommand
# That's all that's needed to decide on the correctnes:
if (( ${#__lines_list} > 0 )); then
__style=${FAST_THEME_NAME}subcommand
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
fi
# The counter includes the subcommand itself
(( FAST_HIGHLIGHT[chroma-git-counter] += 1 ))
else
__wrd="${__wrd//\`/x}"
__arg="${__arg//\`/x}"
__wrd="${(Q)__wrd}"
if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" \
|| "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull" \
|| "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]] \
&& (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} == 0 )); then
# if not option
if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then
(( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] ))
if (( __idx1 == 2 )); then
.fast-run-git-command "git remote" "chroma-git-remotes" ""
else
__wrd="${__wrd%%:*}"
.fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads"
fi
# if remote/ref exists
if [[ -n ${__lines_list[(r)$__wrd]} ]]; then
(( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
# if ref (__idx1 == 3) does not exist and subcommand is push
elif (( __idx1 != 2 )) && [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "push" ]]; then
(( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
# if not existing remote name, because not an URL (i.e. no colon)
elif [[ $__idx1 -eq 2 && $__wrd != *:* ]]; then
(( __start=__start_pos-${#PREBUFFER}, __end=__start_pos+${#__wrd}-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
fi
# if option
else
if [[ "$__wrd" = "--multiple" && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fetch" ]]; then
FAST_HIGHLIGHT[chroma-git-fetch-multiple]=1
__style=${FAST_THEME_NAME}double-hyphen-option
else
return 1
fi
fi
elif (( ${FAST_HIGHLIGHT[chroma-git-fetch-multiple]} )) \
&& [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" -eq 1 ]]; then
.fast-run-git-command "git remote" "chroma-git-remotes" ""
if [[ -n ${__lines_list[(r)$__wrd]} ]]; then
__style=${FAST_THEME_NAME}correct-subtle
fi
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "commit" ]]; then
match[1]=""
match[2]=""
# if previous argument is -m or current argument is --message=something
if (( FAST_HIGHLIGHT[chrome-git-got-msg1] == 1 && ! FAST_HIGHLIGHT[chrome-git-got-anymsg] )) \
|| [[ "$__wrd" = (#b)(--message=)(*) && "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then
FAST_HIGHLIGHT[chrome-git-got-msg1]=0
FAST_HIGHLIGHT[chrome-git-got-anymsg]=1
if [[ -n "${match[1]}" ]]; then
__wrd="${(Q)${match[2]//\`/x}}"
# highlight (--message=)something
(( __start=__start_pos-${#PREBUFFER}, __end=__start_pos-${#PREBUFFER}+10, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}")
# highlight --message=(something)
(( __start=__start_pos-${#PREBUFFER}+10, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}")
else
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}")
fi
local __firstline=${__wrd%%$'\n'*}
if (( ${#__firstline} > 50 )); then
for (( __idx1 = 1, __idx2 = 1; __idx1 <= 50; ++ __idx1, ++ __idx2 )); do
while [[ "${__arg[__idx2]}" != "${__firstline[__idx1]}" ]]; do
(( ++ __idx2 ))
(( __idx2 > __asize )) && { __idx2=-1; break; }
done
(( __idx2 == -1 )) && break
done
if (( __idx2 != -1 )); then
if [[ -n "${match[1]}" ]]; then
(( __start=__start_pos-${#PREBUFFER}+__idx2, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
else
(( __start=__start_pos-${#PREBUFFER}+__idx2-1, __end=__end_pos-${#PREBUFFER}-$#__wrd+$#__firstline-1, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
fi
fi
fi
# if before --
elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 ]]; then
if [[ "$__wrd" = -[^[:space:]-]#m ]]; then
FAST_HIGHLIGHT[chrome-git-got-msg1]=1
__style=${FAST_THEME_NAME}single-hyphen-option
else
return 1
fi
# if after -- is file
elif [[ -e "$__wrd" ]]; then
__style=${FAST_THEME_NAME}path
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]] \
|| [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "revert" ]] \
|| [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "merge" ]] \
|| [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] \
|| [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" ]] \
|| [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "rebase" ]]; then
# if doing `git checkout -b ...'
if [[ "$__wrd" = -[^[:space:]-]#b && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" ]]; then
FAST_HIGHLIGHT[chroma-git-checkout-new]=1
__style=${FAST_THEME_NAME}single-hyphen-option
# if command is not checkout -b something
elif [[ "${FAST_HIGHLIGHT[chroma-git-checkout-new]}" = 0 ]]; then
# if not option
if [[ "$__wrd" != -* || "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 1 ]]; then
(( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] ))
if (( __idx1 == 2 )) || \
[[ "$__idx1" = 3 && "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]]; then
# if is ref
if command git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then
__style=${FAST_THEME_NAME}correct-subtle
# if is file and subcommand is checkout or diff
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" \
|| "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "reset" \
|| "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "diff" ]] && [[ -e ${~__wrd} ]]; then
__style=${FAST_THEME_NAME}path
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "checkout" && \
"1" = "$(command git rev-list --count --no-walk --glob="refs/remotes/${$(git \
config --get checkout.defaultRemote):-*}/$__wrd")" ]]
then
__style=${FAST_THEME_NAME}correct-subtle
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
fi
# if option
else
return 1
fi
# if option
elif [[ "${FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]}" = 0 && "$__wrd" = -* ]]; then
return 1
fi
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "remote" && "$__wrd" != -* ]]; then
(( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] ))
if [[ "$__idx1" = 2 ]]; then
if (( ${chroma_git_remote_subcommands[(I)$__wrd]} )); then
FAST_HIGHLIGHT[chroma-git-remote-subcommand]="$__wrd"
__style=${FAST_THEME_NAME}subcommand
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
elif [[ "$__idx1" = 3 && "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" = "add" ]]; then
.fast-run-git-command "git remote" "chroma-git-remotes" ""
if [[ -n ${__lines_list[(r)$__wrd]} ]]; then
__style=${FAST_THEME_NAME}incorrect-subtle
fi
elif [[ "$__idx1" = 3 && -n "$FAST_HIGHLIGHT[chroma-git-remote-subcommand]" ]]; then
.fast-run-git-command "git remote" "chroma-git-remotes" ""
if [[ -n ${__lines_list[(r)$__wrd]} ]]; then
__style=${FAST_THEME_NAME}correct-subtle
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
fi
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "branch" ]]; then
if [[ "$__wrd" = --delete \
|| "$__wrd" = --edit-description \
|| "$__wrd" = --set-upstream-to=* \
|| "$__wrd" = --unset-upstream \
|| "$__wrd" = -[^[:space:]-]#d \
|| "$__wrd" = -[^[:space:]-]#D ]]; then
FAST_HIGHLIGHT[chroma-git-branch-change]=1
return 1
elif [[ "$__wrd" != -* ]]; then
.fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads"
if [[ -n ${__lines_list[(r)$__wrd]} ]]; then
__style=${FAST_THEME_NAME}correct-subtle
elif (( FAST_HIGHLIGHT[chroma-git-branch-change] )); then
__style=${FAST_THEME_NAME}incorrect-subtle
fi
else
return 1
fi
elif [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "tag" ]]; then
if [[ "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" -le 0 ]]; then
if [[ "$__wrd" = -[^[:space:]-]#(u|m) ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=1
elif [[ "$__wrd" = -[^[:space:]-]#F ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=2
elif [[ "$__wrd" = -[^[:space:]-]#d ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=3
elif [[ "$__wrd" = (--contains|--no-contains|--points-at|--merged|--no-merged) ]]; then
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=4
fi
if [[ "$__wrd" != -* ]]; then
(( FAST_HIGHLIGHT[chroma-git-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-git-counter] ))
if [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 2 ]]; then
.fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-branches" "refs/heads"
.fast-run-git-command "+git tag" "chroma-git-tags" ""
[[ -n ${__lines_list[(r)$__wrd]} ]] && __style=${FAST_THEME_NAME}incorrect-subtle
elif [[ ${FAST_HIGHLIGHT[chroma-git-counter]} -eq 3 ]]; then
fi
else
return 1
fi
else
case "${FAST_HIGHLIGHT[chroma-git-option-with-argument-active]}" in
(1)
__style=${FAST_THEME_NAME}optarg-string
;;
(2)
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0
return 1;
;;
(3)
.fast-run-git-command "git tag" "chroma-git-tags" ""
[[ -n ${__lines_list[(r)$__wrd]} ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
__style=${FAST_THEME_NAME}incorrect-subtle
;;
(4)
if git rev-parse --verify --quiet "$__wrd" >/dev/null 2>&1; then
__style=${FAST_THEME_NAME}correct-subtle
else
__style=${FAST_THEME_NAME}incorrect-subtle
fi
;;
esac
FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0
fi
else
return 1
fi
fi
fi
fi
# Add region_highlight entry (via `reply' array)
if [[ -n "$__style" ]]; then
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
fi
# We aren't passing-through, do obligatory things ourselves
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
# vim:ft=zsh:et:sw=4

View file

@ -2,8 +2,8 @@
# Copyright (c) 2018 Sebastian Gniazdowski
#
# Chroma function for command `perl'. It highlights code passed to perl
# with -e option - does syntax check by calling `perl -ce', then highlights
# as correct or incorrect code.
# with -e or -E option - does syntax check by calling `perl -ce' or `perl -cE',
# then highlights as correct or incorrect code.
#
# $1 - 0 or 1, denoting if it's first call to the chroma, or following one
# $2 - the current token, also accessible by $__arg from the above scope -
@ -34,25 +34,39 @@ integer __idx1 __idx2
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-perl-got-subcommand]} -eq 0 ]]; then
__style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
if [[ "$__wrd" = "-e" || ("$__wrd" = -*e* && "$__wrd" != --*) ]]; then
FAST_HIGHLIGHT[chrome-perl-got-eswitch]=1
elif [[ "$__wrd" = "-E" || ("$__wrd" = -*E* && "$__wrd" != --*) ]]; then
FAST_HIGHLIGHT[chrome-perl-got-eswitch]=2
fi
else
__wrd="${__wrd//\`/x}"
__arg="${__arg//\`/x}"
__wrd="${(Q)__wrd}"
if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then
FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0
if perl -ce "$__wrd" >/dev/null 2>&1; then
# Add correct-subtle style
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
else
# Add incorrect-subtle style
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] )); then
if (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )); then
if (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 1 )); then
perl -ce "$__wrd" >/dev/null 2>&1
elif (( FAST_HIGHLIGHT[chrome-perl-got-eswitch] == 2 )); then
perl -cE "$__wrd" >/dev/null 2>&1
fi && {
# Add correct-subtle style
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
} || {
# Add incorrect-subtle style
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
}
fi
FAST_HIGHLIGHT[chrome-perl-got-eswitch]=0
else
# Pass-through to the big-loop outside
return 1

90
→chroma/-podman.ch Normal file
View file

@ -0,0 +1,90 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2018 Sebastian Gniazdowski
#
# Chroma function for command `podman'. It verifies command line, by denoting
# wrong and good arguments by color. Currently implemented: verification of
# image IDs passed to: podman image rm <ID>.
#
# $1 - 0 or 1, denoting if it's first call to the chroma, or following one
# $2 - the current token, also accessible by $__arg from the above scope -
# basically a private copy of $__arg
# $3 - a private copy of $_start_pos, i.e. the position of the token in the
# command line buffer, used to add region_highlight entry (see man),
# because Zsh colorizes by *ranges* in command line buffer
# $4 - a private copy of $_end_pos from the above scope
#
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style
integer __idx1 __idx2
local -a __lines_list
(( __first_call )) && {
# Called for the first time - new command
# FAST_HIGHLIGHT is used because it survives between calls, and
# allows to use a single global hash only, instead of multiple
# global variables
FAST_HIGHLIGHT[chroma-podman-counter]=0
FAST_HIGHLIGHT[chroma-podman-got-subcommand]=0
FAST_HIGHLIGHT[chroma-podman-subcommand]=""
FAST_HIGHLIGHT[chrome-podman-got-msg1]=0
return 1
} || {
# Following call, i.e. not the first one
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-podman-got-subcommand]} -eq 0 ]]; then
__style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
else
if (( FAST_HIGHLIGHT[chroma-podman-got-subcommand] == 0 )); then
FAST_HIGHLIGHT[chroma-podman-got-subcommand]=1
FAST_HIGHLIGHT[chroma-podman-subcommand]="$__wrd"
__style=${FAST_THEME_NAME}subcommand
(( FAST_HIGHLIGHT[chroma-podman-counter] += 1 ))
else
__wrd="${__wrd//\`/x}"
__arg="${__arg//\`/x}"
__wrd="${(Q)__wrd}"
if [[ "${FAST_HIGHLIGHT[chroma-podman-subcommand]}" = "image" ]]; then
[[ "$__wrd" != -* ]] && {
(( FAST_HIGHLIGHT[chroma-podman-counter] += 1, __idx1 = FAST_HIGHLIGHT[chroma-podman-counter] ))
if (( __idx1 == 2 )); then
__style=${FAST_THEME_NAME}subcommand
elif (( __idx1 == 3 )); then
.fast-run-command "podman images -q" chroma-podman-list ""
[[ -n "${__lines_list[(r)$__wrd]}" ]] && {
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
} || {
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
}
fi
} || __style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
else
return 1
fi
fi
fi
}
# Add region_highlight entry (via `reply' array)
[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
# We aren't passing-through, do obligatory things ourselves
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
# vim:ft=zsh:et:sw=4

View file

@ -30,6 +30,9 @@ integer __idx1 __idx2
return 1
# Following call (not first one).
} || {
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
(( FAST_HIGHLIGHT[chroma-printf-counter-all] += 1, __idx2 = FAST_HIGHLIGHT[chroma-printf-counter-all] ))
# Check if chroma should end test if token is of type

View file

@ -34,6 +34,10 @@ integer __idx1 __idx2
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* && ${FAST_HIGHLIGHT[chroma-ruby-got-subcommand]} -eq 0 ]]; then
__style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
@ -57,6 +61,7 @@ integer __idx1 __idx2
# Pass-through to the big-loop outside
return 1
fi
FAST_HIGHLIGHT[chrome-ruby-got-eswitch]=0
fi
}

View file

@ -38,6 +38,10 @@ local -a __results
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \

View file

@ -14,7 +14,7 @@
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __first_call=$1 __wrd=$2 __start_pos=$3 __end_pos=$4
local __style
integer __idx1 __idx2
local -a __lines_list
@ -28,26 +28,31 @@ local -a __lines_list
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
[[ $__arg_type = 3 ]] && return 2
__wrd="${${${(Q)__wrd}#[\"\']}%[\"\']}"
if [[ "$__wrd" = -* && "$__wrd" != -*c* ]]; then
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
__wrd=${${${(Q)__wrd}#[\"\']}%[\"\']}
if [[ $__wrd = -* && $__wrd != -*c* ]]; then
__style=${FAST_THEME_NAME}${${${__wrd:#--*}:+single-hyphen-option}:-double-hyphen-option}
else
if (( FAST_HIGHLIGHT[chrome-git-got-c] == 1 )); then
for (( __idx1 = 1, __idx2 = 1; __idx2 <= __asize; ++ __idx1 )); do
[[ "${__arg[__idx2]}" = "${__wrd[__idx1]}" ]] && break
while [[ "${__arg[__idx2]}" != "${__wrd[__idx1]}" ]]; do
[[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break
while [[ ${__arg[__idx2]} != ${__wrd[__idx1]} ]]; do
(( ++ __idx2 ))
(( __idx2 > __asize )) && { __idx2=0; break; }
done
(( __idx2 == 0 )) && break
[[ "${__arg[__idx2]}" = "${__wrd[__idx1]}" ]] && break
[[ ${__arg[__idx2]} = ${__wrd[__idx1]} ]] && break
done
FAST_HIGHLIGHT[chrome-git-got-c]=0
-fast-highlight-process "$PREBUFFER" "${__wrd}" "$(( __start_pos + __idx2 - 1 ))"
elif [[ "$__wrd" = -*c* ]]; then
(( _start_pos-__PBUFLEN >= 0 )) && \
-fast-highlight-process "$PREBUFFER" "${__wrd}" "$(( __start_pos + __idx2 - 1 ))"
elif [[ $__wrd = -*c* ]]; then
FAST_HIGHLIGHT[chrome-git-got-c]=1
else
return 1
@ -56,7 +61,7 @@ local -a __lines_list
}
# Add region_highlight entry (via `reply' array)
[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
[[ -n $__style ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
# We aren't passing-through, do obligatory things ourselves
(( this_word = next_word ))

View file

@ -34,6 +34,10 @@ integer __idx1 __idx2
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \

View file

@ -25,7 +25,7 @@ setopt extended_glob warn_create_global typeset_silent
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style check_port=0 host_start_offset host_style user_style possible_host
local -a match mbegin mend completions_user completions_host
local -a match mbegin mend completions_users completions_host
# First call, i.e. command starts, i.e. "grep" token etc.
(( __first_call )) && {
@ -41,13 +41,17 @@ local -a match mbegin mend completions_user completions_host
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
(( FAST_HIGHLIGHT[chroma-ssh-counter-all] += 1 ))
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \
__style=${FAST_THEME_NAME}single-hyphen-option
if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|Q|R|-S|-W|-w) ]]; then
if [[ "$__wrd" = (-b|-c|-D|-E|-e|-F|-I|-i|-J|-L|-l|-m|-O|-o|-p|-Q|-R|-S|-W|-w) ]]; then
FAST_HIGHLIGHT[chroma-ssh-skip-two]=1
fi
else
@ -64,14 +68,16 @@ local -a match mbegin mend completions_user completions_host
user_style=
() {
# Zstyle clobbers reply for sure
local mbegin mend match reply
zstyle -a ":completion:*:users" users completions_users
}
(( ! $#completions_users )) && completions_users=(${(k)userdirs})
if (( $#completions_users )); then
[[ $match[2] = ${~${:-(${(j:|:)completions_users})}} ]] \
&& user_style=${FAST_THEME_NAME}correct-subtle \
|| user_style=${FAST_THEME_NAME}incorrect-subtle
elif (( $#userdirs )); then
[[ -n $userdirs[$match[2]] ]] \
&& user_style=${FAST_THEME_NAME}correct-subtle \
|| user_style=${FAST_THEME_NAME}incorrect-subtle
fi
[[ -n $user_style ]] \
&& (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[2]), __start >= 0 )) \
@ -79,7 +85,7 @@ local -a match mbegin mend completions_user completions_host
}
[[ -n $match[3] ]] \
&& (( __start=__start_pos-${#PREBUFFER}+(mbegin[3]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[5]-mend[3]), __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}")
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subtle-separator]}")
host_style=
case $match[4] in

View file

@ -7,6 +7,8 @@ local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
if (( __first_call )); then
FAST_HIGHLIGHT[chroma-subcommand]=""
return 1
elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif [[ "$2" = -* ]]; then
return 1
elif [[ -z "${FAST_HIGHLIGHT[chroma-subcommand]}" ]]; then

250
→chroma/-subversion.ch Normal file
View file

@ -0,0 +1,250 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 Sebastian Gniazdowski
# Copyright (C) 2019 by Philippe Troin (F-i-f on GitHub)
# All rights reserved.
#
# The only licensing for this file follows.
#
# 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.
# -------------------------------------------------------------------------------------------------
→chroma/-subversion.ch/parse-revision() {
setopt local_options extendedglob warn_create_global typeset_silent
local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end
case $__wrd in
(r|)[0-9]##) __style=${FAST_THEME_NAME}mathnum ;;
(HEAD|BASE|COMITTED|PREV)) __style=${FAST_THEME_NAME}correct-subtle ;;
'{'[^}]##'}') __style=${FAST_THEME_NAME}subtle-bg ;;
*) __style=${FAST_THEME_NAME}incorrect-subtle ;;
esac
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
}
→chroma/-subversion.ch/parse-target() {
setopt local_options extendedglob warn_create_global typeset_silent
local __wrd="$1" __start_pos="$2" __end_pos="$3" __style __start __end
if [[ $__wrd == *@[^/]# ]]
then
local place=${__wrd%@[^/]#}
local rev=$__wrd[$(($#place+2)),$#__wrd]
if [[ -e $place ]]; then
local __style
[[ -d $place ]] && __style="${FAST_THEME_NAME}path-to-dir" || __style="${FAST_THEME_NAME}path"
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}-$#rev-1, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
fi
(( __start=__start_pos-${#PREBUFFER}+$#place, __end=__end_pos-${#PREBUFFER}-$#rev, __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}")
→chroma/-subversion.ch/parse-revision $rev $((__start_pos+$#place+1)) $__end_pos
else
return 1
fi
}
setopt local_options extendedglob warn_create_global
# Keep chroma-takever state meaning: until ;, handle highlighting via chroma.
# So the below 8192 assignment takes care that next token will be routed to chroma.
(( next_word = 2 | 8192 ))
local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
local __style
integer __idx1 __idx2
(( __first_call )) && {
# Called for the first time - new command.
# FAST_HIGHLIGHT is used because it survives between calls, and
# allows to use a single global hash only, instead of multiple
# global string variables.
FAST_HIGHLIGHT[subversion-command]=$__wrd
FAST_HIGHLIGHT[subversion-option-argument]=
FAST_HIGHLIGHT[subversion-subcommand]=
FAST_HIGHLIGHT[subversion-subcommand-arguments]=0
# Set style for region_highlight entry. It is used below in
# '[[ -n "$__style" ]] ...' line, which adds highlight entry,
# like "10 12 fg=green", through `reply' array.
#
# Could check if command `example' exists and set `unknown-token'
# style instead of `command'
__style=${FAST_THEME_NAME}command
} || {
# Following call, i.e. not the first one
# Check if chroma should end test if token is of type
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \
__style=${FAST_THEME_NAME}single-hyphen-option
case $FAST_HIGHLIGHT[subversion-command]/$FAST_HIGHLIGHT[subversion-subcommand] in
svn/)
case $__wrd in
--username|-u) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--password|-p) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--config-(dir|option)) FAST_HIGHLIGHT[subversion-option-argument]=any;;
esac
;;
svn/?*)
case $__wrd in
--accept) FAST_HIGHLIGHT[subversion-option-argument]=accept;;
--change|-c) FAST_HIGHLIGHT[subversion-option-argument]=revision;;
--changelist|--cl) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--(set-|)depth) FAST_HIGHLIGHT[subversion-option-argument]=depth;;
--diff(3|)-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;;
--editor-cmd) FAST_HIGHLIGHT[subversion-option-argument]=cmd;;
--encoding) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--file) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--limit|-l) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--message|-m) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--native-eol) FAST_HIGHLIGHT[subversion-option-argument]=eol;;
--new|--old) FAST_HIGHLIGHT[subversion-option-argument]=target;;
--revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;;
--show-revs) FAST_HIGHLIGHT[subversion-option-argument]=show-revs;;
--strip) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--with-revprop) FAST_HIGHLIGHT[subversion-option-argument]=revprop;;
esac
;;
svnadmin/*)
case $__wrd in
--config-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--fs-type) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--memory-cache-size|-M) FAST_HIGHLIGHT[subversion-option-argument]=number;;
--parent-dir) FAST_HIGHLIGHT[subversion-option-argument]=any;;
--revision|-r) FAST_HIGHLIGHT[subversion-option-argument]=revision-pair;;
esac
;;
svndumpfilter/*)
case $__wrd in
--targets) FAST_HIGHLIGHT[subversion-option-argument]=any;;
esac
;;
esac
elif [[ -n $FAST_HIGHLIGHT[subversion-option-argument] ]]; then
case $FAST_HIGHLIGHT[subversion-option-argument] in
any)
FAST_HIGHLIGHT[subversion-option-argument]=
return 1
;;
accept)
[[ $__wrd = (p(|ostpone)|e(|dit)|l(|aunch)|base|working|recommended|[mt][cf]|(mine|theirs)-(conflict|full)) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
depth)
[[ $__wrd = (empty|files|immediates|infinity) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
number)
[[ $__wrd = [0-9]## ]] \
&& __style=${FAST_THEME_NAME}mathnum \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
eol)
[[ $__wrd = (CR(|LF)|LF) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
show-revs)
[[ $__wrd = (merged|eligible) ]] \
&& __style=${FAST_THEME_NAME}correct-subtle \
|| __style=${FAST_THEME_NAME}incorrect-subtle
;;
revision)
→chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos
;;
revision-pair)
local -a match mbegin mend
if [[ $__wrd = (#b)(\{[^}]##\}|[^:]##)(:)(*) ]]; then
→chroma/-subversion.ch/parse-revision $match[1] $__start_pos $(( __end_pos - ( mend[3]-mend[2] ) - 1 ))
→chroma/-subversion.ch/parse-revision $match[3] $(( __start_pos + ( mbegin[3]-mbegin[1] ) )) $__end_pos
(( __start=__start_pos-${#PREBUFFER}+(mbegin[2]-mbegin[1]), __end=__end_pos-${#PREBUFFER}-(mend[3]-mend[2]), __start >= 0 )) \
&& reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}for-loop-separator]}")
else
→chroma/-subversion.ch/parse-revision $__wrd $__start_pos $__end_pos
fi
;;
target)
→chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $?
;;
cmd)
this_word=1
return 1
;;
esac
FAST_HIGHLIGHT[subversion-option-argument]=
elif [[ -z $FAST_HIGHLIGHT[subversion-subcommand] ]]
then
FAST_HIGHLIGHT[subversion-subcommand]=$__wrd
local subcmds
case $FAST_HIGHLIGHT[subversion-command] in
svn) subcmds='(add|auth|blame|praise|annotate|ann|cat|changelist|cl|checkout|co|cleanup|commit|ci|copy|cp|delete|del|remove|rm|diff|di|export|help|\?|h|import|info|list|ls|lock|log|merge|mergeinfo|mkdir|move|mv|rename|ren|patch|propdel|pdel|pd|propedit|pedit|pe|propget|pget|pg|proplist|plist|pl|propset|pset|ps|relocate|resolve|resolved|revert|status|stat|st|switch|sw|unlock|update|up|upgrade|x-shelf-diff|x-shelf-drop|x-shelf-list|x-shelves|x-shelf-list-by-paths|x-shelf-log|x-shelf-save|x-shelve|x-unshelve)' ;;
svnadmin) subcmds="(crashtest|create|delrevprop|deltify|dump|dump-revprops|freeze|help|\?|h|hotcopy|info|list-dblogs|list-unused-dblogs|load|load-revprops|lock|lslocks|lstxns|pack|recover|rmlocks|rmtxns|setlog|setrevprop|setuuid|unlock|upgrade|verify)";;
svndumpfilter) subcmds='(include|exclude|help|\?)';;
esac
[[ $FAST_HIGHLIGHT[subversion-subcommand] = $~subcmds ]] \
&& __style=${FAST_THEME_NAME}subcommand \
|| __style=${FAST_THEME_NAME}incorrect-subtle
FAST_HIGHLIGHT[subversion-subcommand-arguments]=0
else
(( FAST_HIGHLIGHT[subversion-subcommand-arguments]+=1 ))
if [[ ( $FAST_HIGHLIGHT[subversion-subcommand] == (checkout|co|export|log|merge|switch|sw) && $FAST_HIGHLIGHT[subversion-subcommand-arguments] -eq 1 ) \
|| $FAST_HIGHLIGHT[subversion-subcommand] == (blame|praise|annotate|ann|cat|copy|cp|diff|info|list|ls|mergeinfo) ]]; then
→chroma/-subversion.ch/parse-target $__wrd $__start_pos $__end_pos || return $?
else
return 1
fi
fi
}
# Add region_highlight entry (via `reply' array).
# If 1 will be added to __start_pos, this will highlight "oken".
# If 1 will be subtracted from __end_pos, this will highlight "toke".
# $PREBUFFER is for specific situations when users does command \<ENTER>
# i.e. when multi-line command using backslash is entered.
#
# This is a common place of adding such entry, but any above code can do
# it itself (and it does in other chromas) and skip setting __style to
# this way disable this code.
[[ -n "$__style" ]] && (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}")
# We aren't passing-through, do obligatory things ourselves.
# _start_pos=$_end_pos advainces pointers in command line buffer.
#
# To pass through means to `return 1'. The highlighting of
# this single token is then done by fast-syntax-highlighting's
# main code and chroma doesn't have to do anything.
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
# vim:ft=zsh:et:sw=4

View file

@ -1,7 +1,20 @@
# vim:ft=zsh:et:sw=4
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2018-2019 Sebastian Gniazdowski
(( next_word = 2 | 8192 ))
local THEFD check __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
typeset -gA FAST_WHATIS_CACHE
local __style __term __section __section_flag
# extact manual subsection
# NOTE: __term should be separated from __wrd to prevent incorrect cache hits
if command -v mandb > /dev/null; then
__term="${__wrd%.[0-8n](|p|type|const|head|perl)}"
__section="${${2#$__term}#.}"
else
__term=$__wrd
fi
[[ -n $__section ]] && __section_flag="-s $__section"
(( ! ${+FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]} )) && \
FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=0
@ -12,37 +25,35 @@ typeset -gA FAST_WHATIS_CACHE
}
-fast-whatis-chroma-callback() {
local THEFD="$1" input check=2
emulate -L zsh
setopt extendedglob warncreateglobal typesetsilent
-fast-zts-read-all "$THEFD" input
local THEFD="$1" input check=2 nl=$'\n' __wrd __style
.fast-zts-read-all "$THEFD" input
zle -F "$THEFD"
exec {THEFD}<&-
__wrd="${${input#[^$nl]#$nl}%%$nl*}"
if [[ "$input" = test* ]]; then
if [[ "${input%$'\n'}" = *[^0-9]'0' ]]; then
if [[ "${input#test$'\n'}" = *nothing\ appropriate* ]]; then
FAST_HIGHLIGHT[whatis_chroma_type]=2
elif [[ "${input#test$'\n'man$'\n'}" = *manual\ entry* ]]; then
# TODO: somehow withdrawn from using man here in
# favor of the whatis command
if [[ "${input%$nl}" = *[^0-9]'0' ]]; then
if [[ "${input#test$nl}" = *nothing\ appropriate* ]]; then
FAST_HIGHLIGHT[whatis_chroma_type]=2
else
FAST_HIGHLIGHT[whatis_chroma_type]=0
fi
else
[[ "${input#test$'\n'}" = man* ]] && \
FAST_HIGHLIGHT[whatis_chroma_type]=3 || \
FAST_HIGHLIGHT[whatis_chroma_type]=1
FAST_HIGHLIGHT[whatis_chroma_type]=1
fi
elif [[ "$input" = type2* ]]; then
[[ "$input" != *nothing\ appropriate* ]] && check=1 || check=0
elif [[ "$input" = type1* ]]; then
[[ "${input%$'\n'}" = *0 ]] && check=1 || check=0
[[ "${input%$nl}" = *0 ]] && check=1 || check=0
fi
if (( check != 2 )); then
FAST_WHATIS_CACHE[$__wrd]=$check
FAST_HIGHLIGHT[whatis-cache-$__wrd]=$check
if (( check )) then
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}
elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then
@ -51,9 +62,9 @@ typeset -gA FAST_WHATIS_CACHE
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}
fi
local -a start_end
start_end=( ${(s:/:)${${(M)${${input#type?$'\n'}}#*$'\n'}%$'\n'}} )
start_end=( ${(s:/:)${${(M)${${input#type?${nl}[^$nl]#$nl}}#*$nl}%$nl}} )
(( start_end[1] >= 0 )) && region_highlight+=("$start_end[1] $start_end[2] $__style")
zle .redisplay
zle -R
fi
FAST_HIGHLIGHT[whatis_chroma_callback_was_ran]=1
@ -63,27 +74,26 @@ typeset -gA FAST_WHATIS_CACHE
zle -N -- -fast-whatis-chroma-callback
if (( __first_call )) && [[ -z "${FAST_HIGHLIGHT[whatis_chroma_type]}" ]] ;then
if ! command -v man > /dev/null; then
if ! command -v whatis > /dev/null; then
FAST_HIGHLIGHT[whatis_chroma_type]=0
return 1
fi
integer have_man=0
else
integer have_man=1
if ! command -v whatis > /dev/null; then
FAST_HIGHLIGHT[whatis_chroma_type]=0
return 1
fi
(( have_man )) && \
exec {THEFD}< <( echo "test\nman"; man "osx man fallback check" 2>&1; echo "$?"; ) || \
exec {THEFD}< <( echo "test"; whatis "osx whatis fallback check" 2>&1; echo "$?"; )
exec {THEFD}< <(
print "test"
LANG=C whatis "osx whatis fallback check"
print "$?"
)
command true # a workaround of Zsh bug
zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback
fi
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if (( __first_call )) || [[ "$__wrd" = -* ]]; then
return 1
elif (( ! FAST_HIGHLIGHT[whatis_chroma_type] )); then
@ -91,47 +101,49 @@ elif (( ! FAST_HIGHLIGHT[whatis_chroma_type] )); then
# had a chance to establish the whatis_chroma_type field
(( FAST_HIGHLIGHT[whatis_chroma_callback_was_ran] )) && return 1
else
if [[ -z "${FAST_WHATIS_CACHE[$__wrd]}" ]]; then
if [[ -z "${FAST_HIGHLIGHT[whatis-cache-$__wrd]}" ]]; then
if (( FAST_HIGHLIGHT[whatis_chroma_type] == 2 )); then
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} ))
exec {THEFD}< \
<(
echo "type2"
echo "$__start/$__end"
whatis "$__wrd"
)
exec {THEFD}< <(
print "type2"
print "$__wrd"
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} ))
print "$__start/$__end"
LANG=C whatis "${(z)__section_flag}" "$__term" 2>/dev/null
)
command true # see above
zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback
else
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} ))
local cmd=${${${(M)FAST_HIGHLIGHT[whatis_chroma_type]:#3}:+man}:-whatis}
exec {THEFD}< \
<(
echo "type1"
echo "$__start/$__end"
"$cmd" ${${(M)cmd:#man}:+-t} "$__wrd" > /dev/null; echo "$?"
)
exec {THEFD}< <(
print "type1"
print "$__wrd"
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER} ))
print "$__start/$__end"
LANG=C whatis "${(z)__section_flag}" "$__term" &> /dev/null
print "$?"
)
command true
zle -F ${${FAST_HIGHLIGHT[whatis_chroma_zle_-F_have_-w_opt]:#0}:+-w} "$THEFD" -fast-whatis-chroma-callback
fi
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end $__style")
else
check=${FAST_WHATIS_CACHE[$__wrd]}
check=${FAST_HIGHLIGHT[whatis-cache-$__wrd]}
if (( check )) then
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}
elif [[ ${~__wrd} = */* && -e ${~__wrd} ]] then
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]}
else
elif (( FAST_HIGHLIGHT[whatis_chroma_type] )); then
__style=${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}
fi
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
&& reply+=("$__start $__end $__style")
[[ -n "$__style" ]] && \
(( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) && \
reply+=("$__start $__end $__style")
fi
fi
(( this_word = next_word ))
_start_pos=$_end_pos
return 0
# vim:ft=zsh:et:sw=4:sts=4

View file

@ -40,6 +40,10 @@ local -a __results
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
fi
if [[ "$__wrd" = -* ]]; then
# Detected option, add style for it.
[[ "$__wrd" = --* ]] && __style=${FAST_THEME_NAME}double-hyphen-option || \

378
→chroma/-zinit.ch Normal file
View file

@ -0,0 +1,378 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2018-2019 Sebastian Gniazdowski
#
# Chroma function for command `git'. It colorizes the part of command
# line that holds `git' invocation.
(( FAST_HIGHLIGHT[-zinit.ch-chroma-def] )) && return 1
FAST_HIGHLIGHT[-zinit.ch-chroma-def]=1
typeset -gA fsh__zinit__chroma__def
fsh__zinit__chroma__def=(
##
## No subcommand
##
## {{{
subcmd:NULL "NULL_0_opt"
NULL_0_opt "(-help|--help|-h)
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
"subcommands" "(help|man|self-update|cd|times|zstatus|load|light|unload|snippet|ls|ice|<ice|specification>|update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|completions|cdisable|cname|cenable|cname|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|env-whitelist|bindkeys|module)"
## }}}
# Generic actions
NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
##
## `ice'
##
## {{{
subcmd:ice "ICE_#_arg // NO_MATCH_#_opt"
"ICE_#_arg" "NO-OP // ::→chroma/-zinit-check-ice-mod"
## }}}
##
## `snippet'
##
## {{{
subcmd:snippet "SNIPPET_0_opt // SNIPPET_1_arg // NO_MATCH_#_opt //
NO_MATCH_#_arg"
SNIPPET_0_opt "(-f|--command)
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
SNIPPET_1_arg "NO-OP // ::→chroma/-zinit-verify-snippet"
## }}}
##
## `load'
##
## {{{
"subcmd:load"
"LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
LOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin"
LOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin"
## }}}
##
## `compile|uncompile|stress|edit|glance|recall|status|cd|changes`
##
## {{{
"subcmd:(compile|uncompile|stress|edit|glance|recall|status|cd|changes)"
"PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
PLGSNP_1_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet"
PLGSNP_2_arg "NO-OP // ::→chroma/-zinit-verify-plugin-or-snippet"
## }}}
##
## `update'
##
## {{{
subcmd:update "UPDATE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg //
NO_MATCH_#_opt // NO_MATCH_#_arg"
UPDATE_0_opt "
(--all|-r|--reset|-q|--quiet|-p|--parallel)
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
## }}}
##
## `light'
##
## {{{
subcmd:light "LIGHT_0_opt // LOAD_1_arg // LOAD_2_arg // NO_MATCH_#_opt //
NO_MATCH_#_arg"
LIGHT_0_opt "-b
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
## }}}
##
## `unload'
##
## {{{
subcmd:unload "UNLOAD_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt //
NO_MATCH_#_arg"
UNLOAD_0_opt "-q
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
UNLOAD_1_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin"
UNLOAD_2_arg "NO-OP // ::→chroma/-zinit-verify-loaded-plugin"
## }}}
##
## `report'
##
## {{{
subcmd:report "REPORT_0_opt // UNLOAD_1_arg // UNLOAD_2_arg // NO_MATCH_#_opt //
NO_MATCH_#_arg"
REPORT_0_opt "--all
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
## }}}
##
## `delete'
##
## {{{
"subcmd:delete"
"DELETE_0_opt // PLGSNP_1_arg // PLGSNP_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
DELETE_0_opt "
(--all|--clean|-y|--yes|-q|--quiet)
<<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
## }}}
##
## `cenable'
##
## {{{
subcmd:cenable "COMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
COMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-disabled-completion"
## }}}
##
## `cdisable'
##
## {{{
subcmd:cdisable "DISCOMPLETION_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
DISCOMPLETION_1_arg "NO-OP // ::→chroma/-zinit-verify-completion"
## }}}
##
## `light'
##
## {{{
subcmd:uncompile "UNCOMPILE_1_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
UNCOMPILE_1_arg "NO-OP // ::→chroma/-zinit-verify-compiled-plugin"
## }}}
##
## `*'
##
## {{{
"subcmd:*" "CATCH_ALL_#_opt"
"CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action"
## }}}
)
#→chroma/-zinit-first-call() {
# This is being done in the proper place - in -fast-highlight-process
#FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=0
#}
→chroma/-zinit-verify-plugin() {
local _scmd="$1" _wrd="$4"
[[ -d "$_wrd" ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; }
typeset -a plugins
plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zinit}" )
plugins=( "${plugins[@]:#custom}" )
[[ -n "${plugins[(r)$_wrd]}" ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
return 1
#__style=${FAST_THEME_NAME}incorrect-subtle
return 0
}
→chroma/-zinit-verify-plugin-or-snippet() {
→chroma/-zinit-verify-plugin "$1" "" "" "$4" || \
→chroma/-zinit-verify-snippet "$1" "" "" "$4"
return $?
}
→chroma/-zinit-verify-loaded-plugin() {
local _scmd="$1" _wrd="$4"
typeset -a plugins absolute1 absolute2 absolute3 normal
plugins=( "${ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" )
normal=( "${plugins[@]:#%*}" )
absolute1=( "${(M)plugins[@]:#%*}" )
absolute1=( "${absolute1[@]/\%\/\//%/}" )
local hm="${HOME%/}"
absolute2=( "${absolute1[@]/$hm/HOME}" )
absolute3=( "${absolute1[@]/\%/}" )
plugins=( $absolute1 $absolute2 $absolute3 $normal )
[[ -n "${plugins[(r)$_wrd]}" ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
return 1
#__style=${FAST_THEME_NAME}incorrect-subtle
return 0
}
→chroma/-zinit-verify-completion() {
local _scmd="$1" _wrd="$4"
# Find enabled completions
typeset -a completions
completions=( "${ZINIT[COMPLETIONS_DIR]}"/_*(N:t) )
completions=( "${completions[@]#_}" )
[[ -n "${completions[(r)${_wrd#_}]}" ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
return 1
return 0
}
→chroma/-zinit-verify-disabled-completion() {
local _scmd="$1" _wrd="$4"
# Find enabled completions
typeset -a completions
completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_]*(N:t) )
[[ -n "${completions[(r)${_wrd#_}]}" ]] && \
__style=${FAST_THEME_NAME}correct-subtle || \
return 1
return 0
}
→chroma/-zinit-verify-compiled-plugin() {
local _scmd="$1" _wrd="$4"
typeset -a plugins
plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N) )
typeset -a show_plugins p matches
for p in "${plugins[@]}"; do
matches=( $p/*.zwc(N) )
if [ "$#matches" -ne "0" ]; then
p="${p:t}"
[[ "$p" = (_local---zinit|custom) ]] && continue
p="${p//---//}"
show_plugins+=( "$p" )
fi
done
[[ -n "${show_plugins[(r)$_wrd]}" ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
return 1
}
→chroma/-zinit-verify-snippet() {
local _scmd="$1" url="$4" dirname local_dir
url="${${url#"${url%%[! $'\t']*}"}%/}"
id_as="${FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]:-${ZINIT_ICE[id-as]:-$url}}"
filename="${${id_as%%\?*}:t}"
dirname="${${id_as%%\?*}:t}"
local_dir="${${${id_as%%\?*}:h}/:\/\//--}"
[[ "$local_dir" = "." ]] && local_dir="" || local_dir="${${${${${local_dir#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}"
local_dir="${ZINIT[SNIPPETS_DIR]}${local_dir:+/$local_dir}"
(( ${+ZINIT_ICE[svn]} || ${FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]} )) && {
# TODO: handle the SVN path's specifics
[[ -d "$local_dir/$dirname" ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
return 1
} || {
# TODO: handle the non-SVN path's specifics
[[ -d "$local_dir/$dirname" ]] && \
{ __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
return 1
}
}
→chroma/-zinit-check-ice-mod() {
local _scmd="$1" _wrd="$4"
[[ "$_wrd" = (svn(\'|\")*|svn) ]] && \
FAST_HIGHLIGHT[chroma-zinit-ice-elements-svn]=1
[[ "$_wrd" = (#b)(id-as(:|)(\'|\")(*)(\'|\")|id-as:(*)|id-as(*)) ]] && \
FAST_HIGHLIGHT[chroma-zinit-ice-elements-id-as]="${match[4]}${match[6]}${match[7]}"
# Copy from zinit-autoload.zsh / -zplg-recall
local -a ice_order nval_ices ext_val_ices
ext_val_ices=( ${(@)${(@Ms.|.)ZINIT_EXTS[ice-mods]:#*\'\'*}//\'\'/} )
ice_order=(
svn proto from teleid bindmap cloneopts id-as depth if wait load
unload blockf pick bpick src as ver silent lucid notify mv cp
atinit atclone atload atpull nocd run-atpull has cloneonly make
service trackbinds multisrc compile nocompile nocompletions
reset-prompt wrap-track reset sh \!sh bash \!bash ksh \!ksh csh
\!csh aliases countdown ps-on-unload ps-on-update trigger-load
light-mode is-snippet atdelete pack git verbose on-update-of
subscribe param extract
# Include all additional ices after
# stripping them from the possible: ''
${(@s.|.)${ZINIT_EXTS[ice-mods]//\'\'/}}
)
nval_ices=(
blockf silent lucid trackbinds cloneonly nocd run-atpull
nocompletions sh \!sh bash \!bash ksh \!ksh csh \!csh
aliases countdown light-mode is-snippet git verbose
# Include only those additional ices,
# don't have the '' in their name, i.e.
# aren't designed to hold value
${(@)${(@s.|.)ZINIT_EXTS[ice-mods]}:#*\'\'*}
# Must be last
svn
)
if [[ "$_wrd" = (#b)(${(~j:|:)${ice_order[@]:#(${(~j:|:)nval_ices[@]:#(${(~j:|:)ext_val_ices[@]})})}})(*) ]]; then
reply+=("$(( __start )) $(( __start+${mend[1]} )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-hyphen-option]}")
reply+=("$(( __start+${mbegin[2]} )) $(( __end )) ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}optarg-string]}")
-fast-highlight-string
return 0
elif [[ "$_wrd" = (#b)(${(~j:|:)nval_ices[@]}) ]]; then
__style=${FAST_THEME_NAME}single-hyphen-option
return 0
else
__style=${FAST_THEME_NAME}incorrect-subtle
return 1
fi
}
return 0
# vim:ft=zsh:et:sw=4

View file

@ -15,7 +15,7 @@
(( next_word = 2 | 8192 ))
chroma/main-chroma-print() {
chroma/main-chroma-print() {
(( FAST_HIGHLIGHT[DEBUG] )) && print "$@" >> /tmp/fsh-dbg
}
@ -25,10 +25,10 @@ local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __en
[[ -z "$__chroma_name" ]] && return 1
# Load the fsh_{name-of-the-chroma}_chroma_def array
(( !FAST_HIGHLIGHT[-${__chroma_name}.ch-chroma-def] )) && chroma/-${__chroma_name}.ch
(( !FAST_HIGHLIGHT[-${__chroma_name}.ch-chroma-def] )) && chroma/-${__chroma_name}.ch
chroma/main-chroma-print -r -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
chroma/main-chroma-print -r -- @@@@@@@ local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" @@@@@@@
chroma/main-chroma-print -r -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
→chroma/main-chroma-print -r -- @@@@@@@ local __chroma_name="${1#\%}" __first_call="$2" __wrd="$3" __start_pos="$4" __end_pos="$5" @@@@@@@
local __style __entry __value __action __handler __tmp __svalue __hspaces=$'\t ' __nl=$'\n' __ch_def_name
integer __idx1 __idx2 __start __end __ivalue __have_value=0
local -a __lines_list __avalue
@ -38,7 +38,7 @@ map=( "#" "_H" "^" "_D" "*" "_S" )
(( __start=_start_pos-__PBUFLEN, __end=_end_pos-__PBUFLEN ))
# Handler that highlights the options
chroma/main-chroma-std-aopt-action() {
chroma/main-chroma-std-aopt-action() {
integer _start="$2" _end="$3"
local _scmd="$1" _wrd="$4"
@ -51,7 +51,7 @@ chroma/main-chroma-std-aopt-action() {
}
# Handler that highlights the options' arguments
chroma/main-chroma-std-aopt-ARG-action() {
chroma/main-chroma-std-aopt-ARG-action() {
integer _start="$2" _end="$3"
local _scmd="$1" _wrd="$4"
@ -61,7 +61,7 @@ chroma/main-chroma-std-aopt-ARG-action() {
}
# This handler also highlights explicit arguments, i.e. --opt=the-explicit-arg
chroma/main-chroma-std-aopt-SEMI-action() {
chroma/main-chroma-std-aopt-SEMI-action() {
integer _start="$2" _end="$3"
local _scmd="$1" _wrd="$4"
@ -75,7 +75,7 @@ chroma/main-chroma-std-aopt-SEMI-action() {
}
# A handler which verifies the token as an GIT url
chroma/main-chroma-std-verify-url() {
chroma/main-chroma-std-verify-url() {
setopt localoptions extendedglob
local _wrd="$4"
integer url_correct=0
@ -99,21 +99,21 @@ chroma/main-chroma-std-verify-url() {
}
# A handler which verifies the token as a shell wildcard
chroma/main-chroma-std-verify-pattern() {
chroma/main-chroma-std-verify-pattern() {
setopt localoptions extendedglob
local _wrd="$4"
__style=${FAST_THEME_NAME}globbing-ext
}
# Creates a hash table for given option set (an *_opt field in the chroma def.)
chroma/main-create-OPTION-hash.ch() {
chroma/main-create-OPTION-hash.ch() {
local __subcmd="$1" __option_set_id="$2" __the_hash_name="$3" __ __e __el __the_hash_name __var_name
local -a __split __sp __s
chroma/main-chroma-print -rl "======================" " **## STARTING ##** chroma/main-##CREATE##-option-HASH.ch // subcmd:$__subcmd // option_set_id:$__option_set_id // h-nam:$__the_hash_name"
chroma/main-chroma-print "[D] Got option-set: ${(j:,:)__option_set_id}"
chroma/main-chroma-print -rl "======================" " **## STARTING ##** chroma/main-##CREATE##-option-HASH.ch // subcmd:$__subcmd // option_set_id:$__option_set_id // h-nam:$__the_hash_name"
chroma/main-chroma-print "[D] Got option-set: ${(j:,:)__option_set_id}"
typeset -gA "$__the_hash_name"
chroma/main-chroma-print "[E] __the_hash_name ${__the_hash_name}:[$__option_set_id]"
chroma/main-chroma-print "[E] __the_hash_name ${__the_hash_name}:[$__option_set_id]"
# Split on ||
__ch_def_name="fsh__${__chroma_name}__chroma__def[${__option_set_id}]"
@ -122,15 +122,22 @@ chroma/main-create-OPTION-hash.ch() {
# Remove only leading and trailing whitespace
__split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
chroma/main-chroma-print -rl "[F] Got ||-__split: _________" ${${(@)${${__split[@]##[[:space:]]##}[@]//[${__hspaces}]##/ }[@]//[${__nl}]##/$__nl}[@]//(#s)/:::} "_________"
chroma/main-chroma-print -rl "[F] Got ||-__split: _________" ${${(@)${${__split[@]##[[:space:]]##}[@]//[${__hspaces}]##/ }[@]//[${__nl}]##/$__nl}[@]//(#s)/:::} "_________"
for __el in $__split; do
__sp=( "${(@s:<<>>:)__el}" )
[[ ${#__sp} -eq 1 && -z "${__sp[1]}" ]] && __sp=()
__sp=( "${__sp[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
chroma/main-chroma-print -l -- "Processing an ||-part - got <<>>-split: _________" "${${__sp[@]}[@]/(#s)/-\\t}" "_________"
chroma/main-chroma-print -l -- "Processing an ||-part - got <<>>-split: _________" "${${__sp[@]}[@]/(#s)/-\\t}" "_________"
__e="${__sp[1]}"
__s=( "${(@)${(@s:|:)${${__e#\(}%\)(:add|:del|)}}//(#e)/${${(M)__e##\(*\)(:add|:del)}:+${(M)__e%(:add|:del)}}}" )
local __e1=${${__e#\(}%\)(:add|:del|)}
local __e2=${(M)__e##\(*\)(:add|:del)}
# Split on | with the ( and ) and :add/:del stripped and then append
# the :add or :del depending on what's on the input line
__s=()
for __ in ${(@s:|:)__e1}; do
__s+=( $__${__e2:+${(M)__e%(:add|:del)}} )
done
[[ ${#__s} -eq 1 && -z "${__s[1]}" ]] && __s=()
__s=( "${__s[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
shift __sp
@ -138,12 +145,12 @@ chroma/main-create-OPTION-hash.ch() {
for __ in $__s; do
__=${__%\^}
[[ "$__" = -*:(add|del) ]] && __var_name="${__the_hash_name}[${__}-directive]" || __var_name="${__the_hash_name}[${__}-opt-action]"
chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[1]}${${${#__sp}:#(0|1)}:+ +}<<"
chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[1]}${${${#__sp}:#(0|1)}:+ +}<<"
: ${(P)__var_name::=${__sp[1]}${${${#__sp}:#(0|1)}:+ +}}
if (( ${#__sp} >= 2 )); then
__var_name="${__the_hash_name}[${__}-opt-arg-action]"
chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[2]}<<}"
chroma/main-chroma-print "${(r:70:: :):-${__var_name}} := >>${__sp[2]}<<}"
: ${(P)__var_name::=$__sp[2]}
fi
done
@ -151,18 +158,18 @@ chroma/main-create-OPTION-hash.ch() {
}
# Processes given token
chroma/main-process-token.ch() {
chroma/main-process-token.ch() {
local __subcmd="$1" __wrd="$2" __val __var_name __main_hash_name __the_hash_name __i __size
local -a __splitted __split __added
chroma/main-chroma-print "\n******************* Starting chroma/main-process-token <<$__wrd>>// subcmd:${(qq)__subcmd}"
chroma/main-chroma-print "\n******************* Starting chroma/main-process-token <<$__wrd>>// subcmd:${(qq)__subcmd}"
__main_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^\*])/${map[${match[1]}]}}"
__var_name="${__main_hash_name}[subcmd:$__subcmd]"
__splitted=( "${(@s://:P)__var_name}" )
[[ ${#__splitted} -eq 1 && -z "${__splitted[1]}" ]] && __splitted=()
__splitted=( "${__splitted[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
chroma/main-chroma-print -rl -- "[B] MAIN-PROCESS-TOKEN: got [OPTION/ARG-**S-E-T-S**] //-splitted from subcmd:$__subcmd: ${${(j:, :)__splitted}:-EMPTY-SET!}" "----- __splitted\\Deleted: -----" ${${(j:, :)${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (deleted)!} "----- Added\\Deleted: -----" ${${(j:, :)${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (added)!} -----\ Deleted:\ ----- ${(j:, :)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}} >> /tmp/reply
chroma/main-chroma-print -rl -- "[B] MAIN-PROCESS-TOKEN: got [OPTION/ARG-**S-E-T-S**] //-splitted from subcmd:$__subcmd: ${${(j:, :)__splitted}:-EMPTY-SET!}" "----- __splitted\\Deleted: -----" ${${(j:, :)${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (deleted)!} "----- Added\\Deleted: -----" ${${(j:, :)${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}}:-EMPTY-SET (added)!} -----\ Deleted:\ ----- ${(j:, :)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}} >> /tmp/reply
(( ! ${#__splitted} )) && {
__var_name="${__main_hash_name}[subcmd:*]"
@ -172,25 +179,24 @@ chroma/main-process-token.ch() {
(( ! ${#__splitted} )) && return 1
}
chroma/main-chroma-print -rl -- "---NO-HASH-CREATE-FROM-NOW-ON---"
chroma/main-chroma-print -rl -- "---NO-HASH-CREATE-FROM-NOW-ON---"
# Options occuring before a subcommand
if [[ -z "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}" ]]; then
chroma/main-chroma-print -rl -- "-z OPT-WITH-ARG-ACTIVE == true"
chroma/main-chroma-print -rl -- "-z OPT-WITH-ARG-ACTIVE == true"
if [[ "$__wrd" = -* ]]; then
chroma/main-chroma-print "1st-PATH (-z opt-with-arg-active, non-opt-arg branch, i.e. OPTION BRANCH) [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]"
chroma/main-chroma-print "1st-PATH (-z opt-with-arg-active, non-opt-arg branch, i.e. OPTION BRANCH) [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]"
for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do
[[ "${__val}" != "${__val%%_([0-9]##|\#)##*}"_${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}_opt(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_opt(\*|\^|) ]] && { chroma/main-chroma-print "DIDN'T MATCH $__val / arg counter:${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue; } || chroma/main-chroma-print "Got candidate: $__val"
[[ "${__val}" != "${__val%%_([0-9]##|\#)##*}"_${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}_opt(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_opt(\*|\^|) ]] && { chroma/main-chroma-print "DIDN'T MATCH $__val / arg counter:${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue; } || chroma/main-chroma-print "Got candidate: $__val"
# Create the hash cache-parameter if needed
__the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//(#b)([\#\^\*])/${map[${match[1]}]}}//[^a-zA-Z0-9_]/_}"
[[ "$__val" = *_opt(\*|\^|) && "${(P)+__the_hash_name}" -eq 0 ]] && chroma/main-create-OPTION-hash.ch "$__subcmd" "$__val" "$__the_hash_name" || chroma/main-chroma-print "Not creating, the hash already exists..."
[[ "$__val" = *_opt(\*|\^|) && "${(P)+__the_hash_name}" -eq 0 ]] && chroma/main-create-OPTION-hash.ch "$__subcmd" "$__val" "$__the_hash_name" || chroma/main-chroma-print "Not creating, the hash already exists..."
# Try dedicated-entry for the option
__var_name="${__the_hash_name}[${${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action]"
__split=( "${(@s://:P)__var_name}" )
[[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=()
# If no result, then try with catch-all entry
(( ! ${#__split} )) && {
chroma/main-chroma-print "% no ${(q-)${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action, retrying with *-opt-action" "|__var_name|:$__var_name"
chroma/main-chroma-print "% no ${(q-)${${${(M)__wrd#?*=}:+${__wrd%=*}=}:-$__wrd}}-opt-action, retrying with *-opt-action" "|__var_name|:$__var_name"
__var_name="${__the_hash_name}[*-opt-action]"
__split=( "${(@s://:P)__var_name}" )
[[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && __split=()
@ -198,19 +204,19 @@ chroma/main-process-token.ch() {
__svalue="$__var_name"
# Remove whitespace
__split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
chroma/main-chroma-print -l -- "\`$__val' // ${#__split} // $__wrd: (ch.run #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]}), deref. of \`$__var_name'"
chroma/main-chroma-print -l -- "\`$__val' // ${#__split} // $__wrd: (ch.run #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]}), deref. of \`$__var_name'"
if (( ${#__split} )); then
chroma/main-chroma-print -l -- "Got split of {\$#__split:$#__split} ${__wrd}-opt-action or *-opt-action" "${${(q-)__split[@]}[@]/(#s)/->\\t}"
chroma/main-chroma-print -l -- "Got split of {\$#__split:$#__split} ${__wrd}-opt-action or *-opt-action" "${${(q-)__split[@]}[@]/(#s)/->\\t}"
if [[ "${__split[2]}" = *[[:blank:]]+ ]]; then
chroma/main-chroma-print "YES handling the value (the OPT.ARGUMENT)! [${__split[2]}]"
chroma/main-chroma-print "YES handling the value (the OPT.ARGUMENT)! [${__split[2]}]"
if [[ "$__wrd" = *=* ]]; then
chroma/main-chroma-print "The-immediate Arg-Acquiring, of option"
chroma/main-chroma-print "The-immediate Arg-Acquiring, of option"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="${__wrd#*=}"
__have_value=2
else
chroma/main-chroma-print "Enable Arg-Awaiting, of option"
chroma/main-chroma-print "FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]=\"${__svalue%-opt-action\]}-opt-arg-action]\""
chroma/main-chroma-print "Enable Arg-Awaiting, of option"
chroma/main-chroma-print "FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]=\"${__svalue%-opt-action\]}-opt-arg-action]\""
__have_value=0
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]="${__svalue%-opt-action\]}-opt-arg-action]"
fi
@ -234,27 +240,27 @@ chroma/main-process-token.ch() {
# First: del-directive
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${(j: :)__split[__ivalue+1,__tmp]} "
chroma/main-chroma-print -rl ":add / :del directives: __ivalue:$__ivalue, THE __SPLIT[#$__tmp]: " "${__split[@]}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]} >> /tmp/reply
chroma/main-chroma-print -rl ":add / :del directives: __ivalue:$__ivalue, THE __SPLIT[#$__tmp]: " "${__split[@]}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]} >> /tmp/reply
# Second: add-directive
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]+="${(j: :)__split[1,__ivalue]} "
fi
[[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}" || __handler=""
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(1): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ "$__have_value" -ne 2 && -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl "Running action (1): $__action" ; eval "() { $__action; }"; }
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(1): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ "$__have_value" -ne 2 && -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl "Running action (1): $__action" ; eval "() { $__action; }"; }
[[ "$__val" != *\* ]] && break
else
chroma/main-chroma-print -rl -- "NO-MATCH ROUTE TAKEN"
chroma/main-chroma-print -rl -- "NO-MATCH ROUTE TAKEN"
fi
done
else
chroma/main-chroma-print "1st-PATH-B (-z opt-with-arg-active, non-opt-arg branch, ARGUMENT BRANCH [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]) //// added-nodes: ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}"
chroma/main-chroma-print "1st-PATH-B (-z opt-with-arg-active, non-opt-arg branch, ARGUMENT BRANCH [#${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}]) //// added-nodes: ${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}"
for __val in ${__splitted[@]:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})} ${${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}:#(${(~j:|:)${(@)=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}})}; do
[[ "${__val}" != "${__val%%_([0-9]##|\#)*}"_"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"_arg(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_arg(\*|\^|) ]] && { chroma/main-chroma-print "Continuing for $__val / arg counter ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue }
[[ "${__val}" != "${__val%%_([0-9]##|\#)*}"_"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"_arg(\*|\^|) && "${__val}" != "${__val%%_([0-9]##|\#)*}"_"#"_arg(\*|\^|) ]] && { chroma/main-chroma-print "Continuing for $__val / arg counter ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}" ; continue }
# Create the hash cache-parameter if needed
__the_hash_name="fsh__chroma__${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}__${__subcmd//[^a-zA-Z0-9_]/_}__${${__val//\#/H}//[^a-zA-Z0-9_]/_}"
__action="" __handler=""
chroma/main-chroma-print "A hit, chosen __val:$__val!"
chroma/main-chroma-print "A hit, chosen __val:$__val!"
__ch_def_name="fsh__${__chroma_name}__chroma__def[$__val]"
__split=( "${(P@s:<<>>:)__ch_def_name}" )
__split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
@ -265,13 +271,13 @@ chroma/main-process-token.ch() {
# Verify if it's the expected argument
[[ "${__sp[1]}" = *:::::* && "$__wrd" != ${~${__sp[1]%% ##:::::*}} ]] && \
{ chroma/main-chroma-print -r "mismatch ${__sp[1]%% ##:::::*} != $__wrd, continuing" ; continue; }
{ chroma/main-chroma-print -r "mismatch ${__sp[1]%% ##:::::*} != $__wrd, continuing" ; continue; }
chroma/main-chroma-print -l -- "Got action record for $__val, i.e. the split:" "${__sp[@]//(#s)/-\t}" "_________"
chroma/main-chroma-print -l -- "Got action record for $__val, i.e. the split:" "${__sp[@]//(#s)/-\t}" "_________"
[[ "${__sp[2]}" = ::[^[:space:]]* ]] && __handler="${__sp[2]#::}" || { [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && chroma/main-chroma-print "=== Error === In chroma definition: a handler entry ${(q)__sp[2]} without leading \`::'" ; }
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(3): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running action(3): $__action" ; eval "() { $__action; } \"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}\" \"$__start\" \"$__end\" \"$__wrd\""; }
[[ "${__sp[2]}" = ::[^[:space:]]* ]] && __handler="${__sp[2]#::}" || { [[ -n "$__handler" && "$__handler" != "NO-OP" ]] && chroma/main-chroma-print "=== Error === In chroma definition: a handler entry ${(q)__sp[2]} without leading \`::'" ; }
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(3): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running action(3): $__action" ; eval "() { $__action; } \"${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}\" \"$__start\" \"$__end\" \"$__wrd\""; }
# Check for argument directives (like :add)
if (( ${#__split} >= 2 )); then
@ -283,54 +289,54 @@ chroma/main-process-token.ch() {
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]+="${__splitted[1]#del:} ${(j: :)__splitted[2,-1]} "
fi
done
chroma/main-chroma-print -l "ARGUMENT :add / :del directives: THE __SPLIT[#${#__split}]: " "${__split[@]//(#s)/-\\t}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}//(#s)/-\\t} "The FAST_HIGHLIGHT[chroma-*added-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}//(#s)/-\\t}
chroma/main-chroma-print -l "ARGUMENT :add / :del directives: THE __SPLIT[#${#__split}]: " "${__split[@]//(#s)/-\\t}" "//" "The FAST_HIGHLIGHT[chroma-*deleted-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-deleted-nodes]}//(#s)/-\\t} "The FAST_HIGHLIGHT[chroma-*added-nodes]: " ${(@)${=FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-added-nodes]}//(#s)/-\\t}
fi
[[ "$__val" != *\* ]] && break
done
fi
else
chroma/main-chroma-print -- "2nd-PATH (-n opt-with-arg-active) NON-EMPTY arg-active:\nThe actual opt-val <<< \$__wrd:$__wrd >>> store (after the \`Arg-Awaiting' in the chroma-run: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]-1 )) [current: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] ))])"
chroma/main-chroma-print -- "2nd-PATH (-n opt-with-arg-active) NON-EMPTY arg-active:\nThe actual opt-val <<< \$__wrd:$__wrd >>> store (after the \`Arg-Awaiting' in the chroma-run: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]-1 )) [current: #$(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] ))])"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-arg]="$__wrd"
__have_value=1
fi
# Execute the action if not during simulated opt-argument (--opt=...)
chroma/main-chroma-print "** BEFORE: \`if (( __have_value ))'"
chroma/main-chroma-print "** BEFORE: \`if (( __have_value ))'"
if (( __have_value )); then
chroma/main-chroma-print "In the \`if (( __have_value ))' [have_value: $__have_value]"
chroma/main-chroma-print "In the \`if (( __have_value ))' [have_value: $__have_value]"
# Split
__var_name="${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]=""
__split=( "${(@s://:P)__var_name}" )
[[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && { chroma/main-chroma-print -rl "NULL at __var_name:$__var_name" ; __split=(); }
[[ ${#__split} -eq 1 && -z "${__split[1]}" ]] && { chroma/main-chroma-print -rl "NULL at __var_name:$__var_name" ; __split=(); }
__split=( "${__split[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
# Remember 1st level action
(( __have_value == 2 )) && __value="$__action" || __value=""
if (( ${#__split} )); then
chroma/main-chroma-print -l -- "Got //-split (3, for opt-ARG-action, from [$__var_name]):" "${${(q-)__split[@]}[@]/(#s)/+\\t}"
chroma/main-chroma-print -l -- "Got //-split (3, for opt-ARG-action, from [$__var_name]):" "${${(q-)__split[@]}[@]/(#s)/+\\t}"
__action="${__split[1]}"
__handler="${__split[2]}"
[[ "$__handler" = ::[^[:space:]]* ]] && __handler="${__handler#::}"
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(2): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running action(2): $__action" ; eval "$__action"; }
chroma/main-chroma-print -rl -- "The __action value: [$__value]"
[[ "$__have_value" -eq 2 && -n "$__value" && "$__value" != "NO-OP" ]] && { chroma/main-chroma-print -rl "Running action (of 1, at 2): $__value" ; eval "$__value"; }
[[ -n "$__handler" && "$__handler" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running handler(2): $__handler" ; "$__handler" "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]:-NULL}" "$__start" "$__end" "$__wrd"; }
[[ -n "$__action" && "$__action" != "NO-OP" ]] && { chroma/main-chroma-print -rl -- "Running action(2): $__action" ; eval "$__action"; }
chroma/main-chroma-print -rl -- "The __action value: [$__value]"
[[ "$__have_value" -eq 2 && -n "$__value" && "$__value" != "NO-OP" ]] && { chroma/main-chroma-print -rl "Running action (of 1, at 2): $__value" ; eval "$__value"; }
fi
fi
chroma/main-chroma-print -- "_________ Exiting chroma/main-process-token.ch $__subcmd / $__wrd _________"
chroma/main-chroma-print -- "_________ Exiting chroma/main-process-token.ch $__subcmd / $__wrd _________"
}
# Iterates over the chroma def. fields and creates initial
# fields in the fsh__${__chroma_name}__chroma__def hash
chroma/-pre_process_chroma_def.ch() {
chroma/-pre_process_chroma_def.ch() {
local __key __value __ke _val __the_hash_name="$1" __var_name
local -a __split
chroma/main-chroma-print -rl -- "Starting PRE-PROCESS for __the_hash_name:$__the_hash_name"
→chroma/main-chroma-print -rl -- "Starting PRE_PROCESS for __the_hash_name:$__the_hash_name"
__ch_def_name="fsh__${__chroma_name}__chroma__def[subcommands]"
local __subcmds="${(P)__ch_def_name}"
@ -342,7 +348,7 @@ chroma/-pre_process_chroma_def.ch() {
__var_name="${__the_hash_name}[subcommands]"
: ${(P)__var_name::=$__subcmds}
fi
chroma/main-chroma-print "Got SUBCOMMANDS: ${(P)__var_name}"
chroma/main-chroma-print "Got SUBCOMMANDS: ${(P)__var_name}"
__ch_def_name="fsh__${__chroma_name}__chroma__def[subcmd-hook]"
local __subcmd_hook="${(P)__ch_def_name}"
@ -360,13 +366,13 @@ chroma/-pre_process_chroma_def.ch() {
__var_name="${__the_hash_name}[subcmd:$__ke]"
__ch_def_name="fsh__${__chroma_name}__chroma__def[$__key]"
: ${(P)__var_name::=${(P)__ch_def_name}}
chroma/main-chroma-print -rl -- "Storred ${__var_name}=chroma_def[$__key], i.e. = ${(P)__ch_def_name}"
chroma/main-chroma-print -rl -- "Storred ${__var_name}=chroma_def[$__key], i.e. = ${(P)__ch_def_name}"
done
done
}
if (( __first_call )); then
chroma/-${__chroma_name}-first-call
chroma/-${__chroma_name}-first-call
FAST_HIGHLIGHT[chroma-current]="$__wrd"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]=0
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=0
@ -380,8 +386,8 @@ if (( __first_call )); then
__the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}"
(( 0 == ${(P)+__the_hash_name} )) && {
typeset -gA "$__the_hash_name"
chroma/-pre_process_chroma_def.ch "$__the_hash_name"
} || chroma/main-chroma-print "...No... [\$+var: ${(P)+__the_hash_name}]"
chroma/-pre_process_chroma_def.ch "$__the_hash_name"
} || →chroma/main-chroma-print "...No... [\${+$__the_hash_name} ${(P)+__the_hash_name}]"
return 1
else
(( ++ FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr] ))
@ -391,43 +397,50 @@ else
# "starts new command", if so pass-through chroma ends
[[ "$__arg_type" = 3 ]] && return 2
chroma/main-chroma-print "== @@ Starting @@ #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]} Main-Chroma-call == // << __WORD:$__wrd >> ## Subcommand: ${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL} //@@// -n option-with-arg-active:${(q-)FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}"
chroma/main-chroma-print "== @@ Starting @@ #${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-call-nr]} Main-Chroma-call == // << __WORD:$__wrd >> ## Subcommand: ${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL} //@@// -n option-with-arg-active:${(q-)FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}"
if [[ "$__wrd" = -* || -n "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-option-with-arg-active]}"
]]; then
chroma/main-chroma-print "## The \`if -*' i.e. \`IF OPTION' MAIN branch"
chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd"
chroma/main-chroma-print "## The \`if -*' i.e. \`IF OPTION' MAIN branch"
chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd"
else
# If at e.g. '>' or destination/source spec (of the redirection)
if (( in_redirection > 0 )); then
if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
return 1
elif (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand] == 0 )); then
elif (( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand] == 0 )) {
__the_hash_name="fsh__chroma__main__${${FAST_HIGHLIGHT[chroma-current]//[^a-zA-Z0-9_]/_}//(#b)([\#\^])/${map[${match[1]}]}}"
__var_name="${__the_hash_name}[subcommands]"
if [[ "$__wrd" = ${(P)~__var_name} ]]; then
chroma/main-chroma-print "GOT-SUBCOMMAND := $__wrd, subcmd verification / OK"
chroma/main-chroma-print "GOT-SUBCOMMAND := $__wrd, subcmd verification / OK"
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-got-subcommand]=1
FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="$__wrd"
__var_name="${__the_hash_name}[subcmd-hook]"
(( ${(P)+__var_name} )) && { chroma/main-chroma-print -r -- "Running subcmd-hook: ${(P)__var_name}" ; "${(P)__var_name}" "$__wrd"; }
(( ${(P)+__var_name} )) && { chroma/main-chroma-print -r -- "Running subcmd-hook: ${(P)__var_name}" ; "${(P)__var_name}" "$__wrd"; }
__style="${FAST_THEME_NAME}subcommand"
else
chroma/main-chroma-print "subcmd verif / NOT OK; Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" >> /tmp/fsh-dbg
chroma/main-chroma-print "subcmd verif / NOT OK; Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))" >> /tmp/fsh-dbg
(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 ))
chroma/main-chroma-print "UNRECOGNIZED ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"
chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd"
chroma/main-chroma-print "UNRECOGNIZED ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"
chroma/main-process-token.ch "${${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}:-NULL}" "$__wrd"
fi
else
} else {
__wrd="${__wrd//\`/x}"
__arg="${__arg//\`/x}"
__wrd="${(Q)__wrd}"
chroma/main-chroma-print "Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))"
(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 ))
chroma/main-chroma-print "ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"
local __tmp_def_name="fsh__${__chroma_name}__chroma__def[subcommands-blacklist]"
if [[ ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]} = \
(${(~j:|:)${(@s:,:)${(PA)__tmp_def_name}}})
]] {
return 1
}
chroma/main-chroma-print "ELSE *-got-subcommand == 1 is TRUE"
chroma/main-process-token.ch "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}" "$__wrd"
fi
→chroma/main-chroma-print "Incrementing the COUNTER-ARG ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]} -> $(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] + 1 ))"
(( FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg] += 1 ))
→chroma/main-chroma-print "ARGUMENT ${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-counter-arg]}"
→chroma/main-chroma-print "ELSE *-got-subcommand == 1 is TRUE"
→chroma/main-process-token.ch "${FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]}" "$__wrd"
}
fi
fi