blob: ddb19b5800094e271e843543acaa3a5ab978b003 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaarf2571c62015-06-09 19:44:55 +02002" Language: Zsh shell script
3" Maintainer: Christian Brabandt <cb@256bit.org>
4" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
Bram Moolenaarb17893a2020-03-14 08:19:51 +01005" Latest Revision: 2020-01-23
Bram Moolenaarf2571c62015-06-09 19:44:55 +02006" License: Vim (see :h license)
Bram Moolenaar94237492017-04-23 18:40:21 +02007" Repository: https://github.com/chrisbra/vim-zsh
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00009if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000013let s:cpo_save = &cpo
14set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000015
Bram Moolenaarb17893a2020-03-14 08:19:51 +010016function! s:ContainedGroup()
17 " needs 7.4.2008 for execute() function
18 let result='TOP'
19 " vim-pandoc syntax defines the @langname cluster for embedded syntax languages
20 " However, if no syntax is defined yet, `syn list @zsh` will return
21 " "No syntax items defined", so make sure the result is actually a valid syn cluster
22 for cluster in ['markdownHighlightzsh', 'zsh']
23 try
24 " markdown syntax defines embedded clusters as @markdownhighlight<lang>,
25 " pandoc just uses @<lang>, so check both for both clusters
26 let a=split(execute('syn list @'. cluster), "\n")
27 if len(a) == 2 && a[0] =~# '^---' && a[1] =~? cluster
28 return '@'. cluster
29 endif
30 catch /E392/
31 " ignore
32 endtry
33 endfor
34 return result
35endfunction
36
37let s:contained=s:ContainedGroup()
38
39syn iskeyword @,48-57,_,192-255,#,-
Bram Moolenaarf3913272016-02-25 00:00:01 +010040if get(g:, 'zsh_fold_enable', 0)
41 setlocal foldmethod=syntax
42endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000044syn keyword zshTodo contained TODO FIXME XXX NOTE
Bram Moolenaar071d4272004-06-13 20:20:40 +000045
Bram Moolenaar94237492017-04-23 18:40:21 +020046syn region zshComment oneline start='\%(^\|\s\+\)#' end='$'
Bram Moolenaarf3913272016-02-25 00:00:01 +010047 \ contains=zshTodo,@Spell fold
48
49syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
50 \ contains=zshTodo,@Spell fold
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000052syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
Bram Moolenaar071d4272004-06-13 20:20:40 +000053
Bram Moolenaarb17893a2020-03-14 08:19:51 +010054syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}'
55syn match zshPOSIXQuoted '\\[0-7]\{1,3}'
56syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}'
57syn match zshPOSIXQuoted '\\U[1-9a-fA-F]\{1,8}'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000058syn match zshQuoted '\\.'
59syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+
Bram Moolenaarf3913272016-02-25 00:00:01 +010060 \ contains=zshQuoted,@zshDerefs,@zshSubst fold
61syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000062syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+
Bram Moolenaarb17893a2020-03-14 08:19:51 +010063 \ skip=+\\[\\']+ end=+'+ contains=zshPOSIXQuoted,zshQuoted
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000064syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)'
Bram Moolenaar071d4272004-06-13 20:20:40 +000065
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000066syn keyword zshPrecommand noglob nocorrect exec command builtin - time
Bram Moolenaar071d4272004-06-13 20:20:40 +000067
Bram Moolenaarf2571c62015-06-09 19:44:55 +020068syn keyword zshDelimiter do done end
Bram Moolenaar071d4272004-06-13 20:20:40 +000069
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000070syn keyword zshConditional if then elif else fi case in esac select
Bram Moolenaar071d4272004-06-13 20:20:40 +000071
Bram Moolenaare37d50a2008-08-06 17:06:04 +000072syn keyword zshRepeat while until repeat
73
74syn keyword zshRepeat for foreach nextgroup=zshVariable skipwhite
Bram Moolenaar071d4272004-06-13 20:20:40 +000075
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000076syn keyword zshException always
Bram Moolenaar071d4272004-06-13 20:20:40 +000077
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000078syn keyword zshKeyword function nextgroup=zshKSHFunction skipwhite
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
Bram Moolenaarf3913272016-02-25 00:00:01 +010080syn match zshKSHFunction contained '\w\S\+'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000081syn match zshFunction '^\s*\k\+\ze\s*()'
82
83syn match zshOperator '||\|&&\|;\|&!\='
84
85syn match zshRedir '\d\=\(<\|<>\|<<<\|<&\s*[0-9p-]\=\)'
86syn match zshRedir '\d\=\(>\|>>\|>&\s*[0-9p-]\=\|&>\|>>&\|&>>\)[|!]\='
87syn match zshRedir '|&\='
88
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000089syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaare37d50a2008-08-06 17:06:04 +000090 \ start='<\@<!<<\s*\z([^<]\S*\)'
91 \ end='^\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020092 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000093syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaare37d50a2008-08-06 17:06:04 +000094 \ start='<\@<!<<\s*\\\z(\S\+\)'
95 \ end='^\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020096 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaare37d50a2008-08-06 17:06:04 +000097syn region zshHereDoc matchgroup=zshRedir
98 \ start='<\@<!<<-\s*\\\=\z(\S\+\)'
99 \ end='^\s*\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +0200100 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000101syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200102 \ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000103 \ end='^\z1\>'
104syn region zshHereDoc matchgroup=zshRedir
105 \ start=+<\@<!<<-\s*\(["']\)\z(\S\+\)\1+
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000106 \ end='^\s*\z1\>'
107
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000108syn match zshVariable '\<\h\w*' contained
109
110syn match zshVariableDef '\<\h\w*\ze+\=='
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000111" XXX: how safe is this?
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000112syn region zshVariableDef oneline
Bram Moolenaar94237492017-04-23 18:40:21 +0200113 \ start='\$\@<!\<\h\w*\[' end='\]\ze+\?=\?'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000114 \ contains=@zshSubst
115
Bram Moolenaar94237492017-04-23 18:40:21 +0200116syn cluster zshDerefs contains=zshShortDeref,zshLongDeref,zshDeref,zshDollarVar
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000117
Bram Moolenaar94237492017-04-23 18:40:21 +0200118syn match zshShortDeref '\$[!#$*@?_-]\w\@!'
119syn match zshShortDeref '\$[=^~]*[#+]*\d\+\>'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120
Bram Moolenaar94237492017-04-23 18:40:21 +0200121syn match zshLongDeref '\$\%(ARGC\|argv\|status\|pipestatus\|CPUTYPE\|EGID\|EUID\|ERRNO\|GID\|HOST\|LINENO\|LOGNAME\)'
122syn match zshLongDeref '\$\%(MACHTYPE\|OLDPWD OPTARG\|OPTIND\|OSTYPE\|PPID\|PWD\|RANDOM\|SECONDS\|SHLVL\|signals\)'
123syn match zshLongDeref '\$\%(TRY_BLOCK_ERROR\|TTY\|TTYIDLE\|UID\|USERNAME\|VENDOR\|ZSH_NAME\|ZSH_VERSION\|REPLY\|reply\|TERM\)'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000124
Bram Moolenaar94237492017-04-23 18:40:21 +0200125syn match zshDollarVar '\$\h\w*'
126syn match zshDeref '\$[=^~]*[#+]*\h\w*\>'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000127
128syn match zshCommands '\%(^\|\s\)[.:]\ze\s'
129syn keyword zshCommands alias autoload bg bindkey break bye cap cd
130 \ chdir clone comparguments compcall compctl
131 \ compdescribe compfiles compgroups compquote
132 \ comptags comptry compvalues continue dirs
133 \ disable disown echo echotc echoti emulate
134 \ enable eval exec exit export false fc fg
135 \ functions getcap getln getopts hash history
136 \ jobs kill let limit log logout popd print
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200137 \ printf pushd pushln pwd r read
Bram Moolenaar94237492017-04-23 18:40:21 +0200138 \ rehash return sched set setcap shift
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000139 \ source stat suspend test times trap true
140 \ ttyctl type ulimit umask unalias unfunction
Bram Moolenaar94237492017-04-23 18:40:21 +0200141 \ unhash unlimit unset vared wait
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000142 \ whence where which zcompile zformat zftp zle
Bram Moolenaar7db25fe2018-05-13 00:02:36 +0200143 \ zmodload zparseopts zprof zpty zrecompile
144 \ zregexparse zsocket zstyle ztcp
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000145
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200146" Options, generated by: echo ${(j:\n:)options[(I)*]} | sort
Bram Moolenaarfa735342016-01-03 22:14:44 +0100147" Create a list of option names from zsh source dir:
148" #!/bin/zsh
149" topdir=/path/to/zsh-xxx
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200150" grep '^pindex([A-Za-z_]*)$' $topdir/Doc/Zsh/options.yo |
Bram Moolenaarfa735342016-01-03 22:14:44 +0100151" while read opt
152" do
153" echo ${${(L)opt#pindex\(}%\)}
154" done
155
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200156syn case ignore
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200157
Bram Moolenaar94237492017-04-23 18:40:21 +0200158syn match zshOptStart /^\s*\%(\%(\%(un\)\?setopt\)\|set\s+[-+]o\)/ nextgroup=zshOption skipwhite
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200159syn match zshOption /
160 \ \%(\%(\<no_\?\)\?aliases\>\)\|
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200161 \ \%(\%(\<no_\?\)\?aliasfuncdef\>\)\|\%(\%(no_\?\)\?alias_func_def\>\)\|
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200162 \ \%(\%(\<no_\?\)\?allexport\>\)\|\%(\%(no_\?\)\?all_export\>\)\|
163 \ \%(\%(\<no_\?\)\?alwayslastprompt\>\)\|\%(\%(no_\?\)\?always_last_prompt\>\)\|\%(\%(no_\?\)\?always_lastprompt\>\)\|
164 \ \%(\%(\<no_\?\)\?alwaystoend\>\)\|\%(\%(no_\?\)\?always_to_end\>\)\|
165 \ \%(\%(\<no_\?\)\?appendcreate\>\)\|\%(\%(no_\?\)\?append_create\>\)\|
166 \ \%(\%(\<no_\?\)\?appendhistory\>\)\|\%(\%(no_\?\)\?append_history\>\)\|
167 \ \%(\%(\<no_\?\)\?autocd\>\)\|\%(\%(no_\?\)\?auto_cd\>\)\|
168 \ \%(\%(\<no_\?\)\?autocontinue\>\)\|\%(\%(no_\?\)\?auto_continue\>\)\|
169 \ \%(\%(\<no_\?\)\?autolist\>\)\|\%(\%(no_\?\)\?auto_list\>\)\|
170 \ \%(\%(\<no_\?\)\?automenu\>\)\|\%(\%(no_\?\)\?auto_menu\>\)\|
171 \ \%(\%(\<no_\?\)\?autonamedirs\>\)\|\%(\%(no_\?\)\?auto_name_dirs\>\)\|
172 \ \%(\%(\<no_\?\)\?autoparamkeys\>\)\|\%(\%(no_\?\)\?auto_param_keys\>\)\|
173 \ \%(\%(\<no_\?\)\?autoparamslash\>\)\|\%(\%(no_\?\)\?auto_param_slash\>\)\|
174 \ \%(\%(\<no_\?\)\?autopushd\>\)\|\%(\%(no_\?\)\?auto_pushd\>\)\|
175 \ \%(\%(\<no_\?\)\?autoremoveslash\>\)\|\%(\%(no_\?\)\?auto_remove_slash\>\)\|
176 \ \%(\%(\<no_\?\)\?autoresume\>\)\|\%(\%(no_\?\)\?auto_resume\>\)\|
177 \ \%(\%(\<no_\?\)\?badpattern\>\)\|\%(\%(no_\?\)\?bad_pattern\>\)\|
178 \ \%(\%(\<no_\?\)\?banghist\>\)\|\%(\%(no_\?\)\?bang_hist\>\)\|
179 \ \%(\%(\<no_\?\)\?bareglobqual\>\)\|\%(\%(no_\?\)\?bare_glob_qual\>\)\|
180 \ \%(\%(\<no_\?\)\?bashautolist\>\)\|\%(\%(no_\?\)\?bash_auto_list\>\)\|
181 \ \%(\%(\<no_\?\)\?bashrematch\>\)\|\%(\%(no_\?\)\?bash_rematch\>\)\|
182 \ \%(\%(\<no_\?\)\?beep\>\)\|
183 \ \%(\%(\<no_\?\)\?bgnice\>\)\|\%(\%(no_\?\)\?bg_nice\>\)\|
184 \ \%(\%(\<no_\?\)\?braceccl\>\)\|\%(\%(no_\?\)\?brace_ccl\>\)\|
185 \ \%(\%(\<no_\?\)\?braceexpand\>\)\|\%(\%(no_\?\)\?brace_expand\>\)\|
186 \ \%(\%(\<no_\?\)\?bsdecho\>\)\|\%(\%(no_\?\)\?bsd_echo\>\)\|
187 \ \%(\%(\<no_\?\)\?caseglob\>\)\|\%(\%(no_\?\)\?case_glob\>\)\|
188 \ \%(\%(\<no_\?\)\?casematch\>\)\|\%(\%(no_\?\)\?case_match\>\)\|
189 \ \%(\%(\<no_\?\)\?cbases\>\)\|\%(\%(no_\?\)\?c_bases\>\)\|
190 \ \%(\%(\<no_\?\)\?cdablevars\>\)\|\%(\%(no_\?\)\?cdable_vars\>\)\|\%(\%(no_\?\)\?cd_able_vars\>\)\|
191 \ \%(\%(\<no_\?\)\?chasedots\>\)\|\%(\%(no_\?\)\?chase_dots\>\)\|
192 \ \%(\%(\<no_\?\)\?chaselinks\>\)\|\%(\%(no_\?\)\?chase_links\>\)\|
193 \ \%(\%(\<no_\?\)\?checkjobs\>\)\|\%(\%(no_\?\)\?check_jobs\>\)\|
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200194 \ \%(\%(\<no_\?\)\?checkrunningjobs\>\)\|\%(\%(no_\?\)\?check_running_jobs\>\)\|
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200195 \ \%(\%(\<no_\?\)\?clobber\>\)\|
196 \ \%(\%(\<no_\?\)\?combiningchars\>\)\|\%(\%(no_\?\)\?combining_chars\>\)\|
197 \ \%(\%(\<no_\?\)\?completealiases\>\)\|\%(\%(no_\?\)\?complete_aliases\>\)\|
198 \ \%(\%(\<no_\?\)\?completeinword\>\)\|\%(\%(no_\?\)\?complete_in_word\>\)\|
199 \ \%(\%(\<no_\?\)\?continueonerror\>\)\|\%(\%(no_\?\)\?continue_on_error\>\)\|
200 \ \%(\%(\<no_\?\)\?correct\>\)\|
201 \ \%(\%(\<no_\?\)\?correctall\>\)\|\%(\%(no_\?\)\?correct_all\>\)\|
202 \ \%(\%(\<no_\?\)\?cprecedences\>\)\|\%(\%(no_\?\)\?c_precedences\>\)\|
203 \ \%(\%(\<no_\?\)\?cshjunkiehistory\>\)\|\%(\%(no_\?\)\?csh_junkie_history\>\)\|
204 \ \%(\%(\<no_\?\)\?cshjunkieloops\>\)\|\%(\%(no_\?\)\?csh_junkie_loops\>\)\|
205 \ \%(\%(\<no_\?\)\?cshjunkiequotes\>\)\|\%(\%(no_\?\)\?csh_junkie_quotes\>\)\|
206 \ \%(\%(\<no_\?\)\?csh_nullcmd\>\)\|\%(\%(no_\?\)\?csh_null_cmd\>\)\|\%(\%(no_\?\)\?cshnullcmd\>\)\|\%(\%(no_\?\)\?csh_null_cmd\>\)\|
207 \ \%(\%(\<no_\?\)\?cshnullglob\>\)\|\%(\%(no_\?\)\?csh_null_glob\>\)\|
208 \ \%(\%(\<no_\?\)\?debugbeforecmd\>\)\|\%(\%(no_\?\)\?debug_before_cmd\>\)\|
209 \ \%(\%(\<no_\?\)\?dotglob\>\)\|\%(\%(no_\?\)\?dot_glob\>\)\|
210 \ \%(\%(\<no_\?\)\?dvorak\>\)\|
211 \ \%(\%(\<no_\?\)\?emacs\>\)\|
212 \ \%(\%(\<no_\?\)\?equals\>\)\|
213 \ \%(\%(\<no_\?\)\?errexit\>\)\|\%(\%(no_\?\)\?err_exit\>\)\|
214 \ \%(\%(\<no_\?\)\?errreturn\>\)\|\%(\%(no_\?\)\?err_return\>\)\|
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200215 \ \%(\%(\<no_\?\)\?evallineno\>\)\|\%(\%(no_\?\)\?eval_lineno\>\)\|
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200216 \ \%(\%(\<no_\?\)\?exec\>\)\|
217 \ \%(\%(\<no_\?\)\?extendedglob\>\)\|\%(\%(no_\?\)\?extended_glob\>\)\|
218 \ \%(\%(\<no_\?\)\?extendedhistory\>\)\|\%(\%(no_\?\)\?extended_history\>\)\|
219 \ \%(\%(\<no_\?\)\?flowcontrol\>\)\|\%(\%(no_\?\)\?flow_control\>\)\|
220 \ \%(\%(\<no_\?\)\?forcefloat\>\)\|\%(\%(no_\?\)\?force_float\>\)\|
221 \ \%(\%(\<no_\?\)\?functionargzero\>\)\|\%(\%(no_\?\)\?function_argzero\>\)\|\%(\%(no_\?\)\?function_arg_zero\>\)\|
222 \ \%(\%(\<no_\?\)\?glob\>\)\|
223 \ \%(\%(\<no_\?\)\?globalexport\>\)\|\%(\%(no_\?\)\?global_export\>\)\|
224 \ \%(\%(\<no_\?\)\?globalrcs\>\)\|\%(\%(no_\?\)\?global_rcs\>\)\|
225 \ \%(\%(\<no_\?\)\?globassign\>\)\|\%(\%(no_\?\)\?glob_assign\>\)\|
226 \ \%(\%(\<no_\?\)\?globcomplete\>\)\|\%(\%(no_\?\)\?glob_complete\>\)\|
227 \ \%(\%(\<no_\?\)\?globdots\>\)\|\%(\%(no_\?\)\?glob_dots\>\)\|
228 \ \%(\%(\<no_\?\)\?glob_subst\>\)\|\%(\%(no_\?\)\?globsubst\>\)\|
229 \ \%(\%(\<no_\?\)\?globstarshort\>\)\|\%(\%(no_\?\)\?glob_star_short\>\)\|
230 \ \%(\%(\<no_\?\)\?hashall\>\)\|\%(\%(no_\?\)\?hash_all\>\)\|
231 \ \%(\%(\<no_\?\)\?hashcmds\>\)\|\%(\%(no_\?\)\?hash_cmds\>\)\|
232 \ \%(\%(\<no_\?\)\?hashdirs\>\)\|\%(\%(no_\?\)\?hash_dirs\>\)\|
233 \ \%(\%(\<no_\?\)\?hashexecutablesonly\>\)\|\%(\%(no_\?\)\?hash_executables_only\>\)\|
234 \ \%(\%(\<no_\?\)\?hashlistall\>\)\|\%(\%(no_\?\)\?hash_list_all\>\)\|
235 \ \%(\%(\<no_\?\)\?histallowclobber\>\)\|\%(\%(no_\?\)\?hist_allow_clobber\>\)\|
236 \ \%(\%(\<no_\?\)\?histappend\>\)\|\%(\%(no_\?\)\?hist_append\>\)\|
237 \ \%(\%(\<no_\?\)\?histbeep\>\)\|\%(\%(no_\?\)\?hist_beep\>\)\|
238 \ \%(\%(\<no_\?\)\?hist_expand\>\)\|\%(\%(no_\?\)\?histexpand\>\)\|
239 \ \%(\%(\<no_\?\)\?hist_expire_dups_first\>\)\|\%(\%(no_\?\)\?histexpiredupsfirst\>\)\|
240 \ \%(\%(\<no_\?\)\?histfcntllock\>\)\|\%(\%(no_\?\)\?hist_fcntl_lock\>\)\|
241 \ \%(\%(\<no_\?\)\?histfindnodups\>\)\|\%(\%(no_\?\)\?hist_find_no_dups\>\)\|
242 \ \%(\%(\<no_\?\)\?histignorealldups\>\)\|\%(\%(no_\?\)\?hist_ignore_all_dups\>\)\|
243 \ \%(\%(\<no_\?\)\?histignoredups\>\)\|\%(\%(no_\?\)\?hist_ignore_dups\>\)\|
244 \ \%(\%(\<no_\?\)\?histignorespace\>\)\|\%(\%(no_\?\)\?hist_ignore_space\>\)\|
245 \ \%(\%(\<no_\?\)\?histlexwords\>\)\|\%(\%(no_\?\)\?hist_lex_words\>\)\|
246 \ \%(\%(\<no_\?\)\?histnofunctions\>\)\|\%(\%(no_\?\)\?hist_no_functions\>\)\|
247 \ \%(\%(\<no_\?\)\?histnostore\>\)\|\%(\%(no_\?\)\?hist_no_store\>\)\|
248 \ \%(\%(\<no_\?\)\?histreduceblanks\>\)\|\%(\%(no_\?\)\?hist_reduce_blanks\>\)\|
249 \ \%(\%(\<no_\?\)\?histsavebycopy\>\)\|\%(\%(no_\?\)\?hist_save_by_copy\>\)\|
250 \ \%(\%(\<no_\?\)\?histsavenodups\>\)\|\%(\%(no_\?\)\?hist_save_no_dups\>\)\|
251 \ \%(\%(\<no_\?\)\?histsubstpattern\>\)\|\%(\%(no_\?\)\?hist_subst_pattern\>\)\|
252 \ \%(\%(\<no_\?\)\?histverify\>\)\|\%(\%(no_\?\)\?hist_verify\>\)\|
253 \ \%(\%(\<no_\?\)\?hup\>\)\|
254 \ \%(\%(\<no_\?\)\?ignorebraces\>\)\|\%(\%(no_\?\)\?ignore_braces\>\)\|
255 \ \%(\%(\<no_\?\)\?ignoreclosebraces\>\)\|\%(\%(no_\?\)\?ignore_close_braces\>\)\|
256 \ \%(\%(\<no_\?\)\?ignoreeof\>\)\|\%(\%(no_\?\)\?ignore_eof\>\)\|
257 \ \%(\%(\<no_\?\)\?incappendhistory\>\)\|\%(\%(no_\?\)\?inc_append_history\>\)\|
258 \ \%(\%(\<no_\?\)\?incappendhistorytime\>\)\|\%(\%(no_\?\)\?inc_append_history_time\>\)\|
259 \ \%(\%(\<no_\?\)\?interactive\>\)\|
260 \ \%(\%(\<no_\?\)\?interactivecomments\>\)\|\%(\%(no_\?\)\?interactive_comments\>\)\|
261 \ \%(\%(\<no_\?\)\?ksharrays\>\)\|\%(\%(no_\?\)\?ksh_arrays\>\)\|
262 \ \%(\%(\<no_\?\)\?kshautoload\>\)\|\%(\%(no_\?\)\?ksh_autoload\>\)\|
263 \ \%(\%(\<no_\?\)\?kshglob\>\)\|\%(\%(no_\?\)\?ksh_glob\>\)\|
264 \ \%(\%(\<no_\?\)\?kshoptionprint\>\)\|\%(\%(no_\?\)\?ksh_option_print\>\)\|
265 \ \%(\%(\<no_\?\)\?kshtypeset\>\)\|\%(\%(no_\?\)\?ksh_typeset\>\)\|
266 \ \%(\%(\<no_\?\)\?kshzerosubscript\>\)\|\%(\%(no_\?\)\?ksh_zero_subscript\>\)\|
267 \ \%(\%(\<no_\?\)\?listambiguous\>\)\|\%(\%(no_\?\)\?list_ambiguous\>\)\|
268 \ \%(\%(\<no_\?\)\?listbeep\>\)\|\%(\%(no_\?\)\?list_beep\>\)\|
269 \ \%(\%(\<no_\?\)\?listpacked\>\)\|\%(\%(no_\?\)\?list_packed\>\)\|
270 \ \%(\%(\<no_\?\)\?listrowsfirst\>\)\|\%(\%(no_\?\)\?list_rows_first\>\)\|
271 \ \%(\%(\<no_\?\)\?listtypes\>\)\|\%(\%(no_\?\)\?list_types\>\)\|
272 \ \%(\%(\<no_\?\)\?localloops\>\)\|\%(\%(no_\?\)\?local_loops\>\)\|
273 \ \%(\%(\<no_\?\)\?localoptions\>\)\|\%(\%(no_\?\)\?local_options\>\)\|
274 \ \%(\%(\<no_\?\)\?localpatterns\>\)\|\%(\%(no_\?\)\?local_patterns\>\)\|
275 \ \%(\%(\<no_\?\)\?localtraps\>\)\|\%(\%(no_\?\)\?local_traps\>\)\|
276 \ \%(\%(\<no_\?\)\?log\>\)\|
277 \ \%(\%(\<no_\?\)\?login\>\)\|
278 \ \%(\%(\<no_\?\)\?longlistjobs\>\)\|\%(\%(no_\?\)\?long_list_jobs\>\)\|
279 \ \%(\%(\<no_\?\)\?magicequalsubst\>\)\|\%(\%(no_\?\)\?magic_equal_subst\>\)\|
280 \ \%(\%(\<no_\?\)\?mark_dirs\>\)\|
281 \ \%(\%(\<no_\?\)\?mailwarn\>\)\|\%(\%(no_\?\)\?mail_warn\>\)\|
282 \ \%(\%(\<no_\?\)\?mailwarning\>\)\|\%(\%(no_\?\)\?mail_warning\>\)\|
283 \ \%(\%(\<no_\?\)\?markdirs\>\)\|
284 \ \%(\%(\<no_\?\)\?menucomplete\>\)\|\%(\%(no_\?\)\?menu_complete\>\)\|
285 \ \%(\%(\<no_\?\)\?monitor\>\)\|
286 \ \%(\%(\<no_\?\)\?multibyte\>\)\|\%(\%(no_\?\)\?multi_byte\>\)\|
287 \ \%(\%(\<no_\?\)\?multifuncdef\>\)\|\%(\%(no_\?\)\?multi_func_def\>\)\|
288 \ \%(\%(\<no_\?\)\?multios\>\)\|\%(\%(no_\?\)\?multi_os\>\)\|
289 \ \%(\%(\<no_\?\)\?nomatch\>\)\|\%(\%(no_\?\)\?no_match\>\)\|
290 \ \%(\%(\<no_\?\)\?notify\>\)\|
291 \ \%(\%(\<no_\?\)\?nullglob\>\)\|\%(\%(no_\?\)\?null_glob\>\)\|
292 \ \%(\%(\<no_\?\)\?numericglobsort\>\)\|\%(\%(no_\?\)\?numeric_glob_sort\>\)\|
293 \ \%(\%(\<no_\?\)\?octalzeroes\>\)\|\%(\%(no_\?\)\?octal_zeroes\>\)\|
294 \ \%(\%(\<no_\?\)\?onecmd\>\)\|\%(\%(no_\?\)\?one_cmd\>\)\|
295 \ \%(\%(\<no_\?\)\?overstrike\>\)\|\%(\%(no_\?\)\?over_strike\>\)\|
296 \ \%(\%(\<no_\?\)\?pathdirs\>\)\|\%(\%(no_\?\)\?path_dirs\>\)\|
297 \ \%(\%(\<no_\?\)\?pathscript\>\)\|\%(\%(no_\?\)\?path_script\>\)\|
298 \ \%(\%(\<no_\?\)\?physical\>\)\|
299 \ \%(\%(\<no_\?\)\?pipefail\>\)\|\%(\%(no_\?\)\?pipe_fail\>\)\|
300 \ \%(\%(\<no_\?\)\?posixaliases\>\)\|\%(\%(no_\?\)\?posix_aliases\>\)\|
301 \ \%(\%(\<no_\?\)\?posixargzero\>\)\|\%(\%(no_\?\)\?posix_arg_zero\>\)\|\%(\%(no_\?\)\?posix_argzero\>\)\|
302 \ \%(\%(\<no_\?\)\?posixbuiltins\>\)\|\%(\%(no_\?\)\?posix_builtins\>\)\|
303 \ \%(\%(\<no_\?\)\?posixcd\>\)\|\%(\%(no_\?\)\?posix_cd\>\)\|
304 \ \%(\%(\<no_\?\)\?posixidentifiers\>\)\|\%(\%(no_\?\)\?posix_identifiers\>\)\|
305 \ \%(\%(\<no_\?\)\?posixjobs\>\)\|\%(\%(no_\?\)\?posix_jobs\>\)\|
306 \ \%(\%(\<no_\?\)\?posixstrings\>\)\|\%(\%(no_\?\)\?posix_strings\>\)\|
307 \ \%(\%(\<no_\?\)\?posixtraps\>\)\|\%(\%(no_\?\)\?posix_traps\>\)\|
308 \ \%(\%(\<no_\?\)\?printeightbit\>\)\|\%(\%(no_\?\)\?print_eight_bit\>\)\|
309 \ \%(\%(\<no_\?\)\?printexitvalue\>\)\|\%(\%(no_\?\)\?print_exit_value\>\)\|
310 \ \%(\%(\<no_\?\)\?privileged\>\)\|
311 \ \%(\%(\<no_\?\)\?promptbang\>\)\|\%(\%(no_\?\)\?prompt_bang\>\)\|
312 \ \%(\%(\<no_\?\)\?promptcr\>\)\|\%(\%(no_\?\)\?prompt_cr\>\)\|
313 \ \%(\%(\<no_\?\)\?promptpercent\>\)\|\%(\%(no_\?\)\?prompt_percent\>\)\|
314 \ \%(\%(\<no_\?\)\?promptsp\>\)\|\%(\%(no_\?\)\?prompt_sp\>\)\|
315 \ \%(\%(\<no_\?\)\?promptsubst\>\)\|\%(\%(no_\?\)\?prompt_subst\>\)\|
316 \ \%(\%(\<no_\?\)\?promptvars\>\)\|\%(\%(no_\?\)\?prompt_vars\>\)\|
317 \ \%(\%(\<no_\?\)\?pushdignoredups\>\)\|\%(\%(no_\?\)\?pushd_ignore_dups\>\)\|
318 \ \%(\%(\<no_\?\)\?pushdminus\>\)\|\%(\%(no_\?\)\?pushd_minus\>\)\|
319 \ \%(\%(\<no_\?\)\?pushdsilent\>\)\|\%(\%(no_\?\)\?pushd_silent\>\)\|
320 \ \%(\%(\<no_\?\)\?pushdtohome\>\)\|\%(\%(no_\?\)\?pushd_to_home\>\)\|
321 \ \%(\%(\<no_\?\)\?rcexpandparam\>\)\|\%(\%(no_\?\)\?rc_expandparam\>\)\|\%(\%(no_\?\)\?rc_expand_param\>\)\|
322 \ \%(\%(\<no_\?\)\?rcquotes\>\)\|\%(\%(no_\?\)\?rc_quotes\>\)\|
323 \ \%(\%(\<no_\?\)\?rcs\>\)\|
324 \ \%(\%(\<no_\?\)\?recexact\>\)\|\%(\%(no_\?\)\?rec_exact\>\)\|
325 \ \%(\%(\<no_\?\)\?rematchpcre\>\)\|\%(\%(no_\?\)\?re_match_pcre\>\)\|\%(\%(no_\?\)\?rematch_pcre\>\)\|
326 \ \%(\%(\<no_\?\)\?restricted\>\)\|
327 \ \%(\%(\<no_\?\)\?rmstarsilent\>\)\|\%(\%(no_\?\)\?rm_star_silent\>\)\|
328 \ \%(\%(\<no_\?\)\?rmstarwait\>\)\|\%(\%(no_\?\)\?rm_star_wait\>\)\|
329 \ \%(\%(\<no_\?\)\?sharehistory\>\)\|\%(\%(no_\?\)\?share_history\>\)\|
330 \ \%(\%(\<no_\?\)\?shfileexpansion\>\)\|\%(\%(no_\?\)\?sh_file_expansion\>\)\|
331 \ \%(\%(\<no_\?\)\?shglob\>\)\|\%(\%(no_\?\)\?sh_glob\>\)\|
332 \ \%(\%(\<no_\?\)\?shinstdin\>\)\|\%(\%(no_\?\)\?shin_stdin\>\)\|
333 \ \%(\%(\<no_\?\)\?shnullcmd\>\)\|\%(\%(no_\?\)\?sh_nullcmd\>\)\|
334 \ \%(\%(\<no_\?\)\?shoptionletters\>\)\|\%(\%(no_\?\)\?sh_option_letters\>\)\|
335 \ \%(\%(\<no_\?\)\?shortloops\>\)\|\%(\%(no_\?\)\?short_loops\>\)\|
336 \ \%(\%(\<no_\?\)\?shwordsplit\>\)\|\%(\%(no_\?\)\?sh_word_split\>\)\|
337 \ \%(\%(\<no_\?\)\?singlecommand\>\)\|\%(\%(no_\?\)\?single_command\>\)\|
338 \ \%(\%(\<no_\?\)\?singlelinezle\>\)\|\%(\%(no_\?\)\?single_line_zle\>\)\|
339 \ \%(\%(\<no_\?\)\?sourcetrace\>\)\|\%(\%(no_\?\)\?source_trace\>\)\|
340 \ \%(\%(\<no_\?\)\?stdin\>\)\|
341 \ \%(\%(\<no_\?\)\?sunkeyboardhack\>\)\|\%(\%(no_\?\)\?sun_keyboard_hack\>\)\|
342 \ \%(\%(\<no_\?\)\?trackall\>\)\|\%(\%(no_\?\)\?track_all\>\)\|
343 \ \%(\%(\<no_\?\)\?transientrprompt\>\)\|\%(\%(no_\?\)\?transient_rprompt\>\)\|
344 \ \%(\%(\<no_\?\)\?trapsasync\>\)\|\%(\%(no_\?\)\?traps_async\>\)\|
345 \ \%(\%(\<no_\?\)\?typesetsilent\>\)\|\%(\%(no_\?\)\?type_set_silent\>\)\|\%(\%(no_\?\)\?typeset_silent\>\)\|
346 \ \%(\%(\<no_\?\)\?unset\>\)\|
347 \ \%(\%(\<no_\?\)\?verbose\>\)\|
348 \ \%(\%(\<no_\?\)\?vi\>\)\|
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200349 \ \%(\%(\<no_\?\)\?warnnestedvar\>\)\|\%(\%(no_\?\)\?warn_nested_var\>\)\|
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200350 \ \%(\%(\<no_\?\)\?warncreateglobal\>\)\|\%(\%(no_\?\)\?warn_create_global\>\)\|
351 \ \%(\%(\<no_\?\)\?xtrace\>\)\|
Bram Moolenaar2f058492017-11-30 20:27:52 +0100352 \ \%(\%(\<no_\?\)\?zle\>\)/ nextgroup=zshOption,zshComment skipwhite contained
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200353
Bram Moolenaar2f058492017-11-30 20:27:52 +0100354syn keyword zshTypes float integer local typeset declare private readonly
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000355
356" XXX: this may be too much
357" syn match zshSwitches '\s\zs--\=[a-zA-Z0-9-]\+'
358
359syn match zshNumber '[+-]\=\<\d\+\>'
360syn match zshNumber '[+-]\=\<0x\x\+\>'
361syn match zshNumber '[+-]\=\<0\o\+\>'
362syn match zshNumber '[+-]\=\d\+#[-+]\=\w\+\>'
363syn match zshNumber '[+-]\=\d\+\.\d\+\>'
364
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000365" TODO: $[...] is the same as $((...)), so add that as well.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000366syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100367exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold'
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100368syn region zshParentheses transparent start='(' skip='\\)' end=')' fold
Bram Moolenaar94237492017-04-23 18:40:21 +0200369syn region zshGlob start='(#' end=')'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000370syn region zshMathSubst matchgroup=zshSubstDelim transparent
Bram Moolenaar94237492017-04-23 18:40:21 +0200371 \ start='\$((' skip='\\)' end='))'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000372 \ contains=zshParentheses,@zshSubst,zshNumber,
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100373 \ @zshDerefs,zshString keepend fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100374" The ms=s+1 prevents matching zshBrackets several times on opening brackets
375" (see https://github.com/chrisbra/vim-zsh/issues/21#issuecomment-576330348)
376syn region zshBrackets contained transparent start='{'ms=s+1 skip='\\}'
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100377 \ end='}' fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100378exe 'syn region zshBrackets transparent start=/{/ms=s+1 skip=/\\}/ end=/}/ contains='.s:contained. ' fold'
379
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000380syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100381 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100382exe 'syn region zshOldSubst matchgroup=zshSubstDelim start=/`/ skip=/\\[\\`]/ end=/`/ contains='.s:contained. ',zshOldSubst fold'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000383
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200384syn sync minlines=50 maxlines=90
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000385syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
386syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>'
387
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000388hi def link zshTodo Todo
389hi def link zshComment Comment
390hi def link zshPreProc PreProc
391hi def link zshQuoted SpecialChar
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100392hi def link zshPOSIXQuoted SpecialChar
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000393hi def link zshString String
394hi def link zshStringDelimiter zshString
395hi def link zshPOSIXString zshString
396hi def link zshJobSpec Special
397hi def link zshPrecommand Special
398hi def link zshDelimiter Keyword
399hi def link zshConditional Conditional
400hi def link zshException Exception
401hi def link zshRepeat Repeat
402hi def link zshKeyword Keyword
403hi def link zshFunction None
404hi def link zshKSHFunction zshFunction
405hi def link zshHereDoc String
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200406hi def link zshOperator None
407hi def link zshRedir Operator
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000408hi def link zshVariable None
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000409hi def link zshVariableDef zshVariable
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000410hi def link zshDereferencing PreProc
Bram Moolenaar94237492017-04-23 18:40:21 +0200411hi def link zshShortDeref zshDereferencing
412hi def link zshLongDeref zshDereferencing
413hi def link zshDeref zshDereferencing
414hi def link zshDollarVar zshDereferencing
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000415hi def link zshCommands Keyword
Bram Moolenaar94237492017-04-23 18:40:21 +0200416hi def link zshOptStart Keyword
417hi def link zshOption Constant
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000418hi def link zshTypes Type
419hi def link zshSwitches Special
420hi def link zshNumber Number
421hi def link zshSubst PreProc
422hi def link zshMathSubst zshSubst
423hi def link zshOldSubst zshSubst
424hi def link zshSubstDelim zshSubst
Bram Moolenaar94237492017-04-23 18:40:21 +0200425hi def link zshGlob zshSubst
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000426
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427let b:current_syntax = "zsh"
428
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000429let &cpo = s:cpo_save
430unlet s:cpo_save