btm.vim 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. " Vim syntax file
  2. " Language: 4Dos batch file
  3. " Maintainer: John Leo Spetz <jls11@po.cwru.edu>
  4. " Last Change: 2001 May 09
  5. "//Issues to resolve:
  6. "//- Boolean operators surrounded by period are recognized but the
  7. "// periods are not highlighted. The only way to do that would
  8. "// be separate synmatches for each possibility otherwise a more
  9. "// general \.\i\+\. will highlight anything delimited by dots.
  10. "//- After unary operators like "defined" can assume token type.
  11. "// Should there be more of these?
  12. " quit when a syntax file was already loaded
  13. if exists("b:current_syntax")
  14. finish
  15. endif
  16. syn case ignore
  17. syn keyword btmStatement call off
  18. syn keyword btmConditional if iff endiff then else elseiff not errorlevel
  19. syn keyword btmConditional gt lt eq ne ge le
  20. syn match btmConditional transparent "\.\i\+\." contains=btmDotBoolOp
  21. syn keyword btmDotBoolOp contained and or xor
  22. syn match btmConditional "=="
  23. syn match btmConditional "!="
  24. syn keyword btmConditional defined errorlevel exist isalias
  25. syn keyword btmConditional isdir direxist isinternal islabel
  26. syn keyword btmRepeat for in do enddo
  27. syn keyword btmTodo contained TODO
  28. " String
  29. syn cluster btmVars contains=btmVariable,btmArgument,btmBIFMatch
  30. syn region btmString start=+"+ end=+"+ contains=@btmVars
  31. syn match btmNumber "\<\d\+\>"
  32. "syn match btmIdentifier "\<\h\w*\>"
  33. " If you don't like tabs
  34. "syn match btmShowTab "\t"
  35. "syn match btmShowTabc "\t"
  36. "syn match btmComment "^\ *rem.*$" contains=btmTodo,btmShowTabc
  37. " Some people use this as a comment line
  38. " In fact this is a Label
  39. "syn match btmComment "^\ *:\ \+.*$" contains=btmTodo
  40. syn match btmComment "^\ *rem.*$" contains=btmTodo
  41. syn match btmComment "^\ *::.*$" contains=btmTodo
  42. syn match btmLabelMark "^\ *:[0-9a-zA-Z_\-]\+\>"
  43. syn match btmLabelMark "goto [0-9a-zA-Z_\-]\+\>"lc=5
  44. syn match btmLabelMark "gosub [0-9a-zA-Z_\-]\+\>"lc=6
  45. " syn match btmCmdDivider ">[>&][>&]\="
  46. syn match btmCmdDivider ">[>&]*"
  47. syn match btmCmdDivider ">>&>"
  48. syn match btmCmdDivider "|&\="
  49. syn match btmCmdDivider "%+"
  50. syn match btmCmdDivider "\^"
  51. syn region btmEcho start="echo" skip="echo" matchgroup=btmCmdDivider end="%+" end="$" end="|&\=" end="\^" end=">[>&]*" contains=@btmEchos oneline
  52. syn cluster btmEchos contains=@btmVars,btmEchoCommand,btmEchoParam
  53. syn keyword btmEchoCommand contained echo echoerr echos echoserr
  54. syn keyword btmEchoParam contained on off
  55. " this is also a valid Label. I don't use it.
  56. "syn match btmLabelMark "^\ *:\ \+[0-9a-zA-Z_\-]\+\>"
  57. " //Environment variable can be expanded using notation %var in 4DOS
  58. syn match btmVariable "%[0-9a-z_\-]\+" contains=@btmSpecialVars
  59. " //Environment variable can be expanded using notation %var%
  60. syn match btmVariable "%[0-9a-z_\-]*%" contains=@btmSpecialVars
  61. " //The following are special variable in 4DOS
  62. syn match btmVariable "%[=#]" contains=@btmSpecialVars
  63. syn match btmVariable "%??\=" contains=@btmSpecialVars
  64. " //Environment variable can be expanded using notation %[var] in 4DOS
  65. syn match btmVariable "%\[[0-9a-z_\-]*\]"
  66. " //After some keywords next word should be an environment variable
  67. syn match btmVariable "defined\s\i\+"lc=8
  68. syn match btmVariable "set\s\i\+"lc=4
  69. " //Parameters to batchfiles take the format %<digit>
  70. syn match btmArgument "%\d\>"
  71. " //4DOS allows format %<digit>& meaning batchfile parameters digit and up
  72. syn match btmArgument "%\d\>&"
  73. " //Variable used by FOR loops sometimes use %%<letter> in batchfiles
  74. syn match btmArgument "%%\a\>"
  75. " //Show 4DOS built-in functions specially
  76. syn match btmBIFMatch "%@\w\+\["he=e-1 contains=btmBuiltInFunc
  77. syn keyword btmBuiltInFunc contained alias ascii attrib cdrom
  78. syn keyword btmBuiltInFunc contained char clip comma convert
  79. syn keyword btmBuiltInFunc contained date day dec descript
  80. syn keyword btmBuiltInFunc contained device diskfree disktotal
  81. syn keyword btmBuiltInFunc contained diskused dosmem dow dowi
  82. syn keyword btmBuiltInFunc contained doy ems eval exec execstr
  83. syn keyword btmBuiltInFunc contained expand ext extended
  84. syn keyword btmBuiltInFunc contained fileage fileclose filedate
  85. syn keyword btmBuiltInFunc contained filename fileopen fileread
  86. syn keyword btmBuiltInFunc contained files fileseek fileseekl
  87. syn keyword btmBuiltInFunc contained filesize filetime filewrite
  88. syn keyword btmBuiltInFunc contained filewriteb findclose
  89. syn keyword btmBuiltInFunc contained findfirst findnext format
  90. syn keyword btmBuiltInFunc contained full if inc index insert
  91. syn keyword btmBuiltInFunc contained instr int label left len
  92. syn keyword btmBuiltInFunc contained lfn line lines lower lpt
  93. syn keyword btmBuiltInFunc contained makeage makedate maketime
  94. syn keyword btmBuiltInFunc contained master month name numeric
  95. syn keyword btmBuiltInFunc contained path random readscr ready
  96. syn keyword btmBuiltInFunc contained remote removable repeat
  97. syn keyword btmBuiltInFunc contained replace right search
  98. syn keyword btmBuiltInFunc contained select sfn strip substr
  99. syn keyword btmBuiltInFunc contained time timer trim truename
  100. syn keyword btmBuiltInFunc contained unique upper wild word
  101. syn keyword btmBuiltInFunc contained words xms year
  102. syn cluster btmSpecialVars contains=btmBuiltInVar,btmSpecialVar
  103. " //Show specialized variables specially
  104. " syn match btmSpecialVar contained "+"
  105. syn match btmSpecialVar contained "="
  106. syn match btmSpecialVar contained "#"
  107. syn match btmSpecialVar contained "??\="
  108. syn keyword btmSpecialVar contained cmdline colordir comspec
  109. syn keyword btmSpecialVar contained copycmd dircmd temp temp4dos
  110. syn keyword btmSpecialVar contained filecompletion path prompt
  111. " //Show 4DOS built-in variables specially specially
  112. syn keyword btmBuiltInVar contained _4ver _alias _ansi
  113. syn keyword btmBuiltInVar contained _apbatt _aplife _apmac _batch
  114. syn keyword btmBuiltInVar contained _batchline _batchname _bg
  115. syn keyword btmBuiltInVar contained _boot _ci _cmdproc _co
  116. syn keyword btmBuiltInVar contained _codepage _column _columns
  117. syn keyword btmBuiltInVar contained _country _cpu _cwd _cwds _cwp
  118. syn keyword btmBuiltInVar contained _cwps _date _day _disk _dname
  119. syn keyword btmBuiltInVar contained _dos _dosver _dow _dowi _doy
  120. syn keyword btmBuiltInVar contained _dpmi _dv _env _fg _hlogfile
  121. syn keyword btmBuiltInVar contained _hour _kbhit _kstack _lastdisk
  122. syn keyword btmBuiltInVar contained _logfile _minute _monitor
  123. syn keyword btmBuiltInVar contained _month _mouse _ndp _row _rows
  124. syn keyword btmBuiltInVar contained _second _shell _swapping
  125. syn keyword btmBuiltInVar contained _syserr _time _transient
  126. syn keyword btmBuiltInVar contained _video _win _wintitle _year
  127. " //Commands in 4DOS and/or DOS
  128. syn match btmCommand "\s?"
  129. syn match btmCommand "^?"
  130. syn keyword btmCommand alias append assign attrib
  131. syn keyword btmCommand backup beep break cancel case
  132. syn keyword btmCommand cd cdd cdpath chcp chdir
  133. syn keyword btmCommand chkdsk cls color comp copy
  134. syn keyword btmCommand ctty date debug default defrag
  135. syn keyword btmCommand del delay describe dir
  136. syn keyword btmCommand dirhistory dirs diskcomp
  137. syn keyword btmCommand diskcopy doskey dosshell
  138. syn keyword btmCommand drawbox drawhline drawvline
  139. "syn keyword btmCommand echo echoerr echos echoserr
  140. syn keyword btmCommand edit edlin emm386 endlocal
  141. syn keyword btmCommand endswitch erase eset except
  142. syn keyword btmCommand exe2bin exit expand fastopen
  143. syn keyword btmCommand fc fdisk ffind find format
  144. syn keyword btmCommand free global gosub goto
  145. syn keyword btmCommand graftabl graphics help history
  146. syn keyword btmCommand inkey input join keyb keybd
  147. syn keyword btmCommand keystack label lh list loadbtm
  148. syn keyword btmCommand loadhigh lock log md mem
  149. syn keyword btmCommand memory mirror mkdir mode more
  150. syn keyword btmCommand move nlsfunc on option path
  151. syn keyword btmCommand pause popd print prompt pushd
  152. syn keyword btmCommand quit rd reboot recover ren
  153. syn keyword btmCommand rename replace restore return
  154. syn keyword btmCommand rmdir scandisk screen scrput
  155. syn keyword btmCommand select set setdos setlocal
  156. syn keyword btmCommand setver share shift sort subst
  157. syn keyword btmCommand swapping switch sys tee text
  158. syn keyword btmCommand time timer touch tree truename
  159. syn keyword btmCommand type unalias undelete unformat
  160. syn keyword btmCommand unlock unset ver verify vol
  161. syn keyword btmCommand vscrput y
  162. " Define the default highlighting.
  163. " Only when an item doesn't have highlighting yet
  164. hi def link btmLabel Special
  165. hi def link btmLabelMark Special
  166. hi def link btmCmdDivider Special
  167. hi def link btmConditional btmStatement
  168. hi def link btmDotBoolOp btmStatement
  169. hi def link btmRepeat btmStatement
  170. hi def link btmEchoCommand btmStatement
  171. hi def link btmEchoParam btmStatement
  172. hi def link btmStatement Statement
  173. hi def link btmTodo Todo
  174. hi def link btmString String
  175. hi def link btmNumber Number
  176. hi def link btmComment Comment
  177. hi def link btmArgument Identifier
  178. hi def link btmVariable Identifier
  179. hi def link btmEcho String
  180. hi def link btmBIFMatch btmStatement
  181. hi def link btmBuiltInFunc btmStatement
  182. hi def link btmBuiltInVar btmStatement
  183. hi def link btmSpecialVar btmStatement
  184. hi def link btmCommand btmStatement
  185. "optional highlighting
  186. "hi def link btmShowTab Error
  187. "hi def link btmShowTabc Error
  188. "hi def link btmIdentifier Identifier
  189. let b:current_syntax = "btm"
  190. " vim: ts=8