diff options
author | Bram Moolenaar <Bram@vim.org> | 2008-06-24 20:39:31 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2008-06-24 20:39:31 +0000 |
commit | a7241f5f19fd0865ce697939c347a8c88fb507d5 (patch) | |
tree | e1f1c07fe74094539286be048cc3306f6aedb0bc /runtime/syntax/tcsh.vim | |
parent | f233048a129fa7a3b89e064078435181d6421da5 (diff) | |
download | vim-git-a7241f5f19fd0865ce697939c347a8c88fb507d5.tar.gz |
updated for version 7.2a
Diffstat (limited to 'runtime/syntax/tcsh.vim')
-rw-r--r-- | runtime/syntax/tcsh.vim | 219 |
1 files changed, 137 insertions, 82 deletions
diff --git a/runtime/syntax/tcsh.vim b/runtime/syntax/tcsh.vim index 83649a751..94c4181c3 100644 --- a/runtime/syntax/tcsh.vim +++ b/runtime/syntax/tcsh.vim @@ -1,7 +1,6 @@ -" Vim syntax file -" Language: C-shell (tcsh) -" Maintainer: Gautam Iyer <gi1242@users.sourceforge.net> -" Last Modified: Thu 16 Nov 2006 01:07:04 PM PST +" tcsh.vim: Vim syntax file for tcsh scripts +" Maintainer: Gautam Iyer <gi1242@users.sourceforge.net> +" Modified: Sat 16 Jun 2007 04:52:12 PM PDT " " 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 @@ -13,64 +12,118 @@ " 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") +if exists('b:current_syntax') finish endif +let s:oldcpo = &cpo +set cpo&vim " Line continuation is used + +setlocal iskeyword+=- + 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 tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArguement +syn cluster tcshStatements contains=tcshBuiltin,tcshCommands,tcshIf,tcshWhile syn cluster tcshVarList contains=tcshUsrVar,tcshArgv,tcshSubst +syn cluster tcshConditions contains=tcshCmdSubst,tcshParenExpr,tcshOperator,tcshNumber,@tcshVarList + +" ----- Errors ----- +" Define first, so can be easily overridden. +syn match tcshError contained '\v\S.+' " ----- 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 +" Builtin commands except those treated specially. Currently (un)set(env), +" (un)alias, if, while, else, bindkey +syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg 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 +" StatementEnd is anything after a built-in / command till the lexical end of a " statement (;, |, ||, |&, && or end of line) -syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltins start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds +syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltin start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds " set expressions (Contains shell variables) syn keyword tcshShellVar contained afsuser ampm argv autocorrect autoexpand autolist autologout backslash_quote catalog cdpath color colorcat command complete continue continue_args correct cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit ellipsis fignore filec gid group histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version visiblebell watch who wordchars -syn keyword tcshSet nextgroup=tcshSetEnd set unset -syn region tcshSetEnd contained transparent matchgroup=tcshBuiltins start='' skip="\\$" end="$\|;" contains=tcshShellVar,@tcshStatementEnds +syn keyword tcshBuiltin nextgroup=tcshSetEnd set unset +syn region tcshSetEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshShellVar,@tcshStatementEnds -" setenv expressions (Contains enviorenment variables) +" setenv expressions (Contains environment variables) syn keyword tcshEnvVar contained AFSUSER COLUMNS DISPLAY EDITOR GROUP HOME HOST HOSTTYPE HPATH LANG LC_CTYPE LINES LS_COLORS MACHTYPE NOREBIND OSTYPE PATH PWD REMOTEHOST SHLVL SYSTYPE TERM TERMCAP USER VENDOR VISUAL -syn keyword tcshSetEnv nextgroup=tcshEnvEnd setenv unsetenv -syn region tcshEnvEnd contained transparent matchgroup=tcshBuiltins start='' skip="\\$" end="$\|;" contains=tcshEnvVar,@tcshStatementEnds +syn keyword tcshBuiltin nextgroup=tcshEnvEnd setenv unsetenv +syn region tcshEnvEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshEnvVar,@tcshStatementEnds " alias and unalias (contains special aliases) syn keyword tcshAliases contained beepcmd cwdcmd jobcmd helpcommand periodic precmd postcmd shell -syn keyword tcshAlias nextgroup=tcshAliCmd skipwhite alias unalias +syn keyword tcshBuiltin nextgroup=tcshAliCmd skipwhite alias unalias syn match tcshAliCmd contained nextgroup=tcshAliEnd skipwhite '\v[\w-]+' contains=tcshAliases -syn region tcshAliEnd contained transparent matchgroup=tcshBuiltins start='' skip="\\$" end="$\|;" contains=@tcshStatementEnds +syn region tcshAliEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=@tcshStatementEnds -" if statements (contains expressions / operators) -syn keyword tcshIf nextgroup=tcshIfEnd if -syn region tcshIfEnd contained matchgroup=tcshBuiltins start='' skip="\\$" end="\v<then>|$" contains=tcshOperator,tcshNumber,@tcshStatementEnds +" if statements +syn keyword tcshIf nextgroup=tcshIfEnd skipwhite if +syn region tcshIfEnd contained start='\S' skip='\\$' matchgroup=tcshBuiltin end='\v<then>|$' contains=@tcshConditions,tcshSpecial,@tcshStatementEnds +syn region tcshIfEnd contained matchgroup=tcshBuiltin contains=@tcshConditions,tcshSpecial start='(' end='\v\)%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds +syn region tcshIfEnd contained matchgroup=tcshBuiltin contains=tcshCommands,tcshSpecial start='\v\{\s+' end='\v\s+\}%(\s+then>)?' skipwhite nextgroup=@tcshStatementEnds keepend -" else statements (nextgroup if) -syn keyword tcshElse nextgroup=tcshIf skipwhite else +" else statements +syn keyword tcshBuiltin 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 +syn keyword tcshBuiltin nextgroup=@tcshConditions,tcshSpecial skipwhite while + +" Conditions (for if and while) +syn region tcshParenExpr contained contains=@tcshConditions,tcshSpecial matchgroup=tcshBuiltin start='(' end=')' +syn region tcshCmdSubst contained contains=tcshCommands matchgroup=tcshBuiltin start='\v\{\s+' end='\v\s+\}' keepend + +" Bindkey. Internal editor functions +syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char + \ backward-delete-word backward-kill-line backward-word + \ beginning-of-line capitalize-word change-case + \ change-till-end-of-line clear-screen complete-word + \ complete-word-fwd complete-word-back complete-word-raw + \ copy-prev-word copy-region-as-kill dabbrev-expand delete-char + \ delete-char-or-eof delete-char-or-list + \ delete-char-or-list-or-eof delete-word digit digit-argument + \ down-history downcase-word end-of-file end-of-line + \ exchange-point-and-mark expand-glob expand-history expand-line + \ expand-variables forward-char forward-word + \ gosmacs-transpose-chars history-search-backward + \ history-search-forward insert-last-word i-search-fwd + \ i-search-back keyboard-quit kill-line kill-region + \ kill-whole-line list-choices list-choices-raw list-glob + \ list-or-eof load-average magic-space newline normalize-path + \ normalize-command overwrite-mode prefix-meta quoted-insert + \ redisplay run-fg-editor run-help self-insert-command + \ sequence-lead-in set-mark-command spell-word spell-line + \ stuff-char toggle-literal-history transpose-chars + \ transpose-gosling tty-dsusp tty-flush-output tty-sigintr + \ tty-sigquit tty-sigtsusp tty-start-output tty-stop-output + \ undefined-key universal-argument up-history upcase-word + \ vi-beginning-of-next-word vi-add vi-add-at-eol vi-chg-case + \ vi-chg-meta vi-chg-to-eol vi-cmd-mode vi-cmd-mode-complete + \ vi-delprev vi-delmeta vi-endword vi-eword vi-char-back + \ vi-char-fwd vi-charto-back vi-charto-fwd vi-insert + \ vi-insert-at-bol vi-repeat-char-fwd vi-repeat-char-back + \ vi-repeat-search-fwd vi-repeat-search-back vi-replace-char + \ vi-replace-mode vi-search-back vi-search-fwd vi-substitute-char + \ vi-substitute-line vi-word-back vi-word-fwd vi-undo vi-zero + \ which-command yank yank-pop e_copy_to_clipboard + \ e_paste_from_clipboard e_dosify_next e_dosify_prev e_page_up + \ e_page_down +syn keyword tcshBuiltin nextgroup=tcshBindkeyEnd bindkey +syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArguement,tcshBindkeyFuncs " 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 +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=@tcshConditions +syn match tcshExprEnd contained '\v.{-};'hs=e contains=@tcshConditions " ----- Comments: ----- syn match tcshComment '#\s.*' contains=tcshTodo,tcshCommentTi,@Spell @@ -85,12 +138,12 @@ syn match tcshTodo contained '\v\c<todo>' " 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\\@<!'" end="'" contains=@Spell +if(exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0) + syn region tcshSQuote keepend contained start="\v\\@<!'" end="'" syn region tcshDQuote keepend contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell syn region tcshBQuote keepend start='\v\\@<!`' end='`' contains=@tcshStatements else - syn region tcshSQuote contained start="\v\\@<!'" skip="\v\\\\|\\'" end="'" contains=@Spell + syn region tcshSQuote contained start="\v\\@<!'" skip="\v\\\\|\\'" end="'" syn region tcshDQuote contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='\v\\@<!`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements endif @@ -101,17 +154,17 @@ endif syn match tcshVarError '\v\$\S*' contained " Modifiable Variables without {}. -syn match tcshUsrVar contained "\v\$\h\w*%(\[\d+%(-\d+)?\])?" nextgroup=@tcshModifiers contains=tcshShellVar,tcshEnvVar -syn match tcshArgv contained "\v\$%(\d+|\*)" nextgroup=@tcshModifiers +syn match tcshUsrVar contained '\v\$\h\w*%(\[\d+%(-\d+)?\])?' nextgroup=@tcshModifiers contains=tcshShellVar,tcshEnvVar +syn match tcshArgv contained '\v\$%(\d+|\*)' nextgroup=@tcshModifiers " Modifiable Variables with {}. -syn match tcshUsrVar contained "\v\$\{\h\w*%(\[\d+%(-\d+)?\])?%(:\S*)?\}" contains=@tcshModifiers,tcshShellVar,tcshEnvVar -syn match tcshArgv contained "\v\$\{%(\d+|\*)%(:\S*)?\}" contains=@tcshModifiers +syn match tcshUsrVar contained '\v\$\{\h\w*%(\[\d+%(-\d+)?\])?%(:\S*)?\}' contains=@tcshModifiers,tcshShellVar,tcshEnvVar +syn match tcshArgv contained '\v\$\{%(\d+|\*)%(:\S*)?\}' contains=@tcshModifiers -" UnModifiable Substitutions. Order is important here. -syn match tcshSubst contained "\v\$[?#$!_<]" nextgroup=tcshModifierError -syn match tcshSubst contained "\v\$[%#?]%(\h\w*|\d+)" nextgroup=tcshModifierError contains=tcshShellVar,tcshEnvVar -syn match tcshSubst contained "\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}" contains=tcshModifierError contains=tcshShellVar,tcshEnvVar +" Un-modifiable Substitutions. Order is important here. +syn match tcshSubst contained '\v\$[?#$!_<]' nextgroup=tcshModifierError +syn match tcshSubst contained '\v\$[%#?]%(\h\w*|\d+)' nextgroup=tcshModifierError contains=tcshShellVar,tcshEnvVar +syn match tcshSubst contained '\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}' contains=tcshModifierError contains=tcshShellVar,tcshEnvVar " Variable Name Expansion Modifiers (order important) syn match tcshModifierError contained '\v:\S*' @@ -119,61 +172,60 @@ syn match tcshModifier contained '\v:[ag]?[htreuls&qx]' nextgroup=@tcshModifier " ----- Operators / Specials ----- " Standard redirects (except <<) [<, >, >>, >>&, >>!, >>&!] -syn match tcshRedir contained "\v\<|\>\>?\&?!?" +syn match tcshRedir contained '\v\<|\>\>?\&?!?' -" Metachars -syn match tcshMeta contained "\v[]{}*?[]" +" Meta-chars +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$" +" Here documents (<<) +syn region tcshHereDoc contained matchgroup=tcshShellVar start='\v\<\<\s*\z(\h\w*)' end='^\z1$' contains=@tcshVarList,tcshSpecial +syn region tcshHereDoc contained matchgroup=tcshShellVar 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 "[(){}]" +syn match tcshOperator contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||' +"syn match tcshOperator contained '[(){}]' " Numbers -syn match tcshNumber contained "\v<-?\d+>" +syn match tcshNumber contained '\v<-?\d+>' -" Arguements -syn match tcshArguement contained "\v\s@<=-(\w|-)*" +" Arguments +syn match tcshArguement contained '\v\s@<=-(\w|-)*' -" Special charectors -syn match tcshSpecial contained "\v\\@<!\\(\d{3}|.)" +" Special characters. \xxx, or backslashed characters. +"syn match tcshSpecial contained '\v\\@<!\\(\d{3}|.)' +syn match tcshSpecial contained '\v\\%([0-7]{3}|.)' -" ----- Syncronising ----- -if exists("tcsh_minlines") - exec "syn sync minlines=" . tcsh_minlines +" ----- Synchronising ----- +if exists('tcsh_minlines') + exec 'syn sync minlines=' . tcsh_minlines else - syn sync minlines=15 " Except 'here' documents, nothing is long + syn sync minlines=100 " Some completions can be quite long endif " Define highlighting of syntax groups -hi def link tcshBuiltins statement -hi def link tcshShellVar preproc +hi def link tcshError Error +hi def link tcshBuiltin Statement +hi def link tcshShellVar Preproc hi def link tcshEnvVar tcshShellVar hi def link tcshAliases tcshShellVar -hi def link tcshAliCmd identifier -hi def link tcshCommands identifier -hi def link tcshSet tcshBuiltins -hi def link tcshSetEnv tcshBuiltins -hi def link tcshAlias tcshBuiltins -hi def link tcshIf tcshBuiltins -hi def link tcshElse tcshBuiltins -hi def link tcshWhile tcshBuiltins -hi def link tcshExprStart tcshBuiltins +hi def link tcshAliCmd Identifier +hi def link tcshCommands Identifier +hi def link tcshIf tcshBuiltin +hi def link tcshWhile tcshBuiltin +hi def link tcshBindkeyFuncs Function +hi def link tcshExprStart tcshBuiltin hi def link tcshExprVar tcshUsrVar hi def link tcshExprOp tcshOperator hi def link tcshExprEnd tcshOperator -hi def link tcshComment comment -hi def link tcshCommentTi preproc +hi def link tcshComment Comment +hi def link tcshCommentTi Preproc hi def link tcshSharpBang tcshCommentTi -hi def link tcshTodo todo -hi def link tcshSQuote constant +hi def link tcshTodo Todo +hi def link tcshSQuote Constant hi def link tcshDQuote tcshSQuote -hi def link tcshBQuoteGrp include -hi def link tcshVarError error -hi def link tcshUsrVar type +hi def link tcshBQuoteGrp Include +hi def link tcshVarError Error +hi def link tcshUsrVar Type hi def link tcshArgv tcshUsrVar hi def link tcshSubst tcshUsrVar hi def link tcshModifier tcshArguement @@ -181,9 +233,12 @@ hi def link tcshModifierError tcshVarError hi def link tcshMeta tcshSubst hi def link tcshRedir tcshOperator hi def link tcshHereDoc tcshSQuote -hi def link tcshOperator operator -hi def link tcshNumber number -hi def link tcshArguement special -hi def link tcshSpecial specialchar +hi def link tcshOperator Operator +hi def link tcshNumber Number +hi def link tcshArguement Special +hi def link tcshSpecial SpecialChar + +let &cpo = s:oldcpo +unlet s:oldcpo -let b:current_syntax = "tcsh" +let b:current_syntax = 'tcsh' |