2004-06-13 20:20:40 +00:00
|
|
|
" Vim syntax file
|
2015-06-09 19:44:55 +02:00
|
|
|
" Language: Zsh shell script
|
|
|
|
" Maintainer: Christian Brabandt <cb@256bit.org>
|
|
|
|
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
2017-04-23 18:40:21 +02:00
|
|
|
" Latest Revision: 2017-04-10
|
2015-06-09 19:44:55 +02:00
|
|
|
" License: Vim (see :h license)
|
2017-04-23 18:40:21 +02:00
|
|
|
" Repository: https://github.com/chrisbra/vim-zsh
|
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
|
|
|
|
|
2016-02-25 00:00:01 +01:00
|
|
|
if v:version > 704 || (v:version == 704 && has("patch1142"))
|
|
|
|
syn iskeyword @,48-57,_,192-255,#,-
|
|
|
|
else
|
|
|
|
setlocal iskeyword+=-
|
|
|
|
endif
|
|
|
|
if get(g:, 'zsh_fold_enable', 0)
|
|
|
|
setlocal foldmethod=syntax
|
|
|
|
endif
|
2007-05-05 18:24:42 +00:00
|
|
|
|
|
|
|
syn keyword zshTodo contained TODO FIXME XXX NOTE
|
|
|
|
|
2017-04-23 18:40:21 +02:00
|
|
|
syn region zshComment oneline start='\%(^\|\s\+\)#' end='$'
|
2016-02-25 00:00:01 +01:00
|
|
|
\ contains=zshTodo,@Spell fold
|
|
|
|
|
|
|
|
syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!'
|
|
|
|
\ contains=zshTodo,@Spell fold
|
2007-05-05 18:24:42 +00:00
|
|
|
|
|
|
|
syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
|
|
|
|
|
|
|
|
syn match zshQuoted '\\.'
|
|
|
|
syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+
|
2016-02-25 00:00:01 +01:00
|
|
|
\ contains=zshQuoted,@zshDerefs,@zshSubst fold
|
|
|
|
syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold
|
2007-05-05 18:24:42 +00:00
|
|
|
" 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
|
|
|
|
|
2015-06-09 19:44:55 +02:00
|
|
|
syn keyword zshDelimiter do done end
|
2007-05-05 18:24:42 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-02-25 00:00:01 +01:00
|
|
|
syn match zshKSHFunction contained '\w\S\+'
|
2007-05-05 18:24:42 +00:00
|
|
|
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
|
2015-06-09 19:44:55 +02:00
|
|
|
\ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+
|
2008-08-06 17:06:04 +00:00
|
|
|
\ 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
|
2017-04-23 18:40:21 +02:00
|
|
|
\ start='\$\@<!\<\h\w*\[' end='\]\ze+\?=\?'
|
2007-05-05 18:24:42 +00:00
|
|
|
\ contains=@zshSubst
|
|
|
|
|
2017-04-23 18:40:21 +02:00
|
|
|
syn cluster zshDerefs contains=zshShortDeref,zshLongDeref,zshDeref,zshDollarVar
|
2007-05-05 18:24:42 +00:00
|
|
|
|
2017-04-23 18:40:21 +02:00
|
|
|
syn match zshShortDeref '\$[!#$*@?_-]\w\@!'
|
|
|
|
syn match zshShortDeref '\$[=^~]*[#+]*\d\+\>'
|
2007-05-05 18:24:42 +00:00
|
|
|
|
2017-04-23 18:40:21 +02:00
|
|
|
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\)'
|
2007-05-05 18:24:42 +00:00
|
|
|
|
2017-04-23 18:40:21 +02:00
|
|
|
syn match zshDollarVar '\$\h\w*'
|
|
|
|
syn match zshDeref '\$[=^~]*[#+]*\h\w*\>'
|
2007-05-05 18:24:42 +00:00
|
|
|
|
|
|
|
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
|
2017-04-23 18:40:21 +02:00
|
|
|
\ rehash return sched set setcap shift
|
2007-05-05 18:24:42 +00:00
|
|
|
\ source stat suspend test times trap true
|
|
|
|
\ ttyctl type ulimit umask unalias unfunction
|
2017-04-23 18:40:21 +02:00
|
|
|
\ unhash unlimit unset vared wait
|
2007-05-05 18:24:42 +00:00
|
|
|
\ whence where which zcompile zformat zftp zle
|
|
|
|
\ zmodload zparseopts zprof zpty zregexparse
|
|
|
|
\ zsocket zstyle ztcp
|
|
|
|
|
2015-06-09 19:44:55 +02:00
|
|
|
" Options, generated by: echo ${(j:\n:)options[(I)*]} | sort
|
2016-01-03 22:14:44 +01:00
|
|
|
" Create a list of option names from zsh source dir:
|
|
|
|
" #!/bin/zsh
|
|
|
|
" topdir=/path/to/zsh-xxx
|
|
|
|
" grep '^pindex([A-Za-z_]*)$' $topdir/Src/Doc/Zsh/optionsyo |
|
|
|
|
" while read opt
|
|
|
|
" do
|
|
|
|
" echo ${${(L)opt#pindex\(}%\)}
|
|
|
|
" done
|
|
|
|
|
2015-06-09 19:44:55 +02:00
|
|
|
syn case ignore
|
2017-04-23 18:40:21 +02:00
|
|
|
|
|
|
|
syn match zshOptStart /^\s*\%(\%(\%(un\)\?setopt\)\|set\s+[-+]o\)/ nextgroup=zshOption skipwhite
|
|
|
|
syn match zshOption /\%(\%(no_\?\)\?aliases\)\|\%(\%(no_\?\)\?allexport\)\|\%(\%(no_\?\)\?all_export\)\|\%(\%(no_\?\)\?alwayslastprompt\)\|\%(\%(no_\?\)\?always_last_prompt\)\|\%(\%(no_\?\)\?always_lastprompt\)\|\%(\%(no_\?\)\?alwaystoend\)\|\%(\%(no_\?\)\?always_to_end\)\|\%(\%(no_\?\)\?appendcreate\)\|\%(\%(no_\?\)\?append_create\)\|\%(\%(no_\?\)\?appendhistory\)\|\%(\%(no_\?\)\?append_history\)\|\%(\%(no_\?\)\?autocd\)\|\%(\%(no_\?\)\?auto_cd\)\|\%(\%(no_\?\)\?autocontinue\)\|\%(\%(no_\?\)\?auto_continue\)\|\%(\%(no_\?\)\?autolist\)\|\%(\%(no_\?\)\?auto_list\)\|\%(\%(no_\?\)\?automenu\)\|\%(\%(no_\?\)\?auto_menu\)\|\%(\%(no_\?\)\?autonamedirs\)\|\%(\%(no_\?\)\?auto_name_dirs\)\|\%(\%(no_\?\)\?autoparamkeys\)\|\%(\%(no_\?\)\?auto_param_keys\)\|\%(\%(no_\?\)\?autoparamslash\)\|\%(\%(no_\?\)\?auto_param_slash\)\|\%(\%(no_\?\)\?autopushd\)\|\%(\%(no_\?\)\?auto_pushd\)\|\%(\%(no_\?\)\?autoremoveslash\)\|\%(\%(no_\?\)\?auto_remove_slash\)\|\%(\%(no_\?\)\?autoresume\)\|\%(\%(no_\?\)\?auto_resume\)\|\%(\%(no_\?\)\?badpattern\)\|\%(\%(no_\?\)\?bad_pattern\)\|\%(\%(no_\?\)\?banghist\)\|\%(\%(no_\?\)\?bang_hist\)\|\%(\%(no_\?\)\?bareglobqual\)\|\%(\%(no_\?\)\?bare_glob_qual\)\|\%(\%(no_\?\)\?bashautolist\)\|\%(\%(no_\?\)\?bash_auto_list\)\|\%(\%(no_\?\)\?bashrematch\)\|\%(\%(no_\?\)\?bash_rematch\)\|\%(\%(no_\?\)\?beep\)\|\%(\%(no_\?\)\?bgnice\)\|\%(\%(no_\?\)\?bg_nice\)\|\%(\%(no_\?\)\?braceccl\)\|\%(\%(no_\?\)\?brace_ccl\)\|\%(\%(no_\?\)\?braceexpand\)\|\%(\%(no_\?\)\?brace_expand\)\|\%(\%(no_\?\)\?bsdecho\)\|\%(\%(no_\?\)\?bsd_echo\)\|\%(\%(no_\?\)\?caseglob\)\|\%(\%(no_\?\)\?case_glob\)\|\%(\%(no_\?\)\?casematch\)\|\%(\%(no_\?\)\?case_match\)\|\%(\%(no_\?\)\?cbases\)\|\%(\%(no_\?\)\?c_bases\)\|\%(\%(no_\?\)\?cdablevars\)\|\%(\%(no_\?\)\?cdable_vars\)\|\%(\%(no_\?\)\?cd_able_vars\)\|\%(\%(no_\?\)\?chasedots\)\|\%(\%(no_\?\)\?chase_dots\)\|\%(\%(no_\?\)\?chaselinks\)\|\%(\%(no_\?\)\?chase_links\)\|\%(\%(no_\?\)\?checkjobs\)\|\%(\%(no_\?\)\?check_jobs\)\|\%(\%(no_\?\)\?clobber\)\|\%(\%(no_\?\)\?combiningchars\)\|\%(\%(no_\?\)\?combining_chars\)\|\%(\%(no_\?\)\?completealiases\)\|\%(\%(no_\?\)\?complete_aliases\)\|\%(\%(no_\?\)\?completeinword\)\|\%(\%(no_\?\)\?complete_in_word\)\|\%(\%(no_\?\)\?continueonerror\)\|\%(\%(no_\?\)\?continue_on_error\)\|\%(\%(no_\?\)\?correct\)\|\%(\%(no_\?\)\?correctall\)\|\%(\%(no_\?\)\?correct_all\)\|\%(\%(no_\?\)\?cprecedences\)\|\%(\%(no_\?\)\?c_precedences\)\|\%(\%(no_\?\)\?cshjunkiehistory\)\|\%(\%(no_\?\)\?csh_junkie_history\)\|\%(\%(no_\?\)\?cshjunkieloops\)\|\%(\%(no_\?\)\?csh_junkie_loops\)\|\%(\%(no_\?\)\?cshjunkiequotes\)\|\%(\%(no_\?\)\?csh_junkie_quotes\)\|\%(\%(no_\?\)\?csh_nullcmd\)\|\%(\%(no_\?\)\?csh_null_cmd\)\|\%(\%(no_\?\)\?cshnullcmd\)\|\%(\%(no_\?\)\?csh_null_cmd\)\|\%(\%(no_\?\)\?cshnullglob\)\|\%(\%(no_\?\)\?csh_null_glob\)\|\%(\%(no_\?\)\?debugbeforecmd\)\|\%(\%(no_\?\)\?debug_before_cmd\)\|\%(\%(no_\?\)\?dotglob\)\|\%(\%(no_\?\)\?dot_glob\)\|\%(\%(no_\?\)\?dvorak\)\|\%(\%(no_\?\)\?emacs\)\|\%(\%(no_\?\)\?equals\)\|\%(\%(no_\?\)\?errexit\)\|\%(\%(no_\?\)\?err_exit\)\|\%(\%(no_\?\)\?errreturn\)\|\%(\%(no_\?\)\?err_return\)\|\%(\%(no_\?\)\?evallineno\)\|\%(\%(no_\?\)\?eval_lineno\)\|\%(\%(no_\?\)\?exec\)\|\%(\%(no_\?\)\?extendedglob\)\|\%(\%(no_\?\)\?extended_glob\)\|\%(\%(no_\?\)\?extendedhistory\)\|\%(\%(no_\?\)\?extended_history\)\|\%(\%(no_\?\)\?flowcontrol\)\|\%(\%(no_\?\)\?flow_control\)\|\%(\%(no_\?\)\?forcefloat\)\|\%(\%(no_\?\)\?force_float\)\|\%(\%(no_\?\)\?functionargzero\)\|\%(\%(no_\?\)\?function_argzero\)\|\%(\%(no_\?\)\?function_arg_zero\)\|\%(\%(no_\?\)\?glob\)\|\%(\%(no_\?\)\?globalexport\)\|\%(\%(no_\?\)\?global_export\)\|\%(\%(no_\?\)\?globalrcs\)\|\%(\%(no_\?\)\?global_rcs\)\|\%(\%(no_\?\)\?globassign\)\|\%(\%(no_\?\)\?glob_assign\)\|\%(\%(no_\?\)\?globcomplete\)\|\%(\%(no_\?\)\?glob_complete\)\|\%(\%(no_\?\)\?globdots\)\|\%(\%(no_\?\)\?glob_dots\)\|\%(\%(no_\?\)\?glob_subst\)\|\%(\%(no_\?\)\?globsubst\)\|\%(\%(no_\?\)\?globstarshort\)\|\%(\%(no_\?\)\?glob_star_short\)\|\%(\%(no_\?\)\?hashall\)\|\%(\%(no_\?\)\?hash_all\)\|\%(\%(no_\?\)\?hashcmds\)\|\%(
|
2015-06-09 19:44:55 +02:00
|
|
|
|
2016-01-03 22:14:44 +01:00
|
|
|
syn keyword zshTypes float integer local typeset declare private
|
2007-05-05 18:24:42 +00:00
|
|
|
|
|
|
|
" 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
|
2016-02-04 20:57:07 +01:00
|
|
|
\ start='\$(' skip='\\)' end=')' contains=TOP fold
|
|
|
|
syn region zshParentheses transparent start='(' skip='\\)' end=')' fold
|
2017-04-23 18:40:21 +02:00
|
|
|
syn region zshGlob start='(#' end=')'
|
2007-05-05 18:24:42 +00:00
|
|
|
syn region zshMathSubst matchgroup=zshSubstDelim transparent
|
2017-04-23 18:40:21 +02:00
|
|
|
\ start='\$((' skip='\\)' end='))'
|
2007-05-05 18:24:42 +00:00
|
|
|
\ contains=zshParentheses,@zshSubst,zshNumber,
|
2016-02-04 20:57:07 +01:00
|
|
|
\ @zshDerefs,zshString keepend fold
|
2007-05-05 18:24:42 +00:00
|
|
|
syn region zshBrackets contained transparent start='{' skip='\\}'
|
2016-02-04 20:57:07 +01:00
|
|
|
\ end='}' fold
|
2016-02-25 00:00:01 +01:00
|
|
|
syn region zshBrackets transparent start='{' skip='\\}'
|
|
|
|
\ end='}' contains=TOP fold
|
2007-05-05 18:24:42 +00:00
|
|
|
syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
|
2016-02-04 20:57:07 +01:00
|
|
|
\ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold
|
2007-05-05 18:24:42 +00:00
|
|
|
syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+
|
2016-02-04 20:57:07 +01:00
|
|
|
\ end=+`+ contains=TOP,zshOldSubst fold
|
2007-05-05 18:24:42 +00:00
|
|
|
|
2015-06-09 19:44:55 +02:00
|
|
|
syn sync minlines=50 maxlines=90
|
2008-08-06 17:06:04 +00:00
|
|
|
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
|
2015-06-09 19:44:55 +02:00
|
|
|
hi def link zshOperator None
|
|
|
|
hi def link zshRedir Operator
|
2007-05-05 18:24:42 +00:00
|
|
|
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
|
2017-04-23 18:40:21 +02:00
|
|
|
hi def link zshShortDeref zshDereferencing
|
|
|
|
hi def link zshLongDeref zshDereferencing
|
|
|
|
hi def link zshDeref zshDereferencing
|
|
|
|
hi def link zshDollarVar zshDereferencing
|
2007-05-05 18:24:42 +00:00
|
|
|
hi def link zshCommands Keyword
|
2017-04-23 18:40:21 +02:00
|
|
|
hi def link zshOptStart Keyword
|
|
|
|
hi def link zshOption Constant
|
2007-05-05 18:24:42 +00:00
|
|
|
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
|
2017-04-23 18:40:21 +02:00
|
|
|
hi def link zshGlob 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
|