blob: 084f8cdb41d47e6e2cc62045f52d3099b16478a5 [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 Moolenaar71b6d332022-09-10 13:13:14 +01005" Latest Revision: 2022-07-26
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()
Bram Moolenaar23515b42020-11-29 14:36:24 +010017 " needs 7.4.2008 for execute() function
Bram Moolenaarb17893a2020-03-14 08:19:51 +010018 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
Bram Moolenaar71b6d332022-09-10 13:13:14 +010022 for cluster in ['markdownHighlight_zsh', 'zsh']
Bram Moolenaarb17893a2020-03-14 08:19:51 +010023 try
Bram Moolenaar71b6d332022-09-10 13:13:14 +010024 " markdown syntax defines embedded clusters as @markdownhighlight_<lang>,
Bram Moolenaarb17893a2020-03-14 08:19:51 +010025 " 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 Moolenaarfa3b7232021-12-24 13:18:38 +000044syn match zshQuoted '\\.'
Bram Moolenaarb17893a2020-03-14 08:19:51 +010045syn match zshPOSIXQuoted '\\[xX][0-9a-fA-F]\{1,2}'
46syn match zshPOSIXQuoted '\\[0-7]\{1,3}'
47syn match zshPOSIXQuoted '\\u[0-9a-fA-F]\{1,4}'
48syn match zshPOSIXQuoted '\\U[1-9a-fA-F]\{1,8}'
Bram Moolenaarfa3b7232021-12-24 13:18:38 +000049
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000050syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+
Bram Moolenaar71b6d332022-09-10 13:13:14 +010051 \ contains=zshQuoted,@zshDerefs,@zshSubstQuoted fold
Bram Moolenaarf3913272016-02-25 00:00:01 +010052syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000053syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+
Bram Moolenaarb17893a2020-03-14 08:19:51 +010054 \ skip=+\\[\\']+ end=+'+ contains=zshPOSIXQuoted,zshQuoted
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000055syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)'
Bram Moolenaar071d4272004-06-13 20:20:40 +000056
Bram Moolenaar71b6d332022-09-10 13:13:14 +010057syn match zshNumber '[+-]\=\<\d\+\>'
58syn match zshNumber '[+-]\=\<0x\x\+\>'
59syn match zshNumber '[+-]\=\<0\o\+\>'
60syn match zshNumber '[+-]\=\d\+#[-+]\=\w\+\>'
61syn match zshNumber '[+-]\=\d\+\.\d\+\>'
62
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000063syn keyword zshPrecommand noglob nocorrect exec command builtin - time
Bram Moolenaar071d4272004-06-13 20:20:40 +000064
Bram Moolenaarf2571c62015-06-09 19:44:55 +020065syn keyword zshDelimiter do done end
Bram Moolenaar071d4272004-06-13 20:20:40 +000066
Bram Moolenaar71b6d332022-09-10 13:13:14 +010067syn keyword zshConditional if then elif else fi esac select
68
69syn keyword zshCase case nextgroup=zshCaseWord skipwhite
70syn match zshCaseWord /\S\+/ nextgroup=zshCaseIn skipwhite contained transparent
71syn keyword zshCaseIn in nextgroup=zshCasePattern skipwhite skipnl contained
72syn match zshCasePattern /\S[^)]*)/ contained
Bram Moolenaar071d4272004-06-13 20:20:40 +000073
Bram Moolenaare37d50a2008-08-06 17:06:04 +000074syn keyword zshRepeat while until repeat
75
76syn keyword zshRepeat for foreach nextgroup=zshVariable skipwhite
Bram Moolenaar071d4272004-06-13 20:20:40 +000077
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000078syn keyword zshException always
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000080syn keyword zshKeyword function nextgroup=zshKSHFunction skipwhite
Bram Moolenaar071d4272004-06-13 20:20:40 +000081
Bram Moolenaarf3913272016-02-25 00:00:01 +010082syn match zshKSHFunction contained '\w\S\+'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000083syn match zshFunction '^\s*\k\+\ze\s*()'
84
85syn match zshOperator '||\|&&\|;\|&!\='
86
Bram Moolenaar71b6d332022-09-10 13:13:14 +010087 " <<<, <, <>, and variants.
88syn match zshRedir '\d\=\(<<<\|<&\s*[0-9p-]\=\|<>\?\)'
89 " >, >>, and variants.
90syn match zshRedir '\d\=\(>&\s*[0-9p-]\=\|&>>\?\|>>\?&\?\)[|!]\='
Viktor Szépedbf749b2023-10-16 09:53:37 +020091 " | and |&, but only if it's not preceded or
Bram Moolenaar71b6d332022-09-10 13:13:14 +010092 " followed by a | to avoid matching ||.
93syn match zshRedir '|\@1<!|&\=|\@!'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000094
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000095syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaare37d50a2008-08-06 17:06:04 +000096 \ start='<\@<!<<\s*\z([^<]\S*\)'
97 \ end='^\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +020098 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000099syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000100 \ start='<\@<!<<\s*\\\z(\S\+\)'
101 \ end='^\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +0200102 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000103syn region zshHereDoc matchgroup=zshRedir
104 \ start='<\@<!<<-\s*\\\=\z(\S\+\)'
105 \ end='^\s*\z1\>'
Bram Moolenaar7db25fe2018-05-13 00:02:36 +0200106 \ contains=@zshSubst,@zshDerefs,zshQuoted,zshPOSIXString
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000107syn region zshHereDoc matchgroup=zshRedir
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200108 \ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000109 \ end='^\z1\>'
110syn region zshHereDoc matchgroup=zshRedir
111 \ start=+<\@<!<<-\s*\(["']\)\z(\S\+\)\1+
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000112 \ end='^\s*\z1\>'
113
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000114syn match zshVariable '\<\h\w*' contained
115
116syn match zshVariableDef '\<\h\w*\ze+\=='
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000117" XXX: how safe is this?
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000118syn region zshVariableDef oneline
Bram Moolenaar94237492017-04-23 18:40:21 +0200119 \ start='\$\@<!\<\h\w*\[' end='\]\ze+\?=\?'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000120 \ contains=@zshSubst
121
Bram Moolenaar94237492017-04-23 18:40:21 +0200122syn cluster zshDerefs contains=zshShortDeref,zshLongDeref,zshDeref,zshDollarVar
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000123
Bram Moolenaar94237492017-04-23 18:40:21 +0200124syn match zshShortDeref '\$[!#$*@?_-]\w\@!'
125syn match zshShortDeref '\$[=^~]*[#+]*\d\+\>'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126
Bram Moolenaar94237492017-04-23 18:40:21 +0200127syn match zshLongDeref '\$\%(ARGC\|argv\|status\|pipestatus\|CPUTYPE\|EGID\|EUID\|ERRNO\|GID\|HOST\|LINENO\|LOGNAME\)'
128syn match zshLongDeref '\$\%(MACHTYPE\|OLDPWD OPTARG\|OPTIND\|OSTYPE\|PPID\|PWD\|RANDOM\|SECONDS\|SHLVL\|signals\)'
129syn match zshLongDeref '\$\%(TRY_BLOCK_ERROR\|TTY\|TTYIDLE\|UID\|USERNAME\|VENDOR\|ZSH_NAME\|ZSH_VERSION\|REPLY\|reply\|TERM\)'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000130
Bram Moolenaar94237492017-04-23 18:40:21 +0200131syn match zshDollarVar '\$\h\w*'
132syn match zshDeref '\$[=^~]*[#+]*\h\w*\>'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000133
134syn match zshCommands '\%(^\|\s\)[.:]\ze\s'
135syn keyword zshCommands alias autoload bg bindkey break bye cap cd
136 \ chdir clone comparguments compcall compctl
137 \ compdescribe compfiles compgroups compquote
138 \ comptags comptry compvalues continue dirs
139 \ disable disown echo echotc echoti emulate
140 \ enable eval exec exit export false fc fg
141 \ functions getcap getln getopts hash history
142 \ jobs kill let limit log logout popd print
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100143 \ printf prompt pushd pushln pwd r read
Bram Moolenaar94237492017-04-23 18:40:21 +0200144 \ rehash return sched set setcap shift
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000145 \ source stat suspend test times trap true
146 \ ttyctl type ulimit umask unalias unfunction
Bram Moolenaar94237492017-04-23 18:40:21 +0200147 \ unhash unlimit unset vared wait
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000148 \ whence where which zcompile zformat zftp zle
Bram Moolenaar7db25fe2018-05-13 00:02:36 +0200149 \ zmodload zparseopts zprof zpty zrecompile
150 \ zregexparse zsocket zstyle ztcp
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000151
Bram Moolenaarfa3b7232021-12-24 13:18:38 +0000152" Options, generated by from the zsh source with the make-options.zsh script.
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200153syn case ignore
Bram Moolenaarfa3b7232021-12-24 13:18:38 +0000154syn match zshOptStart
155 \ /\v^\s*%(%(un)?setopt|set\s+[-+]o)/
156 \ nextgroup=zshOption skipwhite
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100157syn keyword zshOption nextgroup=zshOption,zshComment skipwhite contained
158 \ auto_cd no_auto_cd autocd noautocd auto_pushd no_auto_pushd autopushd noautopushd cdable_vars
159 \ no_cdable_vars cdablevars nocdablevars cd_silent no_cd_silent cdsilent nocdsilent chase_dots
160 \ no_chase_dots chasedots nochasedots chase_links no_chase_links chaselinks nochaselinks posix_cd
161 \ posixcd no_posix_cd noposixcd pushd_ignore_dups no_pushd_ignore_dups pushdignoredups
162 \ nopushdignoredups pushd_minus no_pushd_minus pushdminus nopushdminus pushd_silent no_pushd_silent
163 \ pushdsilent nopushdsilent pushd_to_home no_pushd_to_home pushdtohome nopushdtohome
164 \ always_last_prompt no_always_last_prompt alwayslastprompt noalwayslastprompt always_to_end
165 \ no_always_to_end alwaystoend noalwaystoend auto_list no_auto_list autolist noautolist auto_menu
166 \ no_auto_menu automenu noautomenu auto_name_dirs no_auto_name_dirs autonamedirs noautonamedirs
167 \ auto_param_keys no_auto_param_keys autoparamkeys noautoparamkeys auto_param_slash
168 \ no_auto_param_slash autoparamslash noautoparamslash auto_remove_slash no_auto_remove_slash
169 \ autoremoveslash noautoremoveslash bash_auto_list no_bash_auto_list bashautolist nobashautolist
170 \ complete_aliases no_complete_aliases completealiases nocompletealiases complete_in_word
171 \ no_complete_in_word completeinword nocompleteinword glob_complete no_glob_complete globcomplete
172 \ noglobcomplete hash_list_all no_hash_list_all hashlistall nohashlistall list_ambiguous
173 \ no_list_ambiguous listambiguous nolistambiguous list_beep no_list_beep listbeep nolistbeep
174 \ list_packed no_list_packed listpacked nolistpacked list_rows_first no_list_rows_first listrowsfirst
175 \ nolistrowsfirst list_types no_list_types listtypes nolisttypes menu_complete no_menu_complete
176 \ menucomplete nomenucomplete rec_exact no_rec_exact recexact norecexact bad_pattern no_bad_pattern
177 \ badpattern nobadpattern bare_glob_qual no_bare_glob_qual bareglobqual nobareglobqual brace_ccl
178 \ no_brace_ccl braceccl nobraceccl case_glob no_case_glob caseglob nocaseglob case_match
179 \ no_case_match casematch nocasematch case_paths no_case_paths casepaths nocasepaths csh_null_glob
180 \ no_csh_null_glob cshnullglob nocshnullglob equals no_equals noequals extended_glob no_extended_glob
181 \ extendedglob noextendedglob force_float no_force_float forcefloat noforcefloat glob no_glob noglob
182 \ glob_assign no_glob_assign globassign noglobassign glob_dots no_glob_dots globdots noglobdots
183 \ glob_star_short no_glob_star_short globstarshort noglobstarshort glob_subst no_glob_subst globsubst
184 \ noglobsubst hist_subst_pattern no_hist_subst_pattern histsubstpattern nohistsubstpattern
185 \ ignore_braces no_ignore_braces ignorebraces noignorebraces ignore_close_braces
186 \ no_ignore_close_braces ignoreclosebraces noignoreclosebraces ksh_glob no_ksh_glob kshglob nokshglob
187 \ magic_equal_subst no_magic_equal_subst magicequalsubst nomagicequalsubst mark_dirs no_mark_dirs
188 \ markdirs nomarkdirs multibyte no_multibyte nomultibyte nomatch no_nomatch nonomatch null_glob
189 \ no_null_glob nullglob nonullglob numeric_glob_sort no_numeric_glob_sort numericglobsort
190 \ nonumericglobsort rc_expand_param no_rc_expand_param rcexpandparam norcexpandparam rematch_pcre
191 \ no_rematch_pcre rematchpcre norematchpcre sh_glob no_sh_glob shglob noshglob unset no_unset nounset
192 \ warn_create_global no_warn_create_global warncreateglobal nowarncreateglobal warn_nested_var
193 \ no_warn_nested_var warnnestedvar no_warnnestedvar append_history no_append_history appendhistory
194 \ noappendhistory bang_hist no_bang_hist banghist nobanghist extended_history no_extended_history
195 \ extendedhistory noextendedhistory hist_allow_clobber no_hist_allow_clobber histallowclobber
196 \ nohistallowclobber hist_beep no_hist_beep histbeep nohistbeep hist_expire_dups_first
197 \ no_hist_expire_dups_first histexpiredupsfirst nohistexpiredupsfirst hist_fcntl_lock
198 \ no_hist_fcntl_lock histfcntllock nohistfcntllock hist_find_no_dups no_hist_find_no_dups
199 \ histfindnodups nohistfindnodups hist_ignore_all_dups no_hist_ignore_all_dups histignorealldups
200 \ nohistignorealldups hist_ignore_dups no_hist_ignore_dups histignoredups nohistignoredups
201 \ hist_ignore_space no_hist_ignore_space histignorespace nohistignorespace hist_lex_words
202 \ no_hist_lex_words histlexwords nohistlexwords hist_no_functions no_hist_no_functions
203 \ histnofunctions nohistnofunctions hist_no_store no_hist_no_store histnostore nohistnostore
204 \ hist_reduce_blanks no_hist_reduce_blanks histreduceblanks nohistreduceblanks hist_save_by_copy
205 \ no_hist_save_by_copy histsavebycopy nohistsavebycopy hist_save_no_dups no_hist_save_no_dups
206 \ histsavenodups nohistsavenodups hist_verify no_hist_verify histverify nohistverify
207 \ inc_append_history no_inc_append_history incappendhistory noincappendhistory
208 \ inc_append_history_time no_inc_append_history_time incappendhistorytime noincappendhistorytime
209 \ share_history no_share_history sharehistory nosharehistory all_export no_all_export allexport
210 \ noallexport global_export no_global_export globalexport noglobalexport global_rcs no_global_rcs
211 \ globalrcs noglobalrcs rcs no_rcs norcs aliases no_aliases noaliases clobber no_clobber noclobber
212 \ clobber_empty no_clobber_empty clobberempty noclobberempty correct no_correct nocorrect correct_all
213 \ no_correct_all correctall nocorrectall dvorak no_dvorak nodvorak flow_control no_flow_control
214 \ flowcontrol noflowcontrol ignore_eof no_ignore_eof ignoreeof noignoreeof interactive_comments
215 \ no_interactive_comments interactivecomments nointeractivecomments hash_cmds no_hash_cmds hashcmds
216 \ nohashcmds hash_dirs no_hash_dirs hashdirs nohashdirs hash_executables_only
217 \ no_hash_executables_only hashexecutablesonly nohashexecutablesonly mail_warning no_mail_warning
218 \ mailwarning nomailwarning path_dirs no_path_dirs pathdirs nopathdirs path_script no_path_script
219 \ pathscript nopathscript print_eight_bit no_print_eight_bit printeightbit noprinteightbit
220 \ print_exit_value no_print_exit_value printexitvalue noprintexitvalue rc_quotes no_rc_quotes
221 \ rcquotes norcquotes rm_star_silent no_rm_star_silent rmstarsilent normstarsilent rm_star_wait
222 \ no_rm_star_wait rmstarwait normstarwait short_loops no_short_loops shortloops noshortloops
223 \ short_repeat no_short_repeat shortrepeat noshortrepeat sun_keyboard_hack no_sun_keyboard_hack
224 \ sunkeyboardhack nosunkeyboardhack auto_continue no_auto_continue autocontinue noautocontinue
225 \ auto_resume no_auto_resume autoresume noautoresume bg_nice no_bg_nice bgnice nobgnice check_jobs
226 \ no_check_jobs checkjobs nocheckjobs check_running_jobs no_check_running_jobs checkrunningjobs
227 \ nocheckrunningjobs hup no_hup nohup long_list_jobs no_long_list_jobs longlistjobs nolonglistjobs
228 \ monitor no_monitor nomonitor notify no_notify nonotify posix_jobs posixjobs no_posix_jobs
229 \ noposixjobs prompt_bang no_prompt_bang promptbang nopromptbang prompt_cr no_prompt_cr promptcr
230 \ nopromptcr prompt_sp no_prompt_sp promptsp nopromptsp prompt_percent no_prompt_percent
231 \ promptpercent nopromptpercent prompt_subst no_prompt_subst promptsubst nopromptsubst
232 \ transient_rprompt no_transient_rprompt transientrprompt notransientrprompt alias_func_def
233 \ no_alias_func_def aliasfuncdef noaliasfuncdef c_bases no_c_bases cbases nocbases c_precedences
234 \ no_c_precedences cprecedences nocprecedences debug_before_cmd no_debug_before_cmd debugbeforecmd
235 \ nodebugbeforecmd err_exit no_err_exit errexit noerrexit err_return no_err_return errreturn
236 \ noerrreturn eval_lineno no_eval_lineno evallineno noevallineno exec no_exec noexec function_argzero
237 \ no_function_argzero functionargzero nofunctionargzero local_loops no_local_loops localloops
238 \ nolocalloops local_options no_local_options localoptions nolocaloptions local_patterns
239 \ no_local_patterns localpatterns nolocalpatterns local_traps no_local_traps localtraps nolocaltraps
240 \ multi_func_def no_multi_func_def multifuncdef nomultifuncdef multios no_multios nomultios
241 \ octal_zeroes no_octal_zeroes octalzeroes nooctalzeroes pipe_fail no_pipe_fail pipefail nopipefail
242 \ source_trace no_source_trace sourcetrace nosourcetrace typeset_silent no_typeset_silent
243 \ typesetsilent notypesetsilent typeset_to_unset no_typeset_to_unset typesettounset notypesettounset
244 \ verbose no_verbose noverbose xtrace no_xtrace noxtrace append_create no_append_create appendcreate
245 \ noappendcreate bash_rematch no_bash_rematch bashrematch nobashrematch bsd_echo no_bsd_echo bsdecho
246 \ nobsdecho continue_on_error no_continue_on_error continueonerror nocontinueonerror
247 \ csh_junkie_history no_csh_junkie_history cshjunkiehistory nocshjunkiehistory csh_junkie_loops
248 \ no_csh_junkie_loops cshjunkieloops nocshjunkieloops csh_junkie_quotes no_csh_junkie_quotes
249 \ cshjunkiequotes nocshjunkiequotes csh_nullcmd no_csh_nullcmd cshnullcmd nocshnullcmd ksh_arrays
250 \ no_ksh_arrays ksharrays noksharrays ksh_autoload no_ksh_autoload kshautoload nokshautoload
251 \ ksh_option_print no_ksh_option_print kshoptionprint nokshoptionprint ksh_typeset no_ksh_typeset
252 \ kshtypeset nokshtypeset ksh_zero_subscript no_ksh_zero_subscript kshzerosubscript
253 \ nokshzerosubscript posix_aliases no_posix_aliases posixaliases noposixaliases posix_argzero
254 \ no_posix_argzero posixargzero noposixargzero posix_builtins no_posix_builtins posixbuiltins
255 \ noposixbuiltins posix_identifiers no_posix_identifiers posixidentifiers noposixidentifiers
256 \ posix_strings no_posix_strings posixstrings noposixstrings posix_traps no_posix_traps posixtraps
257 \ noposixtraps sh_file_expansion no_sh_file_expansion shfileexpansion noshfileexpansion sh_nullcmd
258 \ no_sh_nullcmd shnullcmd noshnullcmd sh_option_letters no_sh_option_letters shoptionletters
259 \ noshoptionletters sh_word_split no_sh_word_split shwordsplit noshwordsplit traps_async
260 \ no_traps_async trapsasync notrapsasync interactive no_interactive nointeractive login no_login
261 \ nologin privileged no_privileged noprivileged restricted no_restricted norestricted shin_stdin
262 \ no_shin_stdin shinstdin noshinstdin single_command no_single_command singlecommand nosinglecommand
263 \ beep no_beep nobeep combining_chars no_combining_chars combiningchars nocombiningchars emacs
264 \ no_emacs noemacs overstrike no_overstrike nooverstrike single_line_zle no_single_line_zle
265 \ singlelinezle nosinglelinezle vi no_vi novi zle no_zle nozle brace_expand no_brace_expand
266 \ braceexpand nobraceexpand dot_glob no_dot_glob dotglob nodotglob hash_all no_hash_all hashall
267 \ nohashall hist_append no_hist_append histappend nohistappend hist_expand no_hist_expand histexpand
268 \ nohistexpand log no_log nolog mail_warn no_mail_warn mailwarn nomailwarn one_cmd no_one_cmd onecmd
269 \ noonecmd physical no_physical nophysical prompt_vars no_prompt_vars promptvars nopromptvars stdin
270 \ no_stdin nostdin track_all no_track_all trackall notrackall
Bram Moolenaar23515b42020-11-29 14:36:24 +0100271syn case match
272
Bram Moolenaar2f058492017-11-30 20:27:52 +0100273syn keyword zshTypes float integer local typeset declare private readonly
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000274
275" XXX: this may be too much
276" syn match zshSwitches '\s\zs--\=[a-zA-Z0-9-]\+'
277
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000278" TODO: $[...] is the same as $((...)), so add that as well.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000279syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100280syn cluster zshSubstQuoted contains=zshSubstQuoted,zshOldSubst,zshMathSubst
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100281exe 'syn region zshSubst matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold'
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100282exe 'syn region zshSubstQuoted matchgroup=zshSubstDelim transparent start=/\$(/ skip=/\\)/ end=/)/ contains='.s:contained. ' fold'
283syn region zshSubstQuoted matchgroup=zshSubstDelim start='\${' skip='\\}' end='}' contains=@zshSubst,zshBrackets,zshQuoted fold
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100284syn region zshParentheses transparent start='(' skip='\\)' end=')' fold
Bram Moolenaar94237492017-04-23 18:40:21 +0200285syn region zshGlob start='(#' end=')'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000286syn region zshMathSubst matchgroup=zshSubstDelim transparent
Bram Moolenaar23515b42020-11-29 14:36:24 +0100287 \ start='\%(\$\?\)[<=>]\@<!((' skip='\\)' end='))'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000288 \ contains=zshParentheses,@zshSubst,zshNumber,
Bram Moolenaarfa3b7232021-12-24 13:18:38 +0000289 \ @zshDerefs,zshString fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100290" The ms=s+1 prevents matching zshBrackets several times on opening brackets
291" (see https://github.com/chrisbra/vim-zsh/issues/21#issuecomment-576330348)
292syn region zshBrackets contained transparent start='{'ms=s+1 skip='\\}'
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100293 \ end='}' fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100294exe 'syn region zshBrackets transparent start=/{/ms=s+1 skip=/\\}/ end=/}/ contains='.s:contained. ' fold'
295
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000296syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
Bram Moolenaar681baaf2016-02-04 20:57:07 +0100297 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100298exe 'syn region zshOldSubst matchgroup=zshSubstDelim start=/`/ skip=/\\[\\`]/ end=/`/ contains='.s:contained. ',zshOldSubst fold'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000299
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200300syn sync minlines=50 maxlines=90
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000301syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
302syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>'
303
Bram Moolenaar23515b42020-11-29 14:36:24 +0100304syn keyword zshTodo contained TODO FIXME XXX NOTE
305
306syn region zshComment oneline start='\%(^\|\s\+\)#' end='$'
307 \ contains=zshTodo,@Spell fold
308
309syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
310 \ contains=zshTodo,@Spell fold
311
312syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
313
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000314hi def link zshTodo Todo
315hi def link zshComment Comment
316hi def link zshPreProc PreProc
317hi def link zshQuoted SpecialChar
Bram Moolenaarb17893a2020-03-14 08:19:51 +0100318hi def link zshPOSIXQuoted SpecialChar
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000319hi def link zshString String
320hi def link zshStringDelimiter zshString
321hi def link zshPOSIXString zshString
322hi def link zshJobSpec Special
323hi def link zshPrecommand Special
324hi def link zshDelimiter Keyword
325hi def link zshConditional Conditional
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100326hi def link zshCase zshConditional
327hi def link zshCaseIn zshCase
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000328hi def link zshException Exception
329hi def link zshRepeat Repeat
330hi def link zshKeyword Keyword
331hi def link zshFunction None
332hi def link zshKSHFunction zshFunction
333hi def link zshHereDoc String
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200334hi def link zshOperator None
335hi def link zshRedir Operator
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000336hi def link zshVariable None
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000337hi def link zshVariableDef zshVariable
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000338hi def link zshDereferencing PreProc
Bram Moolenaar94237492017-04-23 18:40:21 +0200339hi def link zshShortDeref zshDereferencing
340hi def link zshLongDeref zshDereferencing
341hi def link zshDeref zshDereferencing
342hi def link zshDollarVar zshDereferencing
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000343hi def link zshCommands Keyword
Bram Moolenaar94237492017-04-23 18:40:21 +0200344hi def link zshOptStart Keyword
345hi def link zshOption Constant
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000346hi def link zshTypes Type
347hi def link zshSwitches Special
348hi def link zshNumber Number
349hi def link zshSubst PreProc
Bram Moolenaar71b6d332022-09-10 13:13:14 +0100350hi def link zshSubstQuoted zshSubst
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000351hi def link zshMathSubst zshSubst
352hi def link zshOldSubst zshSubst
353hi def link zshSubstDelim zshSubst
Bram Moolenaar94237492017-04-23 18:40:21 +0200354hi def link zshGlob zshSubst
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000355
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356let b:current_syntax = "zsh"
357
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000358let &cpo = s:cpo_save
359unlet s:cpo_save