| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Vim syntax file | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | " Language:         Zsh shell script | 
					
						
							|  |  |  | " Maintainer:       Nikolai Weibull <now@bitwi.se> | 
					
						
							| 
									
										
										
										
											2010-02-11 14:19:15 +01:00
										 |  |  | " Latest Revision:  2010-01-23 | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if exists("b:current_syntax") | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | let s:cpo_save = &cpo | 
					
						
							|  |  |  | set cpo&vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-24 22:58:06 +00:00
										 |  |  | setlocal iskeyword+=- | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshTodo             contained TODO FIXME XXX NOTE | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-11 14:19:15 +01:00
										 |  |  | syn region  zshComment          oneline start='\%(^\|\s\)#' end='$' | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  |                                 \ contains=zshTodo,@Spell | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshPreProc          '^\%1l#\%(!\|compdef\|autoload\).*$' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshQuoted           '\\.' | 
					
						
							|  |  |  | syn region  zshString           matchgroup=zshStringDelimiter start=+"+ end=+"+ | 
					
						
							|  |  |  |                                 \ contains=zshQuoted,@zshDerefs,@zshSubst | 
					
						
							|  |  |  | syn region  zshString           matchgroup=zshStringDelimiter start=+'+ end=+'+ | 
					
						
							|  |  |  | " XXX: This should probably be more precise, but Zsh seems a bit confused about it itself | 
					
						
							|  |  |  | syn region  zshPOSIXString      matchgroup=zshStringDelimiter start=+\$'+ | 
					
						
							|  |  |  |                                 \ end=+'+ contains=zshQuoted | 
					
						
							|  |  |  | syn match   zshJobSpec          '%\(\d\+\|?\=\w\+\|[%+-]\)' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshPrecommand       noglob nocorrect exec command builtin - time | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshDelimiter        do done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshConditional      if then elif else fi case in esac select | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | syn keyword zshRepeat           while until repeat | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshRepeat           for foreach nextgroup=zshVariable skipwhite | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshException        always | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshKeyword          function nextgroup=zshKSHFunction skipwhite | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshKSHFunction      contained '\k\+' | 
					
						
							|  |  |  | syn match   zshFunction         '^\s*\k\+\ze\s*()' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshOperator         '||\|&&\|;\|&!\=' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshRedir            '\d\=\(<\|<>\|<<<\|<&\s*[0-9p-]\=\)' | 
					
						
							|  |  |  | syn match   zshRedir            '\d\=\(>\|>>\|>&\s*[0-9p-]\=\|&>\|>>&\|&>>\)[|!]\=' | 
					
						
							|  |  |  | syn match   zshRedir            '|&\=' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn region  zshHereDoc          matchgroup=zshRedir | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  |                                 \ start='<\@<!<<\s*\z([^<]\S*\)' | 
					
						
							|  |  |  |                                 \ end='^\z1\>' | 
					
						
							|  |  |  |                                 \ contains=@zshSubst | 
					
						
							|  |  |  | syn region  zshHereDoc          matchgroup=zshRedir | 
					
						
							|  |  |  |                                 \ start='<\@<!<<\s*\\\z(\S\+\)' | 
					
						
							|  |  |  |                                 \ end='^\z1\>' | 
					
						
							|  |  |  |                                 \ contains=@zshSubst | 
					
						
							|  |  |  | syn region  zshHereDoc          matchgroup=zshRedir | 
					
						
							|  |  |  |                                 \ start='<\@<!<<-\s*\\\=\z(\S\+\)' | 
					
						
							|  |  |  |                                 \ end='^\s*\z1\>' | 
					
						
							|  |  |  |                                 \ contains=@zshSubst | 
					
						
							|  |  |  | syn region  zshHereDoc          matchgroup=zshRedir | 
					
						
							|  |  |  |                                 \ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+  | 
					
						
							|  |  |  |                                 \ end='^\z1\>' | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | syn region  zshHereDoc          matchgroup=zshRedir | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  |                                 \ start=+<\@<!<<-\s*\(["']\)\z(\S\+\)\1+ | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  |                                 \ end='^\s*\z1\>' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | syn match   zshVariable         '\<\h\w*' contained | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshVariableDef      '\<\h\w*\ze+\==' | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | " XXX: how safe is this? | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | syn region  zshVariableDef      oneline | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  |                                 \ start='\$\@<!\<\h\w*\[' end='\]\ze+\==' | 
					
						
							|  |  |  |                                 \ contains=@zshSubst | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn cluster zshDerefs           contains=zshShortDeref,zshLongDeref,zshDeref | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if !exists("g:zsh_syntax_variables") | 
					
						
							|  |  |  |   let s:zsh_syntax_variables = 'all' | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   let s:zsh_syntax_variables = g:zsh_syntax_variables | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'short\|all' | 
					
						
							|  |  |  |   syn match zshShortDeref       '\$[!#$*@?_-]\w\@!' | 
					
						
							|  |  |  |   syn match zshShortDeref       '\$[=^~]*[#+]*\d\+\>' | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'long\|all' | 
					
						
							|  |  |  |   syn match zshLongDeref        '\$\%(ARGC\|argv\|status\|pipestatus\|CPUTYPE\|EGID\|EUID\|ERRNO\|GID\|HOST\|LINENO\|LOGNAME\)' | 
					
						
							|  |  |  |   syn match zshLongDeref        '\$\%(MACHTYPE\|OLDPWD OPTARG\|OPTIND\|OSTYPE\|PPID\|PWD\|RANDOM\|SECONDS\|SHLVL\|signals\)' | 
					
						
							|  |  |  |   syn match zshLongDeref        '\$\%(TRY_BLOCK_ERROR\|TTY\|TTYIDLE\|UID\|USERNAME\|VENDOR\|ZSH_NAME\|ZSH_VERSION\|REPLY\|reply\|TERM\)' | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'all' | 
					
						
							|  |  |  |   syn match zshDeref            '\$[=^~]*[#+]*\h\w*\>' | 
					
						
							|  |  |  | else | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  |   syn match zshDeref            transparent contains=NONE '\$[=^~]*[#+]*\h\w*\>' | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshCommands         '\%(^\|\s\)[.:]\ze\s' | 
					
						
							|  |  |  | syn keyword zshCommands         alias autoload bg bindkey break bye cap cd | 
					
						
							|  |  |  |                                 \ chdir clone comparguments compcall compctl | 
					
						
							|  |  |  |                                 \ compdescribe compfiles compgroups compquote | 
					
						
							|  |  |  |                                 \ comptags comptry compvalues continue dirs | 
					
						
							|  |  |  |                                 \ disable disown echo echotc echoti emulate | 
					
						
							|  |  |  |                                 \ enable eval exec exit export false fc fg | 
					
						
							|  |  |  |                                 \ functions getcap getln getopts hash history | 
					
						
							|  |  |  |                                 \ jobs kill let limit log logout popd print | 
					
						
							|  |  |  |                                 \ printf pushd pushln pwd r read readonly | 
					
						
							|  |  |  |                                 \ rehash return sched set setcap setopt shift | 
					
						
							|  |  |  |                                 \ source stat suspend test times trap true | 
					
						
							|  |  |  |                                 \ ttyctl type ulimit umask unalias unfunction | 
					
						
							|  |  |  |                                 \ unhash unlimit unset unsetopt vared wait | 
					
						
							|  |  |  |                                 \ whence where which zcompile zformat zftp zle | 
					
						
							|  |  |  |                                 \ zmodload zparseopts zprof zpty zregexparse | 
					
						
							|  |  |  |                                 \ zsocket zstyle ztcp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn keyword zshTypes            float integer local typeset declare | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " XXX: this may be too much | 
					
						
							|  |  |  | " syn match   zshSwitches         '\s\zs--\=[a-zA-Z0-9-]\+' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | syn match   zshNumber           '[+-]\=\<\d\+\>' | 
					
						
							|  |  |  | syn match   zshNumber           '[+-]\=\<0x\x\+\>' | 
					
						
							|  |  |  | syn match   zshNumber           '[+-]\=\<0\o\+\>' | 
					
						
							|  |  |  | syn match   zshNumber           '[+-]\=\d\+#[-+]\=\w\+\>' | 
					
						
							|  |  |  | syn match   zshNumber           '[+-]\=\d\+\.\d\+\>' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | " TODO: $[...] is the same as $((...)), so add that as well. | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | syn cluster zshSubst            contains=zshSubst,zshOldSubst,zshMathSubst | 
					
						
							|  |  |  | syn region  zshSubst            matchgroup=zshSubstDelim transparent | 
					
						
							|  |  |  |                                 \ start='\$(' skip='\\)' end=')' contains=TOP | 
					
						
							|  |  |  | syn region  zshParentheses      transparent start='(' skip='\\)' end=')' | 
					
						
							|  |  |  | syn region  zshMathSubst        matchgroup=zshSubstDelim transparent | 
					
						
							|  |  |  |                                 \ start='\$((' skip='\\)' | 
					
						
							|  |  |  |                                 \ matchgroup=zshSubstDelim end='))' | 
					
						
							|  |  |  |                                 \ contains=zshParentheses,@zshSubst,zshNumber, | 
					
						
							|  |  |  |                                 \ @zshDerefs,zshString | 
					
						
							|  |  |  | syn region  zshBrackets         contained transparent start='{' skip='\\}' | 
					
						
							|  |  |  |                                 \ end='}' | 
					
						
							|  |  |  | syn region  zshSubst            matchgroup=zshSubstDelim start='\${' skip='\\}' | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  |                                 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | syn region  zshOldSubst         matchgroup=zshSubstDelim start=+`+ skip=+\\`+ | 
					
						
							|  |  |  |                                 \ end=+`+ contains=TOP,zshOldSubst | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | syn sync    minlines=50 | 
					
						
							|  |  |  | syn sync    match zshHereDocSync    grouphere   NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)' | 
					
						
							|  |  |  | syn sync    match zshHereDocEndSync groupthere  NONE '^\s*EO\a\+\>' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | hi def link zshTodo             Todo | 
					
						
							|  |  |  | hi def link zshComment          Comment | 
					
						
							|  |  |  | hi def link zshPreProc          PreProc | 
					
						
							|  |  |  | hi def link zshQuoted           SpecialChar | 
					
						
							|  |  |  | hi def link zshString           String | 
					
						
							|  |  |  | hi def link zshStringDelimiter  zshString | 
					
						
							|  |  |  | hi def link zshPOSIXString      zshString | 
					
						
							|  |  |  | hi def link zshJobSpec          Special | 
					
						
							|  |  |  | hi def link zshPrecommand       Special | 
					
						
							|  |  |  | hi def link zshDelimiter        Keyword | 
					
						
							|  |  |  | hi def link zshConditional      Conditional | 
					
						
							|  |  |  | hi def link zshException        Exception | 
					
						
							|  |  |  | hi def link zshRepeat           Repeat | 
					
						
							|  |  |  | hi def link zshKeyword          Keyword | 
					
						
							|  |  |  | hi def link zshFunction         None | 
					
						
							|  |  |  | hi def link zshKSHFunction      zshFunction | 
					
						
							|  |  |  | hi def link zshHereDoc          String | 
					
						
							|  |  |  | if 0 | 
					
						
							|  |  |  |   hi def link zshOperator         Operator | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   hi def link zshOperator         None | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | if 1 | 
					
						
							|  |  |  |   hi def link zshRedir            Operator | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   hi def link zshRedir            None | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | hi def link zshVariable         None | 
					
						
							| 
									
										
										
										
											2008-08-06 17:06:04 +00:00
										 |  |  | hi def link zshVariableDef      zshVariable | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | hi def link zshDereferencing    PreProc | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'short\|all' | 
					
						
							|  |  |  |   hi def link zshShortDeref     zshDereferencing | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   hi def link zshShortDeref     None | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'long\|all' | 
					
						
							|  |  |  |   hi def link zshLongDeref      zshDereferencing | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   hi def link zshLongDeref      None | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | if s:zsh_syntax_variables =~ 'all' | 
					
						
							|  |  |  |   hi def link zshDeref          zshDereferencing | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   hi def link zshDeref          None | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | endif | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | hi def link zshCommands         Keyword | 
					
						
							|  |  |  | hi def link zshTypes            Type | 
					
						
							|  |  |  | hi def link zshSwitches         Special | 
					
						
							|  |  |  | hi def link zshNumber           Number | 
					
						
							|  |  |  | hi def link zshSubst            PreProc | 
					
						
							|  |  |  | hi def link zshMathSubst        zshSubst | 
					
						
							|  |  |  | hi def link zshOldSubst         zshSubst | 
					
						
							|  |  |  | hi def link zshSubstDelim       zshSubst | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | let b:current_syntax = "zsh" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-05 18:24:42 +00:00
										 |  |  | let &cpo = s:cpo_save | 
					
						
							|  |  |  | unlet s:cpo_save |