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
Daniel Shahaf
79e8c2dd48
Don't highlight syntax elements as paths.
...
Without this, redirections, history expansions, and command separators would
be matched by path_approx.
A test case is simply LBUFFER="<" RBUFFER="" (highlighted as redirection with this
fix and as path_approx without it).
Fixes zsh-users/zsh-syntax-highlighting#204 .
2015-09-26 18:28:48 +00:00
Daniel Shahaf
4ec821b2b1
Highlight redirections.
...
Fixes zsh-users/zsh-syntax-highlighting#23 .
* danielsh/i23-highlight-redirections:
Highlight redirections.
2015-09-26 17:58:07 +00:00
Daniel Shahaf
6732783d46
back-dollar-quoted-argument: Correct an off-by-one.
...
Highlight the last character of a «\xHH» escape when it is the last thing in
LBUFFER. This is similar to what b0cc02ed86
did
for issue #186 .
2015-09-26 01:09:37 +00:00
Daniel Shahaf
0788514cbd
back-dollar-quoted-argument: Correct octal escape syntax.
...
A leading zero, as in '\0NNN', is permitted by 'echo' but not by 'print',
and «$''» follows 'print'.
2015-09-25 21:54:37 +00:00
Daniel Shahaf
8a43bd2cd9
back-dollar-quoted-argument: Highlight \uHHHH and \UHHHHHHHH escapes.
2015-09-25 21:45:38 +00:00
Daniel Shahaf
98366ade11
back-dollar-quoted-argument: Don't consider \0xHH a hex escape sequence.
...
A leading zero is not permitted in the '\xHH' syntax.
2015-09-25 21:45:38 +00:00
Daniel Shahaf
78ad649d47
back-dollar-quoted-argument: Don't consider comma a hex character.
...
Character class syntax does not ignore commas between ranges.
2015-09-25 21:45:38 +00:00
Daniel Shahaf
69fcb40275
Highlight backslash escapes within $'' strings.
...
Correct highlighting of backslash escapes within "" strings: highlight only
the four specific escape sequences defined there.
Fixes zsh-users/zsh-syntax-highlighting#196 .
2015-09-25 21:45:38 +00:00
Daniel Shahaf
f4164ac86c
internal: Document a function-local variable.
2015-09-25 21:22:09 +00:00
Daniel Shahaf
9c7a1109c8
WARN_CREATE_GLOBAL: don't leak the arithmetic for loop's index variable.
...
Found by code inspection; WARN_CREATE_GLOBAL missed this.
2015-09-25 20:57:51 +00:00
Daniel Shahaf
040df93c01
Highlight redirections.
...
Fixes zsh-users/zsh-syntax-highlighting#23 .
2015-09-25 12:42:34 +00:00
Daniel Shahaf
66eb801358
dollar-double-quoted-argument: Handle «"foo$"» correctly.
2015-09-24 19:03:17 +00:00
Daniel Shahaf
b0cc02ed86
dollar-double-quoted-argument: Highlight "$foo" better.
...
Now, «"$42foo"» doesn't highlight the «foo», and «"$bar» highlights the «r».
2015-09-24 19:03:00 +00:00
Daniel Shahaf
908c4fe150
Stop leaking variables into global namespace.
...
Set WARN_CREATE_GLOBAL to prevent recurrence.
Fixes zsh-users/zsh-syntax-highlighting#192 .
2015-09-24 18:01:06 +00:00
Daniel Shahaf
9e80fe8f02
Bump copyright years.
2015-09-24 16:46:28 +00:00
Daniel Shahaf
5fb4cb2f72
Fix regression: Highlight ';' as commandseparator.
...
This was broken by c2b9327b07
and tracked as zsh-users/zsh-syntax-highlighting#199 .
This fixes the vanilla-newline.zsh test, which was was (consciously) broken
by the previous commit.
2015-09-23 14:50:22 +00:00
Daniel Shahaf
a8afbdf2f5
Support $''-quoted strings.
...
This does not yet highlight backslash escapes within them.
2015-09-10 20:02:39 +00:00
Daniel Shahaf
555e142e66
suffix aliases: Highlight differently.
...
Add an underline, since they are at command word position but will be executed
by something else.
Suggested-by: Daniel Hahler
2015-09-08 10:13:16 +00:00
Daniel Shahaf
e13c5a1611
Highlight 'noglob' correctly in more cases.
...
Fixes zsh-users/zsh-syntax-highlighting#189 .
2015-09-07 18:07:59 +00:00
Daniel Shahaf
8515b7e0c5
Highlight ? as globbing.
...
Fixes zsh-users/zsh-syntax-highlighting#94 .
2015-09-07 18:05:56 +00:00
Daniel Shahaf
dc701501e5
Highlight ? as globbing.
...
Fixes zsh-users/zsh-syntax-highlighting#94 .
2015-09-07 18:03:14 +00:00
Daniel Shahaf
9310d8ae71
Support suffix aliases
...
Fixes zsh-users/zsh-syntax-highlighting#126 .
2015-09-07 17:59:52 +00:00
Daniel Shahaf
b3ceea8511
Highlight 'noglob' correctly in more cases.
...
Fixes zsh-users/zsh-syntax-highlighting#189 .
2015-09-07 09:09:17 +00:00
Daniel Shahaf
a0b5bc6c71
Fix bug in previous commit ( d330b49b33
)
...
'local' is a reserved word in zsh 5.1 but not in earlier versions [1].
Therefore, under zsh older than 5.1, quoting is required.
This manifested as random «builtin=''» in emitted to the terminal, and
commands (such as 'echo') highlighted as errors (in red).
[1] https://github.com/zsh-users/zsh/blob/master/README#L46
(the section "Incompatibilites between 5.0.8 and 5.1")
2015-09-07 01:26:11 +00:00
Daniel Shahaf
d330b49b33
Fix variable leakage into global namespace.
...
Similar to zsh-users/zsh-syntax-highlighting#97 .
2015-09-06 19:20:49 +00:00
Daniel Shahaf
7f41967a17
Highlight array appends: foo+=(bar baz).
...
Fixes zsh-users/zsh-syntax-highlighting#181 .
2015-09-05 09:38:02 +00:00
Daniel Shahaf
51aed8a765
Merge remote-tracking branch 'upstream/pr/179'
...
* upstream/pr/179:
Don't parse first word of array assignment as command
2015-09-04 17:57:08 +00:00
Daniel Shahaf
42495cc5d6
Merge remote-tracking branch 'upstream/pr/161'
...
* upstream/pr/161:
Don't highlight prefix redirections as error
2015-09-04 17:27:25 +00:00
Daniel Shahaf
c2b9327b07
Support literal newlines, part 2
2015-09-02 09:30:08 +00:00
Daniel Shahaf
52ece975c3
Update comments. No functional change.
2015-09-02 02:37:43 +00:00
Daniel Shahaf
b9b67b9f78
Don't parse first word of array assignment as command
...
Fixes zsh-users/zsh-syntax-highlighting#178
2015-08-28 09:52:52 +00:00
Daniel Shahaf
359d48bf78
Don't highlight prefix redirections as error
...
Fixes zsh-users/zsh-syntax-highlighting#146
2015-02-16 02:44:56 +00:00
Daniel Shahaf
ff4d402e9a
Highlight the first part of multiline strings correctly
...
Given the following input:
PREBUFFER=$'echo "foo\n'
BUFFER='bar"'
This patch causes the '"foo' part to be highlighted as a string. There
is no test because the tests only check highlighting of BUFFER, and 'bar"'
is already highlighted correctly.
2015-02-02 15:12:59 +00:00
Daniel Shahaf
384be15b13
Support literal newlines
2015-01-27 10:23:59 +00:00
Daniel Shahaf
23cacb12fe
Support backslash continuations
2015-01-27 10:23:59 +00:00
Daniel Shahaf
667495bfb7
Support multiline strings
2015-01-27 10:23:58 +00:00
Daniel Shahaf
2c5acaefa9
Refactoring, no functional change
...
The new function will be used in the next commit.
2015-01-27 10:23:58 +00:00
sonnym
04f9c8884f
highlight ^old^new pattern
...
by extending the already in place mechanism of checking for the first
histchar to check for the second as well
2013-12-07 05:11:19 -05:00
Julien Nicoulaud
f289a9f8e7
Merge pull request #125 from acatton/fix-121
...
Fix #121 : sudo syntax highlighting incorrectly
2013-11-19 11:42:03 -08:00
Julien Nicoulaud
8ac964186d
Merge pull request #131 from MarkLodato/array-assignments
...
Properly highlight array assignments
2013-11-19 11:40:29 -08:00
Julien Nicoulaud
ffce2a0b20
Merge pull request #133 from lucc/master
...
protect alias expansion from interpreting aliases as options
2013-11-19 11:39:40 -08:00
Lucas Hoffmann
784a5dc35b
protect alias expansion from interpreting aliases as options
...
If one defines aliases like `++` the alias builtin tries to interprete these
as options so they have to be protected like this
alias -- ++=true
The same goes for a call to `alias` in order to expand the alias again.
2013-11-05 00:50:20 +01:00
Mark Lodato
441f1a8aad
highlight array assignments of the form x[y]=...
...
This code is more lenient than bash. Examples:
$ x[y[]=
zsh: no matches found: x[y[]=
$ x[][]=
zsh: no matches found: x[][]=
The proper solution is to look inside the [...] and make sure that all
unescaped/unquoted square brackes are matched, but that is a heck of
a lot more complicated than this simple 8-character patch.
2013-10-30 00:53:46 -04:00
Mark Lodato
c62cb54e9d
do not remove quotes when checking assignments
...
Zsh does not allow the variable name or the equals sign to be quoted or
escaped. The previous code incorrectly highlighted the following
examples as assignments:
$ 'x=y'
zsh: command not found: x=y
$ x\=y
zsh: command not found: x=y
$ "x"=y
zsh: command not found: x=y
$ \x=y
zsh: command not found: x=y
2013-10-30 00:00:16 -04:00
Akinori MUSHA
0fc6b07509
Do not leak a variable: cdpath_dir.
...
Leaking a variable that holds a path in CDPATH could easily end up appearing on your prompt like `~cdpath_dir/subdir`.
2013-10-21 21:18:38 +09:00
Antoine Catton
3b3a58be91
Fix #121 : sudo syntax highlighting incorrectly
...
Parse sudo command line in order to highlight the options correctly
2013-09-28 19:33:34 -06:00
Julien Nicoulaud
08b80022ca
Merge pull request #123 from Shura0/master
...
Highlighted dollar variable ver. 2
2013-08-09 00:47:32 -07:00
Shura
a7ee0597ef
Update main-highlighter.zsh
...
Comments added
2013-08-09 10:24:14 +04:00
Julien Nicoulaud
3677b75731
Merge pull request #115 from Valodim/master
...
add separate path_prefix and path_approx hilights
2013-08-08 07:31:46 -07:00
Владимир
57c01d19de
Update main-highlighter.zsh
...
Add support of CDPATH
2013-08-07 03:21:15 +03:00
Shura
8abcf187f6
dollar variable and backslash codes highlighting
2013-07-29 17:33:34 +04:00
Vincent Breitmoser
228f5a6aad
add separate path_prefix and path_approx hilights
2013-07-25 04:41:09 +02:00
evan
19981ef9ea
added sudo as a precommand
2012-08-17 15:52:09 -04:00
Jud Porter
d82eee5212
add emulate -L zsh to _zsh_highlight_main_highlighter. resolves issue #83
2011-12-02 16:44:33 -05:00
Julien Nicoulaud
f824e5e84d
Options should only be set locally
2011-09-24 14:42:55 +02:00
Andreas Gahr
024c1c46f7
next try. fix for issue #76 without brakeing fix for #21
2011-09-24 20:39:34 +08:00
Julien Nicoulaud
8d4cde6301
(Hopefully) fix #21 (tilde and hashed directories in paths)
2011-09-20 19:13:37 +02:00
Julien Nicoulaud
db8f98fc53
Set default style for pipes and stuff to none
2011-09-20 19:13:37 +02:00
Andreas Gahr
287167d453
fix for issue #76 . This was more ore less forgotten in pull request #75
2011-09-20 19:13:37 +02:00
Andreas Gahr
670961ad01
handle highlighting for precommands; handle highlighting for commands separators
2011-09-20 19:13:37 +02:00
Andreas Gahr
f84f9319d8
supposed fix for issue #73 and issue #74
2011-09-09 16:07:49 +02:00
Julien Nicoulaud
a6d105131c
Fix #21 : No highlighting when using tilde
2011-09-06 19:21:40 +02:00
Takeshi Banse
4a8b184632
pass ${arg} explicit
...
Signed-off-by: Takeshi Banse <takebi@laafc.net>
2011-09-07 01:14:45 +08:00
Valodim
f27ef7a279
after exec token we can expect a command
2011-08-02 00:55:55 +08:00
Julien Nicoulaud
e7d7ccfe35
Group if statements in f26310d97e
2011-06-16 14:54:24 +02:00
Guido
f26310d97e
* enable command lines starting with a hyphen.
2011-06-16 04:28:59 -07:00
Julien Nicoulaud
0772ddd346
Big refactoring.
...
* Don't override user defined styles
* Better modularisation of highlighters
* Allow to define which highlighters are activated
* Allow to define the order in which they are defined
* Minor performance optimizations
* Fixed some variables leak
* Improve documentation
* Brackets highlighter: use ZSH_HIGHLIGHT_STYLES instead of a specific array
2011-06-12 22:57:14 +02:00