Commit graph

117 commits

Author SHA1 Message Date
Daniel Shahaf
17fbcad8ac 'main': Fix state check.
At this time, no user-visible consequences are known.
2015-11-18 16:37:38 +00:00
Daniel Shahaf
29fd6ec1de Support the '|&', '&!', '&|' command separators. 2015-11-17 20:19:19 +00:00
Daniel Shahaf
3ed0f7f823 noop: Consolidate two identical conditionals. 2015-11-17 20:07:14 +00:00
Daniel Shahaf
2dbcb575e5 internal: Document the ':regular' state. 2015-11-17 19:40:58 +00:00
Daniel Shahaf
4fcfb15913 Highlight parameter expansions that are a command word.
Fixes zsh-users/zsh-syntax-highlighting#101.
2015-11-17 01:37:58 +00:00
Daniel Shahaf
bdc1449733 noop: Break out a helper function. 2015-11-17 01:37:12 +00:00
Daniel Shahaf
6e3720f39d dollar-double-quoted-argument: Support the syntax «"${foo}"». (Issue #186.) 2015-11-17 00:40:02 +00:00
Daniel Shahaf
96ee5116b1 Fix issue #228, "Support the PATH_DIRS option". 2015-11-16 23:14:48 +00:00
Daniel Shahaf
b285c7b821 brackets: Highlight closing ')' of array assignments correctly. (Issue #226.)
Followup to c0dafd1d85, which changed the highlight of
those ')'s from <nothing> to [reserved-word].
2015-11-16 18:44:44 +00:00
Daniel Shahaf
c0dafd1d85 brackets: Highlight the closing brackets of subshells and blocks. (Issue #226.) 2015-10-30 20:20:30 +02:00
Daniel Shahaf
28abb960de noop: Follow-up to last: improve readability. 2015-10-30 20:14:03 +02:00
Daniel Shahaf
a59f442d2d brackets: Highlight the closing brackets of arithmetic expansion. (Issue #226.) 2015-10-30 17:28:48 +00:00
Daniel Shahaf
8b4adbd991 Fix issue #222, "command word after repeat". 2015-10-30 13:31:43 +00:00
Daniel Shahaf
9e178f9f39 subshells: Highlight the opening parenthesis correctly. (Issue #166.)
Followup to 0d1bfbcbfa.
2015-10-30 11:38:32 +02:00
Daniel Shahaf
d3deffbf46 minor: Fix WARN_CREATE_GLOBAL warnings issued by zsh 5.1.1-dev-0.
The following warnings are issued by zsh as of zsh-workers/37018 (commit
de9effbce601 to zsh itself):

_zsh_highlight_main_highlighter_highlight_dollar_string:17: array parameter match created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_dollar_string:17: array parameter mbegin created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_dollar_string:17: array parameter mend created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_dollar_string:17: numeric parameter parameter MBEGIN created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_dollar_string:17: numeric parameter parameter MEND created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_dollar_string:17: scalar parameter MATCH created globally in function _zsh_highlight_main_highlighter_highlight_dollar_string
_zsh_highlight_main_highlighter_highlight_string:11: array parameter match created globally in function _zsh_highlight_main_highlighter_highlight_string
_zsh_highlight_main_highlighter_highlight_string:11: array parameter mbegin created globally in function _zsh_highlight_main_highlighter_highlight_string
_zsh_highlight_main_highlighter_highlight_string:11: array parameter mend created globally in function _zsh_highlight_main_highlighter_highlight_string
_zsh_highlight_main_highlighter_highlight_string:11: numeric parameter parameter MBEGIN created globally in function _zsh_highlight_main_highlighter_highlight_string
_zsh_highlight_main_highlighter_highlight_string:11: numeric parameter parameter MEND created globally in function _zsh_highlight_main_highlighter_highlight_string
_zsh_highlight_main_highlighter_highlight_string:11: scalar parameter MATCH created globally in function _zsh_highlight_main_highlighter_highlight_string
2015-10-30 10:12:04 +02:00
Daniel Shahaf
8ab8c815ec Fix syntax error with zsh-5.0.5-dev-1 and older.
zsh prior to workers/32609 (commit 9d47e8398d299e53ffe4e7ddf3731d2fedae9948)
does not support the (-n)-less «[[ $var ]]» syntax.

Fixes zsh-users/zsh-syntax-highlighting#225.
2015-10-30 09:34:16 +02:00
Daniel Shahaf
afa6bb3882 states work: Extend state machine documentation. 2015-10-30 08:38:45 +02:00
Daniel Shahaf
1ac39b0af1 comments: Mark prematurely-terminated command as an error.
This is already done for commands prematurely terminated by ";".
2015-10-30 08:38:45 +02:00
Daniel Shahaf
693de99a90 comments: Fix issue #163 and #167: Highlight comments. 2015-10-30 08:38:44 +02:00
Daniel Shahaf
2f05620b19 sudo: Flag an error when a required argument is missing. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
9cb87473cc sudo: Tweak state computations.
This causes the ':start:' state to be set in $next_word in iteration N-1,
rather than to only be added to $this_word in iteration N.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
a3047a9121 sudo: Highlight an empty sudo; as an error.
The word following 'sudo' was considered :regular:, although it isn't.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
86e9249709 sudo/redirections: Fix remaining part of issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
0d1bfbcbfa Highlight subshells and anonymous functions correctly.
Fixes zsh-users/zsh-syntax-highlighting#166.
Fixes zsh-users/zsh-syntax-highlighting#194.
Builds upon the issue #207 work.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
c216242b46 command word: Highlight more reserved words. Part of issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
2218e26bf8 command word: Highlight 'else' correctly. Part of issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
b397b12ac1 command word: Start fixing issue #207, "Word following certain reserved words should be a command word". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
01d7eeb3c7 Fix issue #205, "';' after assignment is highlighted as unknown-token". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
6d6fb8b03e redirections: Document handling of redirections and possibly fix a latent bug.
The change of behaviour is triggered by test-data/sudo-redirection.zsh: the iteration
on "otheruser" sets $next_word to ":regular::sudo_opt::start::sudo_opt::start:" before
this patch, but to ":regular::sudo_opt::start:" after it (note the deduplication).
2015-10-29 12:01:13 +00:00
Daniel Shahaf
be006aded5 sudo/redirections: Fix part of issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:11 +00:00
Daniel Shahaf
c6355a31b7 Followup to last: re-fix issue #9 and add test for it.
The fix for issue #9 was accidentally broken by the penultimate commit.

Note that we don't care about aliases to ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
entries, since the code deals with aliases at command position.
2015-10-29 12:01:11 +00:00
Daniel Shahaf
018bc45f21 Followup to last: tighten the fix and ask a question. 2015-10-29 12:01:11 +00:00
Daniel Shahaf
2c9f8c8c95 Fix issue #209, "precommand modifiers at non-command-word position". 2015-10-29 12:01:11 +00:00
Daniel Shahaf
88cf98d9c4 states work: Documents the various states. 2015-10-29 12:01:11 +00:00
Daniel Shahaf
0aa6a5db78 states work: Convert $new_expression parsing. 2015-10-29 12:01:11 +00:00
Daniel Shahaf
10b1da64e6 states work: Convert sudo parsing. 2015-10-29 12:01:11 +00:00
Daniel Shahaf
2080a441ac minor: Remove redundant setting of $highlight_glob. 2015-10-28 09:58:13 +02:00
Daniel Shahaf
59fbdda64c main: Refresh highlighting upon accept-* widgets (accept-line et al).
Use this to remove [path_prefix] highlighting during accept-* widgets.
This causes ": file.tx<CR>" to remove the underline from "file.tx", like
": file.tx<SPACE>" already does.  (Assume 'file.txt' exists.)
2015-10-28 09:24:08 +02:00
Daniel Shahaf
fb5ce43799 noop: Rename a local variable for clarity. 2015-10-27 11:59:25 +02:00
Daniel Shahaf
98aee7f8b9 Remove path_approx.
Fixes zsh-users/zsh-syntax-highlighting#187.
Adds a test for zsh-users/zsh-syntax-highlighting#204.
2015-10-27 04:29:05 +00:00
Daniel Shahaf
c687bddea3 Drop unnecessary shebang lines, part 2.
Follow-up to the last commit.

E: zsh-syntax-highlighting: missing-dep-for-interpreter zsh => zsh | zsh-beta (usr/share/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh)
W: zsh-syntax-highlighting: executable-not-elf-or-script usr/share/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh
2015-10-20 12:06:07 +00:00
Daniel Shahaf
e138cfd765 command word: Protect against the case that the command word starts with a minus. 2015-10-02 13:27:21 +00:00
Daniel Shahaf
07fd773d7e noop: Add comments. 2015-09-30 01:26:27 +00:00
Daniel Shahaf
5cd1fb26c0 Resolve tilde expansions in command word.
This causes '~/bin/foo' to highlight as a command, rather than as a file.

Part of issue #201.
2015-09-30 00:49:34 +00:00
Daniel Shahaf
faed2fa49e internal: Fix docstrings. 2015-09-29 23:45:44 +00:00
Daniel Shahaf
69203b1a1d Don't highlight escaped globbing.
Fixes zsh-users/zsh-syntax-highlighting#193.
2015-09-29 23:44:57 +00:00
Daniel Shahaf
800158745a Highlight quoted command words correctly.
Fixes zsh-users/zsh-syntax-highlighting#147.
2015-09-28 19:49:39 +00:00
Daniel Shahaf
7b4598a764 Highlight arithmetic expansions.
Fixes zsh-users/zsh-syntax-highlighting#188 in the case that both the
opening '((' and closing '))' have been typed,  The case that only the
opening '((' have been typed is also fixed, but requires a zsh development
build (zsh-5.1.1-52-g4bed2cf or newer); see comments within.
2015-09-28 13:55:38 +00:00
Daniel Shahaf
52a2ef644b Don't highlight escaped globbing.
Fixes zsh-users/zsh-syntax-highlighting#193.
2015-09-27 16:28:32 +00:00
Daniel Shahaf
6488284814 back-dollar-quoted-argument: Highlight incomplete escape sequences as unknown-token
Followup to 219184f046, which fixed issue #196.
2015-09-27 15:59:04 +00:00