home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / share / vim / syntax / csh.vim < prev    next >
Encoding:
Text File  |  1999-08-10  |  5.9 KB  |  136 lines

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