" Vim syntax file " Language: C-shell (tcsh) " Maintainor: Gautam Iyer " Last Modified: Sat 11 Mar 2006 11:16:47 AM CST " " Description: We break up each statement into a "command" and an "end" part. " All groups are either a "command" or part of the "end" of a statement (ie " everything after the "command"). This is because blindly highlighting tcsh " statements as keywords caused way too many false positives. Eg: " " set history=200 " " causes history to come up as a keyword, which we want to avoid. " Quit when a syntax file was already loaded if exists("b:current_syntax") finish endif syn case match " ----- Clusters ----- syn cluster tcshModifiers contains=tcshModifier,tcshModifierError syn cluster tcshQuoteList contains=tcshDQuote,tcshSQuote,tcshBQuote syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,tcshUsrVar,TcshArgv,tcshSubst,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArguement syn cluster tcshStatements contains=tcshBuiltins,tcshCommands,tcshSet,tcshSetEnv,tcshAlias,tcshIf,tcshWhile syn cluster tcshVarList contains=tcshUsrVar,tcshArgv,tcshSubst " ----- Statements ----- " Tcsh commands: Any filename / modifiable variable (must be first!) syn match tcshCommands '\v[a-zA-Z0-9\\./_$:-]+' contains=tcshSpecial,tcshUsrVar,tcshArgv,tcshVarError nextgroup=tcshStatementEnd " Builtin commands except (un)set(env), (un)alias, if, while, else syn keyword tcshBuiltins nextgroup=tcshStatementEnd alloc bg bindkey break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc time umask uncomplete unhash universe unlimit ver wait warp watchlog where which " StatementEnd is anything after a builtin / command till the lexical end of a " statement (;, |, ||, |&, && or end of line) syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltins start='' end='\v\\@|$" contains=tcshOperator,tcshNumber,@tcshStatementEnds " else statements (nextgroup if) syn keyword tcshElse nextgroup=tcshIf skipwhite else " while statements (contains expressions / operators) syn keyword tcshWhile nextgroup=tcshWhEnd while syn region tcshWhEnd contained transparent matchgroup=tcshBuiltins start='' skip="\\$" end="\v$" contains=tcshOperator,tcshNumber,@tcshStatementEnds " Expressions start with @. syn match tcshExprStart "\v\@\s+" nextgroup=tcshExprVar syn match tcshExprVar contained "\v\h\w*%(\[\d+\])?" contains=tcshShellVar,tcshEnvVar nextgroup=tcshExprOp syn match tcshExprOp contained "++\|--" syn match tcshExprOp contained "\v\s*\=" nextgroup=tcshExprEnd syn match tcshExprEnd contained "\v.*$"hs=e+1 contains=tcshOperator,tcshNumber,@tcshVarList syn match tcshExprEnd contained "\v.{-};"hs=e contains=tcshOperator,tcshNumber,@tcshVarList " ----- Comments: ----- syn match tcshComment "#.*" contains=tcshTodo,tcshCommentTi,tcshCommentSp,@Spell syn match tcshSharpBang "^#! .*$" syn match tcshCommentTi contained '\v#\s*\u\w*(\s+\u\w*)*:'hs=s+1 contains=tcshTodo syn match tcshCommentSp contained '\v<\u{3,}>' contains=tcshTodo syn match tcshTodo contained '\v\c' " ----- Strings ----- " Tcsh does not allow \" in strings unless the "backslash_quote" shell " variable is set. Set the vim variable "tcsh_backslash_quote" to 0 if you " want VIM to assume that no backslash quote constructs exist. " Backquotes are treated as commands, and are not contained in anything if(exists("tcsh_backslash_quote") && tcsh_backslash_quote == 0) syn region tcshSQuote keepend contained start="\v\\@, >>, >>&, >>!, >>&!] syn match tcshRedir contained "\v\<|\>\>?\&?!?" " Metachars syn match tcshMeta contained "\v[]{}*?[]" " Here Documents (<<) syn region tcshHereDoc contained matchgroup=tcshRedir start="\v\<\<\s*\z(\h\w*)" end="^\z1$" contains=@tcshVarList,tcshSpecial syn region tcshHereDoc contained matchgroup=tcshRedir start="\v\<\<\s*'\z(\h\w*)'" start='\v\<\<\s*"\z(\h\w*)"$' start="\v\<\<\s*\\\z(\h\w*)$" end="^\z1$" " Operators syn match tcshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||" syn match tcshOperator contained "[(){}]" " Numbers syn match tcshNumber contained "\v<-?\d+>" " Arguements syn match tcshArguement contained "\v\s@<=-(\w|-)*" " Special charectors syn match tcshSpecial contained "\v\\@