csh.vim 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. " Vim syntax file
  2. " Language: C-shell (csh)
  3. " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
  4. " Last Change: Aug 31, 2016
  5. " Version: 13
  6. " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH
  7. " quit when a syntax file was already loaded
  8. if exists("b:current_syntax")
  9. finish
  10. endif
  11. " clusters:
  12. syn cluster cshQuoteList contains=cshDblQuote,cshSnglQuote,cshBckQuote
  13. syn cluster cshVarList contains=cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst
  14. " Variables which affect the csh itself
  15. syn match cshSetVariables contained "argv\|histchars\|ignoreeof\|noglob\|prompt\|status"
  16. syn match cshSetVariables contained "cdpath\|history\|mail\|nonomatch\|savehist\|time"
  17. syn match cshSetVariables contained "cwd\|home\|noclobber\|path\|shell\|verbose"
  18. syn match cshSetVariables contained "echo"
  19. syn case ignore
  20. syn keyword cshTodo contained todo
  21. syn case match
  22. " Variable Name Expansion Modifiers
  23. syn match cshModifier contained ":\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  24. " Strings and Comments
  25. syn match cshNoEndlineDQ contained "[^\"]\(\\\\\)*$"
  26. syn match cshNoEndlineSQ contained "[^\']\(\\\\\)*$"
  27. syn match cshNoEndlineBQ contained "[^\`]\(\\\\\)*$"
  28. syn region cshDblQuote start=+[^\\]"+lc=1 skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshShellVariables,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,cshBckQuote,@Spell
  29. syn region cshSnglQuote start=+[^\\]'+lc=1 skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
  30. syn region cshBckQuote start=+[^\\]`+lc=1 skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
  31. syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial,cshExtVar,cshSelector,cshQtyWord,cshArgv,cshSubst,cshNoEndlineDQ,@Spell
  32. syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
  33. syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
  34. syn cluster cshCommentGroup contains=cshTodo,@Spell
  35. syn match cshComment "#.*$" contains=@cshCommentGroup
  36. " A bunch of useful csh keywords
  37. syn keyword cshStatement alias end history onintr setenv unalias
  38. syn keyword cshStatement cd eval kill popd shift unhash
  39. syn keyword cshStatement chdir exec login pushd source
  40. syn keyword cshStatement continue exit logout rehash time unsetenv
  41. syn keyword cshStatement dirs glob nice repeat umask wait
  42. syn keyword cshStatement echo goto nohup
  43. syn keyword cshConditional break case else endsw switch
  44. syn keyword cshConditional breaksw default endif
  45. syn keyword cshRepeat foreach
  46. " Special environment variables
  47. syn keyword cshShellVariables HOME LOGNAME PATH TERM USER
  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. " Modifiable Variables with {}
  55. syn match cshExtVar "\${[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
  56. syn match cshSelector "\${[a-zA-Z_][a-zA-Z0-9_]*\[[a-zA-Z_]\+\]\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
  57. syn match cshQtyWord "\${#[a-zA-Z_][a-zA-Z0-9_]*\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
  58. syn match cshArgv "\${\d\+\(:h\|:t\|:r\|:q\|:x\|:gh\|:gt\|:gr\)\=}" contains=cshModifier
  59. " UnModifiable Substitutions
  60. syn match cshSubstError "\$?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  61. syn match cshSubstError "\${?[a-zA-Z_][a-zA-Z0-9_]*:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)}"
  62. syn match cshSubstError "\$?[0$<]:\(h\|t\|r\|q\|x\|gh\|gt\|gr\)"
  63. syn match cshSubst "\$?[a-zA-Z_][a-zA-Z0-9_]*"
  64. syn match cshSubst "\${?[a-zA-Z_][a-zA-Z0-9_]*}"
  65. syn match cshSubst "\$?[0$<]"
  66. " I/O redirection
  67. syn match cshRedir ">>&!\|>&!\|>>&\|>>!\|>&\|>!\|>>\|<<\|>\|<"
  68. " Handle set expressions
  69. syn region cshSetExpr matchgroup=cshSetStmt start="\<set\>\|\<unset\>" end="$\|;" contains=cshComment,cshSetStmt,cshSetVariables,@cshQuoteList
  70. " Operators and Expression-Using constructs
  71. "syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|\|%\|&\|+\|-\|/\|<\|>\||"
  72. syn match cshOperator contained "&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||"
  73. syn match cshOperator contained "[(){}]"
  74. syn region cshTest matchgroup=cshStatement start="\<if\>\|\<while\>" skip="\\$" matchgroup=cshStatement end="\<then\>\|$" contains=cshComment,cshOperator,@cshQuoteList,@cshVarLIst
  75. " Highlight special characters (those which have a backslash) differently
  76. syn match cshSpecial contained "\\\d\d\d\|\\[abcfnrtv\\]"
  77. syn match cshNumber "-\=\<\d\+\>"
  78. " All other identifiers
  79. "syn match cshIdentifier "\<[a-zA-Z._][a-zA-Z0-9._]*\>"
  80. " Shell Input Redirection (Here Documents)
  81. syn region cshHereDoc matchgroup=cshRedir start="<<-\=\s*\**\z(\h\w*\)\**" matchgroup=cshRedir end="^\z1$"
  82. " Define the default highlighting.
  83. if !exists("skip_csh_syntax_inits")
  84. hi def link cshArgv cshVariables
  85. hi def link cshBckQuote cshCommand
  86. hi def link cshDblQuote cshString
  87. hi def link cshExtVar cshVariables
  88. hi def link cshHereDoc cshString
  89. hi def link cshNoEndlineBQ cshNoEndline
  90. hi def link cshNoEndlineDQ cshNoEndline
  91. hi def link cshNoEndlineSQ cshNoEndline
  92. hi def link cshQtyWord cshVariables
  93. hi def link cshRedir cshOperator
  94. hi def link cshSelector cshVariables
  95. hi def link cshSetStmt cshStatement
  96. hi def link cshSetVariables cshVariables
  97. hi def link cshSnglQuote cshString
  98. hi def link cshSubst cshVariables
  99. hi def link cshCommand Statement
  100. hi def link cshComment Comment
  101. hi def link cshConditional Conditional
  102. hi def link cshIdentifier Error
  103. hi def link cshModifier Special
  104. hi def link cshNoEndline Error
  105. hi def link cshNumber Number
  106. hi def link cshOperator Operator
  107. hi def link cshRedir Statement
  108. hi def link cshRepeat Repeat
  109. hi def link cshShellVariables Special
  110. hi def link cshSpecial Special
  111. hi def link cshStatement Statement
  112. hi def link cshString String
  113. hi def link cshSubstError Error
  114. hi def link cshTodo Todo
  115. hi def link cshVariables Type
  116. endif
  117. let b:current_syntax = "csh"
  118. " vim: ts=18