1" Vim syntax file 2" Language: Zsh shell script 3" Maintainer: Nikolai Weibull <[email protected]> 4" Latest Revision: 2006-08-06 5 6if exists("b:current_syntax") 7 finish 8endif 9 10let s:cpo_save = &cpo 11set cpo&vim 12 13setlocal iskeyword=@,48-57,_,- 14 15syn keyword zshTodo contained TODO FIXME XXX NOTE 16 17syn region zshComment display oneline start='\%(^\|\s\)#' end='$' 18 \ contains=zshTodo,@Spell 19 20syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$' 21 22syn match zshQuoted '\\.' 23syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+ 24 \ contains=zshQuoted,@zshDerefs,@zshSubst 25syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ 26" XXX: This should probably be more precise, but Zsh seems a bit confused about it itself 27syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+ 28 \ end=+'+ contains=zshQuoted 29syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)' 30 31syn keyword zshPrecommand noglob nocorrect exec command builtin - time 32 33syn keyword zshDelimiter do done 34 35syn keyword zshConditional if then elif else fi case in esac select 36 37syn keyword zshRepeat for while until repeat foreach 38 39syn keyword zshException always 40 41syn keyword zshKeyword function nextgroup=zshKSHFunction skipwhite 42 43syn match zshKSHFunction contained '\k\+' 44syn match zshFunction '^\s*\k\+\ze\s*()' 45 46syn match zshOperator '||\|&&\|;\|&!\=' 47 48syn match zshRedir '\d\=\(<\|<>\|<<<\|<&\s*[0-9p-]\=\)' 49syn match zshRedir '\d\=\(>\|>>\|>&\s*[0-9p-]\=\|&>\|>>&\|&>>\)[|!]\=' 50syn match zshRedir '|&\=' 51 52syn region zshHereDoc matchgroup=zshRedir start='<<\s*\z(\S*\)' 53 \ end='^\z1\>' contains=@zshSubst 54syn region zshHereDoc matchgroup=zshRedir start='<<-\s*\z(\S*\)' 55 \ end='^\s*\z1\>' contains=@zshSubst 56syn region zshHereDoc matchgroup=zshRedir 57 \ start=+<<\s*\(["']\)\z(\S*\)\1+ end='^\z1\>' 58syn region zshHereDoc matchgroup=zshRedir 59 \ start=+<<-\s*\(["']\)\z(\S*\)\1+ 60 \ end='^\s*\z1\>' 61 62syn match zshVariable '\<\h\w*\ze+\==' 63" XXX: how safe is this? 64syn region zshVariable oneline 65 \ start='\$\@<!\<\h\w*\[' end='\]\ze+\==' 66 \ contains=@zshSubst 67 68syn cluster zshDerefs contains=zshShortDeref,zshLongDeref,zshDeref 69 70if !exists("g:zsh_syntax_variables") 71 let s:zsh_syntax_variables = 'all' 72else 73 let s:zsh_syntax_variables = g:zsh_syntax_variables 74endif 75 76if s:zsh_syntax_variables =~ 'short\|all' 77 syn match zshShortDeref '\$[!#$*@?_-]\w\@!' 78 syn match zshShortDeref '\$[=^~]*[#+]*\d\+\>' 79endif 80 81if s:zsh_syntax_variables =~ 'long\|all' 82 syn match zshLongDeref '\$\%(ARGC\|argv\|status\|pipestatus\|CPUTYPE\|EGID\|EUID\|ERRNO\|GID\|HOST\|LINENO\|LOGNAME\)' 83 syn match zshLongDeref '\$\%(MACHTYPE\|OLDPWD OPTARG\|OPTIND\|OSTYPE\|PPID\|PWD\|RANDOM\|SECONDS\|SHLVL\|signals\)' 84 syn match zshLongDeref '\$\%(TRY_BLOCK_ERROR\|TTY\|TTYIDLE\|UID\|USERNAME\|VENDOR\|ZSH_NAME\|ZSH_VERSION\|REPLY\|reply\|TERM\)' 85endif 86 87if s:zsh_syntax_variables =~ 'all' 88 syn match zshDeref '\$[=^~]*[#+]*\h\w*\>' 89else 90 syn match zshDeref transparent '\$[=^~]*[#+]*\h\w*\>' 91endif 92 93syn match zshCommands '\%(^\|\s\)[.:]\ze\s' 94syn keyword zshCommands alias autoload bg bindkey break bye cap cd 95 \ chdir clone comparguments compcall compctl 96 \ compdescribe compfiles compgroups compquote 97 \ comptags comptry compvalues continue dirs 98 \ disable disown echo echotc echoti emulate 99 \ enable eval exec exit export false fc fg 100 \ functions getcap getln getopts hash history 101 \ jobs kill let limit log logout popd print 102 \ printf pushd pushln pwd r read readonly 103 \ rehash return sched set setcap setopt shift 104 \ source stat suspend test times trap true 105 \ ttyctl type ulimit umask unalias unfunction 106 \ unhash unlimit unset unsetopt vared wait 107 \ whence where which zcompile zformat zftp zle 108 \ zmodload zparseopts zprof zpty zregexparse 109 \ zsocket zstyle ztcp 110 111syn keyword zshTypes float integer local typeset declare 112 113" XXX: this may be too much 114" syn match zshSwitches '\s\zs--\=[a-zA-Z0-9-]\+' 115 116syn match zshNumber '[+-]\=\<\d\+\>' 117syn match zshNumber '[+-]\=\<0x\x\+\>' 118syn match zshNumber '[+-]\=\<0\o\+\>' 119syn match zshNumber '[+-]\=\d\+#[-+]\=\w\+\>' 120syn match zshNumber '[+-]\=\d\+\.\d\+\>' 121 122syn cluster zshSubst contains=zshSubst,zshOldSubst,zshMathSubst 123syn region zshSubst matchgroup=zshSubstDelim transparent 124 \ start='\$(' skip='\\)' end=')' contains=TOP 125syn region zshParentheses transparent start='(' skip='\\)' end=')' 126syn region zshMathSubst matchgroup=zshSubstDelim transparent 127 \ start='\$((' skip='\\)' 128 \ matchgroup=zshSubstDelim end='))' 129 \ contains=zshParentheses,@zshSubst,zshNumber, 130 \ @zshDerefs,zshString 131syn region zshBrackets contained transparent start='{' skip='\\}' 132 \ end='}' 133syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}' 134 \ end='}' contains=@zshSubst,zshBrackets,zshQuoted 135syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+ 136 \ end=+`+ contains=TOP,zshOldSubst 137 138hi def link zshTodo Todo 139hi def link zshComment Comment 140hi def link zshPreProc PreProc 141hi def link zshQuoted SpecialChar 142hi def link zshString String 143hi def link zshStringDelimiter zshString 144hi def link zshPOSIXString zshString 145hi def link zshJobSpec Special 146hi def link zshPrecommand Special 147hi def link zshDelimiter Keyword 148hi def link zshConditional Conditional 149hi def link zshException Exception 150hi def link zshRepeat Repeat 151hi def link zshKeyword Keyword 152hi def link zshFunction None 153hi def link zshKSHFunction zshFunction 154hi def link zshHereDoc String 155if 0 156 hi def link zshOperator Operator 157else 158 hi def link zshOperator None 159endif 160if 1 161 hi def link zshRedir Operator 162else 163 hi def link zshRedir None 164endif 165hi def link zshVariable None 166hi def link zshDereferencing PreProc 167if s:zsh_syntax_variables =~ 'short\|all' 168 hi def link zshShortDeref zshDereferencing 169else 170 hi def link zshShortDeref None 171endif 172if s:zsh_syntax_variables =~ 'long\|all' 173 hi def link zshLongDeref zshDereferencing 174else 175 hi def link zshLongDeref None 176endif 177if s:zsh_syntax_variables =~ 'all' 178 hi def link zshDeref zshDereferencing 179else 180 hi def link zshDeref None 181endif 182hi def link zshCommands Keyword 183hi def link zshTypes Type 184hi def link zshSwitches Special 185hi def link zshNumber Number 186hi def link zshSubst PreProc 187hi def link zshMathSubst zshSubst 188hi def link zshOldSubst zshSubst 189hi def link zshSubstDelim zshSubst 190 191let b:current_syntax = "zsh" 192 193let &cpo = s:cpo_save 194unlet s:cpo_save 195