From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7624 invoked from network); 12 Dec 2004 13:35:09 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Dec 2004 13:35:09 -0000 Received: (qmail 47281 invoked from network); 12 Dec 2004 13:35:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Dec 2004 13:35:02 -0000 Received: (qmail 3979 invoked by alias); 12 Dec 2004 13:34:12 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8295 Received: (qmail 3965 invoked from network); 12 Dec 2004 13:34:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Dec 2004 13:34:11 -0000 Received: (qmail 46005 invoked from network); 12 Dec 2004 13:34:11 -0000 Received: from mxfep02.bredband.com (195.54.107.73) by a.mx.sunsite.dk with SMTP; 12 Dec 2004 13:34:10 -0000 Received: from puritan.pcp.ath.cx ([213.112.43.197] [213.112.43.197]) by mxfep02.bredband.com with ESMTP id <20041212133410.JHB6820.mxfep02.bredband.com@puritan.pcp.ath.cx> for ; Sun, 12 Dec 2004 14:34:10 +0100 Received: by puritan.pcp.ath.cx (Postfix, from userid 1000) id 1BC51AE044; Sun, 12 Dec 2004 14:34:10 +0100 (CET) Date: Sun, 12 Dec 2004 14:34:09 +0100 From: Nikolai Weibull To: zsh-users@sunsite.dk Subject: Re: Vim syntax file for zsh Message-ID: <20041212133409.GA9431@puritan.pcp.ath.cx> Mail-Followup-To: zsh-users@sunsite.dk References: <902B4263-49EA-11D9-A14D-000A95D2C79E@kalama.no-ip.org> <20041209144520.GC9424@puritan.pcp.ath.cx> <20041209181813.GF9424@puritan.pcp.ath.cx> <20041209182347.GG9424@puritan.pcp.ath.cx> <20041209200941.GA27510@blorf.net> <20041209212423.GA21023@puritan.pcp.ath.cx> <20041209224315.GB27510@blorf.net> <20041209232655.GB21023@puritan.pcp.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: **** X-Spam-Status: No, hits=4.1 required=6.0 tests=OPT_IN_CAPS,RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 4.1 --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Felix Rosencrantz [Dec 12, 2004 14:09]: > Some of the characters like "|<>" were being highlighted as yellow in > a variable reference like ( found in _files:71) eval "def=( > ${${def:gs/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}})" > another one from _path_files:165 that confuses it: > tmp3="${${(M)SUFFIX%\([^\|\~]##\)}[2,-2]}" Here's a line that seems to > confuse it from _nslookup > "${(@)^${(@)${(@M)setopts:#\(*}/\)/)-}/\(/(-}" \ This all leads me to believe that substitutions shouldn't be highlighted at all; it's just to complicated to get right. At least we're able to match well-nested stuff, but ${(@)^${(@)${(@M)setopts:#\(*}/\)/)-}/\(/(-} is just too weird. It's a bugger that it highlights too much, though. Suggestions? I guess that if there was a good way of matching stuff like ${var/pat/sub} ^^^^^^^^ one could figure out that this could contain unescaped parentheses and so on... > Also the `` embedded in double quotes doesn't seem to highlight > properly. Fixed. > Also, it might be nice if well known functions like the completion > functions (e.g. _arguments) are highlighted, like it does with > builtin variables. That's getting a bit out of hand. > A free standing -, or one that is in the middle of a word seems to > turn red... Yeah, it's the pre-command modifier. Perhaps we should simply ignore it. > The syntax file doesn't handle here-strings "<<<" syntax. (see: > http://zsh.sunsite.dk/Doc/Release/zsh_6.html#SEC28) Well, it highlights the <<<. > Thanks Nikolai, this is useful. NP, nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);} --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="zsh.vim" " Vim syntax file " Language: Zsh shell script " Maintainer: Nikolai Weibull " URL: http://www.pcppopper.org/vim/syntax/pcp/zsh/ " Latest Revision: 2004-12-12 " arch-tag: 2e2c7097-99cb-4b87-a771-3a819b69995e if version < 600 syntax clear elseif exists("b:current_syntax") finish endif " Set iskeyword since we need `-' (and potentially others) in keywords. " For version 5.x: Set it globally " For version 6.x: Set it locally if version >= 600 command -nargs=1 SetIsk setlocal iskeyword= else command -nargs=1 SetIsk set iskeyword= endif SetIsk @,48-57,_,- delcommand SetIsk " Todo syn keyword zshTodo contained TODO FIXME XXX NOTE " Comments syn region zshComment matchgroup=zshComment start='\(^\|\s\)#' end='$' contains=zshTodo " PreProc syn match zshPreProc '^\%1l#\(!\|compdef\|autoload\).*$' " Strings 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\+\|[%+-]\)' " Precommand Modifiers syn keyword zshPrecommand noglob nocorrect exec command builtin - time " Delimiters syn keyword zshDelimiter do done " Conditionals syn keyword zshConditional if then elif else fi case in esac select " Loops syn keyword zshRepeat for while until repeat foreach " Exceptions syn keyword zshException always " Keywords syn keyword zshKeyword function nextgroup=zshKSHFunction skipwhite " Functions syn match zshKSHFunction contained '\k\+' syn match zshFunction '^\s*\k\+\ze\s*()' " Operators syn match zshOperator '||\|&&\|;\|&!\=' " Redirections syn match zshRedir '\d\=\(<\|<>\|<<<\|<&\s*[0-9p-]\=\)' syn match zshRedir '\d\=\(>\|>>\|>&\s*[0-9p-]\=\|&>\|>>&\|&>>\)[|!]\=' syn match zshRedir '|&\=' " Here Documents if version < 600 " Do nothing for now TODO: do something else 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$' syn region zshHereDoc matchgroup=zshRedir start='<<-\s*\(["']\)\z(\S*\)\1' end='^\s*\z1$' endif " Variable Assignments syn match zshVariable '\<\h\w*\ze+\==' " XXX: how safe is this? syn region zshVariable oneline matchgroup=zshVariable start='\$\@' 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*\>' endif " Commands syn match zshCommands '\s[.:]\s' syn keyword zshCommands alias autoload bg bindkey break bye cap cd chdir syn keyword zshCommands clone comparguments compcall compctl compdescribe syn keyword zshCommands compfiles compgroups compquote comptags comptry syn keyword zshCommands compvalues continue declare dirs disable disown syn keyword zshCommands echo echotc echoti emulate enable eval exec exit syn keyword zshCommands export false fc fg functions getcap getln syn keyword zshCommands getopts hash history jobs kill let limit syn keyword zshCommands log logout popd print printf pushd pushln syn keyword zshCommands pwd r read readonly rehash return sched set syn keyword zshCommands setcap setopt shift source stat suspend test times syn keyword zshCommands trap true ttyctl type ulimit umask unalias syn keyword zshCommands unfunction unhash unlimit unset unsetopt vared syn keyword zshCommands wait whence where which zcompile zformat zftp zle syn keyword zshCommands zmodload zparseopts zprof zpty zregexparse zsocket syn keyword zshCommands zstyle ztcp " Types syn keyword zshTypes float integer local typeset " Switches " XXX: this may be too much syn match zshSwitches '\s\zs--\=[a-zA-Z0-9-]\+' " Numbers syn match zshNumber '\<-\=\(\d\+#\|0x\=\)\=\d\+\>' syn match zshNumber '\<-\=\d\+.\d\+\>' " Substitution " XXX: is this right? something may be wrong here syn cluster zshSubst contains=zshSubst,zshBrackets,zshOldSubst syn region zshBrackets transparent start='(' skip='\\)' end=')' contains=TOP syn region zshBrackets transparent start='{' skip='\\}' end='}' contains=TOP syn region zshSubst matchgroup=zshDeref transparent start='\$(' skip='\\)' end=')' contains=TOP syn region zshSubst matchgroup=zshDeref transparent start='\$((' end='))' contains=TOP syn region zshSubst matchgroup=zshSubst start='\${' skip='\\}' end='}' contains=@zshSubst syn region zshOldSubst matchgroup=zshOldSubst start=+`+ skip=+\\`+ end=+`+ contains=TOP,zshOldSubst " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_zsh_syn_inits") if version < 508 let did_zsh_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink zshTodo Todo HiLink zshComment Comment HiLink zshPreProc PreProc HiLink zshQuoted SpecialChar HiLink zshString String HiLink zshStringDelimiter zshString HiLink zshPOSIXString zshString HiLink zshJobSpec Special HiLink zshPrecommand Special HiLink zshDelimiter Keyword HiLink zshConditional Conditional HiLink zshException Exception HiLink zshRepeat Repeat HiLink zshKeyword Keyword HiLink zshFunction Function HiLink zshKSHFunction zshFunction HiLink zshHereDoc String HiLink zshOperator Operator HiLink zshRedir Operator HiLink zshVariable Identifier HiLink zshShortDeref zshDeref HiLink zshLongDeref zshDeref HiLink zshDeref PreProc HiLink zshCommands Keyword HiLink zshTypes Type HiLink zshSwitches Special HiLink zshNumber Number HiLink zshSubst zshDeref HiLink zshOldSubst zshSubst delcommand HiLink endif let b:current_syntax = "zsh" " vim: set sts=2 sw=2: --7JfCtLOvnd9MIVvH--