'main': Highlight the 'command' precommand.

Fixes #343.
This commit is contained in:
Daniel Shahaf
2016-07-28 07:50:38 +00:00
committed by Daniel Shahaf
parent 6ccba63f21
commit ea09d483be
2 changed files with 7 additions and 6 deletions

View File

@@ -240,6 +240,7 @@ _zsh_highlight_highlighter_main_paint()
# for that precommand.
local -A precommand_options
precommand_options=(
'command' ''
'sudo' Cgprtu
)
@@ -261,7 +262,7 @@ _zsh_highlight_highlighter_main_paint()
# ';;' ';&' ';|'
)
ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=(
'builtin' 'command' 'exec' 'nocorrect' 'noglob'
'builtin' 'exec' 'nocorrect' 'noglob'
'pkexec' # immune to #121 because it's usually not passed --option flags
)
@@ -532,14 +533,14 @@ _zsh_highlight_highlighter_main_paint()
style=reserved-word # de facto a reserved word, although not de jure
next_word=':start:'
elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
style=precommand
elif (( ${+precommand_options[$arg]} )) && { _zsh_highlight_main__type $arg; [[ -n $REPLY && $REPLY != "none" ]] }; then
if (( ${+precommand_options[$arg]} )) && { _zsh_highlight_main__type $arg; [[ -n $REPLY && $REPLY != "none" ]] }; then
style=precommand
flags_with_argument=${precommand_options[$arg]}
next_word=${next_word//:regular:/}
next_word+=':sudo_opt:'
next_word+=':start:'
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
style=precommand
else
case $res in
reserved) # reserved word