home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim60.zip / vim60rt2.zip / vim / vim60 / syntax / csh.vim < prev    next >
Encoding:
Text File  |  2001-09-26  |  6.7 KB  |  162 lines

  1. " Vim syntax file
  2. " Language:    C-shell (csh)
  3. " Maintainer:    Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>
  4. " Version:    1.02
  5. " Last Change:    September 19, 2000
  6.  
  7. " For version 5.x: Clear all syntax items
  8. " For version 6.x: Quit when a syntax file was already loaded
  9. if version < 600
  10.   syntax clear
  11. elseif exists("b:current_syntax")
  12.   finish
  13. endif
  14.  
  15. " clusters:
  16. syn cluster cshQuoteList    contains=cshDblQuote,cshSnglQuote,cshBckQuote
  17.  
  18. " Variables which affect the csh itself
  19. syn match cshSetVariables    contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status"
  20. syn match cshSetVariables    contained "cdpath\|history\|mail\|nonomatch\|savehist\|time"
  21. syn match cshSetVariables    contained "cwd\|home\|noclobber\|path\|shell\|verbose"
  22. syn match cshSetVariables    contained "echo"
  23.  
  24. syn case ignore
  25. syn keyword cshTodo    contained todo
  26. syn case match
  27.  
  28. " Variable Name Expansion Modifiers
  29. syn match cshModifier    contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  30.  
  31. " Strings and Comments
  32. syn match   cshNoEndlineDQ    contained "[^\"]\(\\\\\)*$"
  33. syn match   cshNoEndlineSQ    contained "[^\']\(\\\\\)*$"
  34. syn match   cshNoEndlineBQ    contained "[^\`]\(\\\\\)*$"
  35.  
  36. syn region  cshDblQuote    start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+    contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote
  37. syn region  cshSnglQuote    start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+    contains=cshNoEndlineSQ
  38. syn region  cshBckQuote    start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+    contains=cshNoEndlineBQ
  39. syn region  cshDblQuote    start=+^"+ skip=+\\\\\|\\"+ end=+"+        contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ
  40. syn region  cshSnglQuote    start=+^'+ skip=+\\\\\|\\'+ end=+'+        contains=cshNoEndlineSQ
  41. syn region  cshBckQuote    start=+^`+ skip=+\\\\\|\\`+ end=+`+        contains=cshNoEndlineBQ
  42. syn cluster cshCommentGroup    contains=cshTodo
  43. syn match   cshComment    "#.*$" contains=@cshCommentGroup
  44.  
  45. " A bunch of useful csh keywords
  46. syn keyword cshStatement    alias    end    history    onintr    setenv    unalias
  47. syn keyword cshStatement    cd    eval    kill    popd    shift    unhash
  48. syn keyword cshStatement    chdir    exec    login    pushd    source
  49. syn keyword cshStatement    continue    exit    logout    rehash    time    unsetenv
  50. syn keyword cshStatement    dirs    glob    nice    repeat    umask    wait
  51. syn keyword cshStatement    echo    goto    nohup
  52.  
  53. syn keyword cshConditional    break    case    else    endsw    switch
  54. syn keyword cshConditional    breaksw    default    endif
  55. syn keyword cshRepeat    foreach
  56.  
  57. " Special environment variables
  58. syn keyword cshShellVariables    HOME    LOGNAME    PATH    TERM    USER
  59.  
  60. " Modifiable Variables without {}
  61. syn match cshExtVar    "\$[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\="        contains=cshModifier
  62. syn match cshSelector    "\$[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\="    contains=cshModifier
  63. syn match cshQtyWord    "\$#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\="        contains=cshModifier
  64. syn match cshArgv    "\$\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\="            contains=cshModifier
  65. syn match cshArgv    "\$\*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\="            contains=cshModifier
  66.  
  67. " Modifiable Variables with {}
  68. syn match cshExtVar    "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}"        contains=cshModifier
  69. syn match cshSelector    "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}"    contains=cshModifier
  70. syn match cshQtyWord    "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}"    contains=cshModifier
  71. syn match cshArgv    "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}"            contains=cshModifier
  72.  
  73. " UnModifiable Substitutions
  74. syn match cshSubstError    "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  75. syn match cshSubstError    "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}"
  76. syn match cshSubstError    "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  77. syn match cshSubst    "\$?[a-zA-Z_][a-zA-Z0-9_]*"
  78. syn match cshSubst    "\${?[a-zA-Z_][a-zA-Z0-9_]*}"
  79. syn match cshSubst    "\$?[0$<]"
  80.  
  81. " I/O redirection
  82. syn match cshRedir    ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<"
  83.  
  84. " Handle set expressions
  85. syn keyword cshSetStmt    contained set unset
  86. syn region  cshSetExpr    transparent start="set\|unset" end="$\|;" contains=cshSetVariables,cshSetStmt,@cshQuoteList
  87.  
  88. " Operators and Expression-Using constructs
  89. syn keyword cshExprUsing    contained if while exit then
  90. syn match   cshOperator    contained "\(&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||\)"
  91. syn match   cshOperator    contained "[(){}]"
  92. syn region  cshTest    transparent start="if\|while\|exit" skip="\\$" end="$\|;\|then" contains=cshOperator,cshExprUsing,@cshQuoteList
  93.  
  94.  
  95. " Highlight special characters (those which have a backslash) differently
  96. syn match cshSpecial    contained "\\\d\d\d\|\\[abcfnrtv\\]"
  97. syn match cshNumber    "-\=\<\d\+\>"
  98.  
  99. " All other identifiers
  100. "syn match cshIdentifier    "\<[a-zA-Z._][a-zA-Z0-9._]*\>"
  101.  
  102. " Shell Input Redirection (Here Documents)
  103. if version < 600
  104.   syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**END[a-zA-Z_0-9]*\**" matchgroup=cshRedir end="^END[a-zA-Z_0-9]*$"
  105.   syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**EOF\**" matchgroup=cshRedir end="^EOF$"
  106. else
  107.   syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$"
  108. endif
  109.  
  110. " Define the default highlighting.
  111. " For version 5.7 and earlier: only when not done already
  112. " For version 5.8 and later: only when an item doesn't have highlighting yet
  113. if version >= 508 || !exists("did_csh_syntax_inits")
  114.   if version < 508
  115.     let did_csh_syntax_inits = 1
  116.     command -nargs=+ HiLink hi link <args>
  117.   else
  118.     command -nargs=+ HiLink hi def link <args>
  119.   endif
  120.  
  121.   HiLink cshArgv        cshVariables
  122.   HiLink cshBckQuote    cshCommand
  123.   HiLink cshDblQuote    cshString
  124.   HiLink cshExprUsing    cshStatement
  125.   HiLink cshExtVar    cshVariables
  126.   HiLink cshHereDoc    cshString
  127.   HiLink cshNoEndlineBQ    cshNoEndline
  128.   HiLink cshNoEndlineDQ    cshNoEndline
  129.   HiLink cshNoEndlineSQ    cshNoEndline
  130.   HiLink cshQtyWord    cshVariables
  131.   HiLink cshRedir        cshOperator
  132.   HiLink cshSelector    cshVariables
  133.   HiLink cshSetStmt    cshStatement
  134.   HiLink cshSetVariables    cshVariables
  135.   HiLink cshSnglQuote    cshString
  136.   HiLink cshSubst        cshVariables
  137.  
  138.   HiLink cshCommand    Statement
  139.   HiLink cshComment    Comment
  140.   HiLink cshConditional    Conditional
  141.   HiLink cshIdentifier    Error
  142.   HiLink cshModifier    Special
  143.   HiLink cshNoEndline    Error
  144.   HiLink cshNumber    Number
  145.   HiLink cshOperator    Operator
  146.   HiLink cshRedir        Statement
  147.   HiLink cshRepeat    Repeat
  148.   HiLink cshShellVariables    Special
  149.   HiLink cshSpecial    Special
  150.   HiLink cshStatement    Statement
  151.   HiLink cshString    String
  152.   HiLink cshSubstError    Error
  153.   HiLink cshTodo        Todo
  154.   HiLink cshVariables    Type
  155.  
  156.   delcommand HiLink
  157. endif
  158.  
  159. let b:current_syntax = "csh"
  160.  
  161. " vim: ts=18
  162.