tt.vim 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. " VIM Syntax file for tintin++ scripts
  2. " TODO
  3. " Add proper support for #chat
  4. " Add proper support for #map
  5. " Finish support for #buffer get
  6. " Make Better use of Clusters
  7. " Porper #script support, I feel none is better than the fragile support from
  8. " before
  9. " Test vs various code styles
  10. " Add bad syntax highlights to ttError
  11. if version < 600
  12. syntax clear
  13. elseif exists("b:current_syntax")
  14. finish
  15. endif
  16. " Sets the '#' character as a valid keyword character
  17. setlocal iskeyword+=#
  18. " tintin++ keywords are case insensitive
  19. syntax case ignore
  20. " Increase minlines to avoid highlighting errors
  21. syntax sync minlines=200
  22. " tintin++ Commands {{{
  23. " Kill: #kill #killall {{{
  24. syntax keyword ttCmd #kill
  25. \ nextgroup=ttListNameKill
  26. \ skipwhite skipempty
  27. syntax keyword ttCmd #killall
  28. \ nextgroup=ttListName
  29. \ skipwhite skipempty
  30. " }}}
  31. " Debugging: #ignore #debug #message {{{
  32. syntax keyword ttCmdDebug #ignore #debug #message
  33. \ nextgroup=ttListName,ttListNameBlock
  34. \ skipwhite skipempty
  35. " }}}
  36. " Useless For Scripting: #grep #help #greeting #info {{{
  37. syntax keyword ttCmdUseless #grep #help #greeting #info
  38. " }}}
  39. " Misc tintin commands: #cr #bell #send #split #system #config #pathdir {{{
  40. syntax keyword ttCmd #cr #bell
  41. syntax keyword ttCmd #send
  42. \ nextgroup=ttValueBlock
  43. \ skipwhite skipempty
  44. syntax keyword ttCmd #split
  45. \ nextgroup=ttSplitValueBlock
  46. \ skipwhite skipempty
  47. syntax keyword ttCmd #system
  48. \ nextgroup=ttShellCmd
  49. \ skipwhite skipempty
  50. syntax keyword ttCmd #config
  51. \ nextgroup=ttConfigBlock
  52. \ skipwhite skipempty
  53. syntax keyword ttCmd #pathdir #unpathdir
  54. " }}}
  55. " End/Suspend: #end #suspend #zap {{{
  56. syntax keyword ttCmd #end #suspend
  57. syntax keyword ttCmd #zap
  58. \ nextgroup=ttSessionName,ttSessionNameBlock
  59. \ skipwhite skipempty
  60. " }}}
  61. " Session Related: #all #gts #snoop #session #run {{{
  62. syntax keyword ttCmd #all #gts
  63. syntax match ttCmd "\c#{gts}"
  64. syntax keyword ttCmd #snoop
  65. \ nextgroup=ttSessionName,ttSessionNameBlock
  66. \ skipwhite skipempty
  67. syntax keyword ttCmd #ses[sion]
  68. \ nextgroup=ttSesSessionNameBlock,ttSesSessionName
  69. \ skipwhite skipempty
  70. syntax keyword ttCmd #run
  71. \ nextgroup=ttRunSessionNameBlock,ttRunSessionName
  72. \ skipwhite skipempty
  73. " }}}
  74. " Looping Commands #while #loop #forall #foreach #parse #break #continue {{{
  75. syntax keyword ttCmdLoop #break #continue
  76. syntax keyword ttCmdLoop #while
  77. \ nextgroup=ttExpressionBlock
  78. \ skipwhite skipempty
  79. syntax keyword ttCmdLoop #forall
  80. \ nextgroup=ttForAllBlock
  81. \ skipwhite skipempty
  82. syntax keyword ttCmdLoop #foreach
  83. \ nextgroup=ttForEachBlock
  84. \ skipwhite skipempty
  85. syntax keyword ttCmdLoop #loop
  86. \ nextgroup=ttLoopLowerBlock
  87. \ skipwhite skipempty
  88. syntax keyword ttCmdLoop #parse
  89. \ nextgroup=ttParseValueBlock
  90. \ skipwhite skipempty
  91. " }}}
  92. " Triggers On Game Output #act #high #sub #event {{{
  93. syntax keyword ttCmdTrigger #act[ion] #gag
  94. \ nextgroup=ttPatternBlock
  95. \ skipwhite skipempty
  96. syntax keyword ttCmdTrigger #high[light]
  97. \ nextgroup=ttPatternBlockHigh
  98. \ skipwhite skipempty
  99. syntax keyword ttCmdTrigger #sub[stitute] #prompt
  100. \ nextgroup=ttPatternBlockSub
  101. \ skipwhite skipempty
  102. syntax keyword ttCmdTrigger #event
  103. \ nextgroup=ttEventBlock
  104. \ skipwhite skipempty
  105. " }}}
  106. " Input Related: #alias #tab #macro #history #cursor #buffer {{{
  107. syntax keyword ttCmdInput #alias
  108. \ nextgroup=ttPatternBlock
  109. \ skipwhite skipempty
  110. syntax keyword ttCmdInput #tab
  111. \ nextgroup=ttValueBlock
  112. \ skipwhite skipempty
  113. syntax keyword ttCmdInput #macro
  114. \ nextgroup=ttKeyBlock
  115. \ skipwhite skipempty
  116. syntax keyword ttCmdInput #hist[ory]
  117. \ nextgroup=ttHistSub
  118. \ skipwhite skipempty
  119. syntax keyword ttCmdInput #cursor
  120. \ nextgroup=ttCursorBlock
  121. \ skipwhite skipempty
  122. syntax keyword ttCmdInput #buffer
  123. \ nextgroup=ttBufferSub
  124. \ skipwhite skipempty
  125. " }}}
  126. " Switch/Case: #switch #case #default {{{
  127. syntax keyword ttCmdSwitch #switch #case
  128. \ nextgroup=ttExpressionBlock
  129. \ skipwhite skipempty
  130. syntax keyword ttCmdSwitch #default
  131. "}}}
  132. " If/ElseIf/Else Branching: #if #elseif #else {{{
  133. syntax keyword ttCmdBranch #if #elseif
  134. \ nextgroup=ttExpressionBlock
  135. \ skipwhite skipempty
  136. syntax keyword ttCmdBranch #else
  137. " }}}
  138. " File Related: #read #write #scan #textin {{{
  139. syntax keyword ttCmd #read #write #scan #textin
  140. \ nextgroup=ttFileNameBlock,ttFileName
  141. \ skipwhite skipempty
  142. " }}}
  143. " Variable Assignment: #var #format #math #regex #repalce #list {{{
  144. syntax keyword ttCmdVar #var[iable]
  145. \ nextgroup=ttVarVarBlock,ttVarVar
  146. \ skipwhite skipempty
  147. syntax keyword ttCmdVar #loc[al]
  148. \ nextgroup=ttVarVarBlock,ttVarVar
  149. \ skipwhite skipempty
  150. syntax keyword ttCmdVar #format
  151. \ nextgroup=ttFormatVarBlock,ttFormatVar
  152. \ skipwhite skipempty
  153. syntax keyword ttCmdVar #math
  154. \ nextgroup=ttMathVarBlock,ttMathVar
  155. \ skipwhite skipempty
  156. syntax keyword ttCmdVar #regex
  157. \ nextgroup=ttRegexVarBlock,ttRegexVar
  158. \ skipwhite skipempty
  159. syntax keyword ttCmdVar #replace
  160. \ nextgroup=ttReplaceVarBlock,ttReplaceVar
  161. \ skipwhite skipempty
  162. syntax keyword ttCmdVar #list
  163. \ nextgroup=ttListVarBlock,ttListVar
  164. \ skipwhite skipempty
  165. " }}}
  166. " Functions: #function #return {{{
  167. syntax keyword ttCmd #func[tion]
  168. \ nextgroup=ttFunctionNameBlock
  169. \ skipwhite skipempty
  170. syntax keyword ttCmd #return
  171. \ nextgroup=ttValueBlock
  172. \ skipwhite skipempty
  173. " }}}
  174. " Time Realted: #tick #delay {{{
  175. syntax keyword ttCmdTime #tick[er] #delay
  176. \ nextgroup=ttTimeNameBlock
  177. \ skipwhite skipempty
  178. " }}}
  179. " Class: #class {{{
  180. syntax keyword ttCmd #class
  181. \ nextgroup=ttClassNameBlock,ttClassName
  182. \ skipwhite skipempty
  183. " }}}
  184. " Local Echos: #echo #showme {{{
  185. syntax keyword ttCmd #show[me]
  186. \ nextgroup=ttValueBlock
  187. \ skipwhite skipempty
  188. syntax keyword ttCmd #echo
  189. \ nextgroup=ttEchoBlock
  190. \ skipwhite skipempty
  191. " }}}
  192. " Path: #path {{{
  193. syntax keyword ttCmd #path
  194. \ nextgroup=ttPathSub
  195. \ skipwhite skipempty
  196. " }}}
  197. " Log: #log {{{
  198. syntax keyword ttCmd #log
  199. \ nextgroup=ttLogSub
  200. \ skipwhite skipempty
  201. " }}}
  202. " Line: #line {{{
  203. syntax keyword ttCmd #line
  204. \ nextgroup=ttLineSub
  205. \ skipwhite skipempty
  206. " }}}
  207. " UnCommands: #un* {{{
  208. syntax keyword ttCmdUn #unl[ocal] #unvar[iable] #untick[er] #undelay #unact[ion] #unevent #unfunc[tion]
  209. \ #unhigh[light] #unmacro #unprompt #unsub[sisitue] #untab #ungag #unalias
  210. \ nextgroup=ttUnBlock,ttUn
  211. \ skipwhite
  212. " }}}
  213. " Repeat Command: #{number} {{{
  214. syntax match ttCmdRep "#\d\+"
  215. syntax match ttCmdRep "#{\d\+}"
  216. " }}}
  217. " #script is handled in a special way {{{
  218. syntax keyword ttCmdScript #script
  219. " }}}
  220. " Map: #map {{{
  221. syntax keyword ttCmd #map
  222. \ nextgroup=ttMapSub
  223. \ skipwhite skipempty
  224. " }}}
  225. syntax keyword ttCmd #chat
  226. " }}}
  227. syntax case match
  228. " Cluster ttCmd* into ttCmds {{{
  229. syntax cluster ttCmds contains=
  230. \ ttCmd,
  231. \ ttCmdBranch,
  232. \ ttCmdDebug,
  233. \ ttCmdInput,
  234. \ ttCmdLoop,
  235. \ ttCmdRep,
  236. \ ttCmdSwitch,
  237. \ ttCmdTime,
  238. \ ttCmdTrigger,
  239. \ ttCmdUseless,
  240. \ ttCmdVar,
  241. \ ttCmdUn,
  242. \ ttCmdScript,
  243. " }}}
  244. " Blocks {{{
  245. " General Blocks:
  246. " Pattern Match Blocks {{{
  247. syntax region ttPatternBlock
  248. \ matchgroup=ttBracesMatch start=/{/ end=/}/
  249. \ contained
  250. syntax region ttPatternBlockHigh
  251. \ matchgroup=ttBracesMatch start=/{/ end=/}/
  252. \ contained skipwhite skipempty
  253. \ nextgroup=ttHighColorBlock
  254. syntax region ttPatternBlockSub
  255. \ matchgroup=ttBracesMatch start=/{/ end=/}/
  256. \ contained skipwhite skipempty
  257. \ nextgroup=ttFormatBlock
  258. " }}}
  259. " Format Block {{{
  260. syntax region ttFormatBlock
  261. \ matchgroup=ttBracesFormat start=/{/ end=/}/
  262. \ contained
  263. syntax region ttReplaceFormatBlock
  264. \ matchgroup=ttBracesFormat start=/{/ end=/}/
  265. \ contained
  266. " }}}
  267. " Value Blocks {{{
  268. syntax region ttValueBlock
  269. \ matchgroup=ttBracesValue start=/{/ end=/}/
  270. \ contained
  271. \ contains=ttValueBlock
  272. syntax region ttSplitValueBlock
  273. \ matchgroup=ttBracesValue start=/{/ end=/}/
  274. \ contained skipwhite skipempty
  275. \ nextgroup=ttValueBlock
  276. syntax region ttParseValueBlock
  277. \ matchgroup=ttBracesValue start=/{/ end=/}/
  278. \ contained skipwhite skipempty
  279. \ nextgroup=ttLoopVarBlock
  280. " }}}
  281. " Expression Block {{{
  282. syntax region ttExpressionBlock
  283. \ matchgroup=ttBracesExpression start=/{/ end=/}/
  284. \ contained
  285. " }}}
  286. " File Name Block {{{
  287. syntax region ttFileNameBlock
  288. \ matchgroup=ttBraces start=/{/ end=/}/
  289. \ contained
  290. syntax region ttFileName
  291. \ start=/\w/ skip=/\\\s/ end=/\( \|$\)/
  292. \ contained
  293. \ contains=ttCmdSep
  294. " }}}
  295. " Key Block {{{
  296. syntax region ttKeyBlock
  297. \ matchgroup=ttBraces start=/{/ end=/}/
  298. \ contained
  299. " }}}
  300. " Shell Command Block {{{
  301. syntax region ttShellCmd
  302. \ matchgroup=ttBraces start=/{/ end=/}/
  303. \ contained
  304. \ contains=ttShellCmd
  305. " }}}
  306. " Blocks For Specefic Commands:
  307. " ListName Blocks {{{
  308. syntax match ttListName "\c\%[{]\(act\%[ions]\|alias\%[es]\|class\%[es]\|config\%[urations]\|delay\%[s]\|event\%[s]\|func\%[tions]\|gag\[%s]\|high\%[lights]\|hist\%[ories]\|macro\%[s]\|path\%[s]\|pathdirs\|prompt\%[s]\|sub\%[stitutions]\|tab\%[s]\|tabcycle\|ticker\%[s]\|var\%[iables]\)\%[}]"
  309. \ contained
  310. \ contains=ttSubBrace
  311. syntax match ttListNameKill "\c\%[{]\(act\%[ions]\|alias\%[es]\|class\%[es]\|config\%[urations]\|delay\%[s]\|event\%[s]\|func\%[tions]\|gag\[%s]\|high\%[lights]\|hist\%[ories]\|macro\%[s]\|path\%[s]\|pathdirs\|prompt\%[s]\|sub\%[stitutions]\|tab\%[s]\|tabcycle\|ticker\%[s]\|var\%[iables]\)\%[}]"
  312. \ contains=ttSubBrace
  313. \ contained
  314. \ skipwhite skipempty
  315. \ nextgroup=ttPatternBlock
  316. " }}}
  317. " ForAll/ForEach LoopLower/LoopUpper {{{
  318. syntax region ttForAllBlock
  319. \ matchgroup=ttBraces start=/{/ end=/}/
  320. \ contained
  321. \ contains=ttValueBlock
  322. syntax region ttForEachBlock
  323. \ matchgroup=ttBraces start=/{/ end=/}/
  324. \ contained
  325. \ contains=ttValueBlock
  326. \ skipwhite skipempty
  327. \ nextgroup=ttLoopVarBlock
  328. syntax region ttLoopVarBlock
  329. \ matchgroup=ttBraces start=/{/ end=/}/
  330. \ contained
  331. syntax region ttLoopLowerBlock
  332. \ matchgroup=ttBraces start=/{/ end=/}/
  333. \ contained
  334. \ skipwhite skipempty
  335. \ nextgroup=ttLoopUpperBlock
  336. syntax region ttLoopUpperBlock
  337. \ matchgroup=ttBraces start=/{/ end=/}/
  338. \ contained
  339. \ skipwhite skipempty
  340. \ nextgroup=ttLoopVarBlock
  341. " }}}
  342. " Highlight Color Block {{{
  343. syntax region ttHighColorBlock
  344. \ matchgroup=ttBraces start=/{/ end=/}/
  345. \ contained
  346. " }}}
  347. " Functions Name Block {{{
  348. syntax region ttFunctionNameBlock
  349. \ matchgroup=ttBraces start=/{/ end=/}/
  350. \ contained
  351. " }}}
  352. " Variable Name Block {{{
  353. syntax match ttVarVar "[^ ;]\+"
  354. \ contained
  355. \ contains=ttVarIndex
  356. \ skipwhite
  357. \ nextgroup=ttValueBlock
  358. syntax region ttVarVarBlock
  359. \ matchgroup=ttBraces start=/{/ end=/}/
  360. \ contained
  361. \ contains=ttVarIndex
  362. \ skipwhite
  363. \ nextgroup=ttValueBlock
  364. syntax match ttFormatVar "[^ ;]\+"
  365. \ contained
  366. \ contains=ttVarIndex
  367. \ skipwhite
  368. \ nextgroup=ttFormatBlock
  369. syntax region ttFormatVarBlock
  370. \ matchgroup=ttBraces start=/{/ end=/}/
  371. \ contained
  372. \ contains=ttVarIndex
  373. \ skipwhite skipempty
  374. \ nextgroup=ttFormatBlock
  375. syntax match ttMathVar "[^ ;]\+"
  376. \ contained
  377. \ contains=ttVarIndex
  378. \ skipwhite
  379. \ nextgroup=ttExpressionBlock
  380. syntax region ttMathVarBlock
  381. \ matchgroup=ttBraces start=/{/ end=/}/
  382. \ contained
  383. \ contains=ttVarIndex
  384. \ skipwhite skipempty
  385. \ nextgroup=ttExpressionBlock
  386. syntax match ttMRegexVar "[^ ;]\+"
  387. \ contained
  388. \ contains=ttVarIndex
  389. \ skipwhite
  390. \ nextgroup=ttFormatBlock
  391. syntax region ttRegexVarBlock
  392. \ matchgroup=ttBraces start=/{/ end=/}/
  393. \ contained
  394. \ contains=ttVarIndex
  395. \ skipwhite skipempty
  396. \ nextgroup=ttPatternBlock
  397. syntax match ttReplaceVar "[^ ;]\+"
  398. \ contained
  399. \ contains=ttVarIndex
  400. \ skipwhite
  401. \ nextgroup=ttReplaceFormatBlock
  402. syntax region ttReplaceVarBlock
  403. \ matchgroup=ttBraces start=/{/ end=/}/
  404. \ contained
  405. \ contains=ttVarIndex
  406. \ skipwhite skipempty
  407. \ nextgroup=ttReplaceFormatBlock
  408. syntax match ttListVar "[^ ;]\+"
  409. \ contained
  410. \ contains=ttVarIndex
  411. \ skipwhite
  412. \ nextgroup=ttListSub
  413. syntax region ttListVarBlock
  414. \ matchgroup=ttBraces start=/{/ end=/}/
  415. \ contained
  416. \ contains=ttVarIndex
  417. \ skipwhite skipempty
  418. \ nextgroup=ttListSub
  419. syntax match ttPathVar "[^ ;]\+"
  420. \ contained
  421. \ contains=ttVarIndex
  422. \ skipwhite
  423. \ nextgroup=ttListSub
  424. syntax region ttPathVarBlock
  425. \ matchgroup=ttBraces start=/{/ end=/}/
  426. \ contained
  427. \ contains=ttVarIndex
  428. \ skipwhite skipempty
  429. \ nextgroup=ttListSub
  430. " }}}
  431. " Ticker/Delay Name {{{
  432. syntax region ttTimeNameBlock
  433. \ matchgroup=ttBraces start=/{/ end=/}/
  434. \ contained
  435. " }}}
  436. " Class Blocks {{{
  437. syntax match ttClassName "[^ ;]\+"
  438. \ contained
  439. \ skipwhite
  440. \ nextgroup=ttClassSub
  441. syntax region ttClassNameBlock
  442. \ matchgroup=ttBraces start=/{/ end=/}/
  443. \ contained
  444. \ skipwhite
  445. \ nextgroup=ttClassSub
  446. syntax match ttClassSub "\c\%[{]\(open\|close\|kill\)\%[}]"
  447. \ contained
  448. \ contains=ttSubBrace
  449. syntax match ttClassSub "\c\%[{]\(read\|write\)\%[}]"
  450. \ contained
  451. \ contains=ttSubBrace
  452. \ skipwhite
  453. \ nextgroup=ttFileNameBlock,ttFileName
  454. " }}}
  455. " List Block {{{
  456. syntax match ttListSub "\c\%[{]\(add\|cl\%[ear]\|create\|del\%[ete]\|ins\%[ert]\|get\|set\|size\|sort\)\%[}]"
  457. \ contained
  458. \ contains=ttSubBrace
  459. " }}}
  460. " Map Block {{{
  461. syntax match ttMapSub "\c\%[{]\(at\|create\|destroy\|info\|jump\|find\|flag\|get\|goto\|leave\|legend\|list\|map\|name\|resize\|return\|run\|undo\|vnum\)\%[}]"
  462. \ contained
  463. \ contains=ttSubBrace
  464. syntax match ttMapSub "\c\%[{]\(read\|write\)\%[}]"
  465. \ contained
  466. \ contains=ttSubBrace
  467. \ skipwhite skipempty
  468. \ nextgroup=ttFileNameBlock,ttFileName
  469. syntax match ttMapSub "\c\%[{]color\%[}]"
  470. \ contained
  471. \ contains=ttSubBrace
  472. \ skipwhite skipempty
  473. \ nextgroup=ttMapSubSubColor
  474. syntax match ttMapSub "\c\%[{]flag\%[}]"
  475. \ contained
  476. \ contains=ttSubBrace
  477. \ skipwhite skipempty
  478. \ nextgroup=ttMapSubSubFlag
  479. syntax match ttMapSub "\c\%[{]\(delete\|dig\|exit\%[flag]\|explore\|insert\|link\|move\|travel\|uninsert\|unlink\)\%[}]"
  480. \ contained
  481. \ contains=ttSubBrace
  482. \ skipwhite skipempty
  483. \ nextgroup=ttMapSubSubDirection
  484. syntax match ttMapSub "\c\%[{]roomflag\%[}]"
  485. \ contained
  486. \ contains=ttSubBrace
  487. \ skipwhite skipempty
  488. \ nextgroup=ttMapSubSubRoomFlag
  489. syntax match ttMapSub "\c\%[{]set\%[}]"
  490. \ contained
  491. \ contains=ttSubBrace
  492. \ skipwhite skipempty
  493. \ nextgroup=ttMapSubSubSet
  494. syntax match ttMapSubSubColor "\c\%[{]\(exit\|here\|path\|room\)\%[}]"
  495. \ contained
  496. \ contains=ttSubBrace
  497. syntax match ttMapSubSubFlag "\c\%[{]\(asciigraphics\|asciivnums\|mudfont\|nofollow\|static\|symbolgraphics\|vtmap\|vtgraphics\)\%[}]"
  498. \ contained
  499. \ contains=ttSubBrace
  500. syntax match ttMapSubSubDirection "\c\%[{]\(ne\|nw\|se\|sw\|n\|s\|e\|w\|w\|u\|d\)\%[}]"
  501. \ contained
  502. \ contains=ttSubBrace
  503. syntax match ttMapSubSubRoomFlag "\c\%[{]\(avoid\|hide\|leave\|void\|static\)\%[}]"
  504. \ contained
  505. \ contains=ttSubBrace
  506. syntax match ttMapSubSubSet "\c\%[{]room\(area\|color\|data\|desc\|flags\|name\|note\|symbol\|terrain\|weight\)\%[}]"
  507. \ contained
  508. \ contains=ttSubBrace
  509. " }}}
  510. " Path Block {{{
  511. syntax match ttPathSub "\c\%[{]\(end\|del\|new\|run\|show\|walk\|zip\|unzip\)\%[}]"
  512. \ contained
  513. \ contains=ttSubBrace
  514. syntax match ttPathSub "\c\%[{]\(load\|save\)\%[}]"
  515. \ contained
  516. \ contains=ttSubBrace
  517. \ skipwhite
  518. \ nextgroup=ttPathVarBlock,ttPathVar
  519. syntax match ttPathSub "\c\%[{]\(ins\%[ert]\)\%[}]"
  520. \ contained
  521. \ contains=ttSubBrace
  522. \ skipwhite
  523. \ nextgroup=ttValueBlock
  524. " }}}
  525. " Log Block {{{
  526. syntax match ttLogSub "\c\%[{]\(a\%[ppend]\|ov\%[erwrite]\|of\%[f]\)\%[}]"
  527. \ contained
  528. \ contains=ttSubBrace
  529. \ skipwhite
  530. \ nextgroup=ttFileNameBlock,ttFileName
  531. " }}}
  532. " Buffer Block {{{
  533. syntax match ttBufferSub "\c\%[{]\(clear\|down\|end\|find\|home\|info\|lock\|up\)\%[}]"
  534. \ contained
  535. \ contains=ttSubBrace
  536. syntax match ttBufferSub "\c\%[{]write\%[}]"
  537. \ contained
  538. \ contains=ttSubBrace
  539. \ skipwhite
  540. \ nextgroup=ttFileNameBlock,ttFileName
  541. syntax match ttBufferSub "\c\%[{]get\%[}]"
  542. \ contained
  543. \ contains=ttSubBrace
  544. \ skipwhite
  545. " }}}
  546. " Event Name {{{
  547. syntax region ttEventBlock
  548. \ matchgroup=ttBraces start=/{/ end=/}/
  549. \ contained
  550. " }}}
  551. " Cursor Option {{{
  552. syntax region ttCursorBlock
  553. \ matchgroup=ttBraces start=/{/ end=/}/
  554. \ contained
  555. \ skipwhite skipempty
  556. \ nextgroup=ttKeyBlock
  557. " }}}
  558. "Session/Run Name Blocks {{{
  559. syntax match ttSessionName "[^ ;]\+"
  560. \ contained
  561. syntax region ttSessionNameBlock
  562. \ matchgroup=ttBraces start=/{/ end=/}/
  563. \ contained
  564. syntax match ttSesSessionName "[^ ;]\+"
  565. \ contained
  566. \ skipwhite
  567. \ nextgroup=ttSessionURIBlock,ttSessionURI
  568. syntax region ttSesSessionNameBlock
  569. \ matchgroup=ttBraces start=/{/ end=/}/
  570. \ contained
  571. \ skipwhite
  572. \ nextgroup=ttSessionURIBlock,ttSessionURI
  573. syntax match ttRunSessionName "[^ ;]\+"
  574. \ contained
  575. \ skipwhite
  576. \ nextgroup=ttShellCmd
  577. syntax region ttRunSessionNameBlock
  578. \ matchgroup=ttBraces start=/{/ end=/}/
  579. \ contained
  580. \ skipwhite
  581. \ nextgroup=ttShellCmd
  582. syntax match ttSessionURI "[^ ;]\+"
  583. \ contained
  584. \ skipwhite
  585. \ nextgroup=ttSessionPortBlock,ttSessionPort
  586. syntax region ttSessionURIBlock
  587. \ matchgroup=ttBraces start=/{/ end=/}/
  588. \ contained
  589. \ skipwhite
  590. \ nextgroup=ttSessionPortBlock,ttSessionPort
  591. syntax match ttSessionPort "[^ ;]\+"
  592. \ contained
  593. syntax region ttSessionPortBlock
  594. \ matchgroup=ttBraces start=/{/ end=/}/
  595. \ contained
  596. " }}}
  597. " History Block {{{
  598. syntax match ttHistSub "\c\%[{]\(delete\|list\)\%[}]"
  599. \ contained
  600. \ contains=ttSubBrace
  601. syntax match ttHistSub "\c\%[{]insert\%[}]"
  602. \ contained
  603. \ contains=ttSubBrace
  604. \ skipwhite
  605. \ nextgroup=ttValueBlock
  606. syntax match ttHistSub "\c\%[{]\(write\|read\)\%[}]"
  607. \ contained
  608. \ contains=ttSubBrace
  609. \ skipwhite
  610. \ nextgroup=ttFileNameBlock,ttFileName
  611. " }}}
  612. " Echo Block {{{
  613. syntax region ttEchoBlock
  614. \ matchgroup=ttBraces start=/{/ end=/}/
  615. \ contained
  616. \ contains=ttFormatBlock,ttEchoNumberBlock
  617. syntax match ttEchoNumberBlock "{\d\+}"
  618. \ contained
  619. \ contains=ttCodeBlock
  620. " }}}
  621. " RegEx Matching Block {{{
  622. syntax region ttRegExBlock
  623. \ matchgroup=ttRegExBraces start=/{/ end=/}/
  624. \ contained
  625. \ contains=ttRegExBlock
  626. \ containedin=ttPatternBlock,ttPatternBlockSub,ttPatternBlockHigh
  627. " }}}
  628. " String Block {{{
  629. syntax region ttString
  630. \ matchgroup=ttBraces start=/"/ skip=/\\"/ end=/"/
  631. \ contained
  632. \ contains=ttRegExBlock
  633. \ containedin=ttExpressionBlock
  634. " }}}
  635. " Config Block {{{
  636. syntax region ttConfigBlock
  637. \ matchgroup=ttBraces start=/{/ end=/}/
  638. \ contained
  639. " }}}
  640. " Line Block {{{
  641. syntax match ttLineSub "\c\%[{]\(gag\)\%[}]"
  642. \ contained
  643. \ contains=ttSubBrace
  644. syntax match ttLineSub "\c\%[{]\(strip\|ignore\|verbose\)\%[}]"
  645. \ contained
  646. \ contains=ttSubBrace
  647. syntax match ttLineSub "\c\%[{]\(sub\%[titute]\)\%[}]"
  648. \ contained
  649. \ contains=ttSubBrace
  650. \ skipwhite
  651. \ nextgroup=ttLineSubSub
  652. syntax match ttLineSub "\c\%[{]\(log\%[verbatim]\)\%[}]"
  653. \ contained
  654. \ contains=ttSubBrace
  655. \ skipwhite
  656. \ nextgroup=ttFileNameBlock,ttFileName
  657. syntax match ttLineSubSub "\c\%[{]\(var\%[iables]\|functions\|colors\|escapes\|secure\|eol\|lnf\)\%[}]"
  658. \ contained
  659. \ contains=ttSubBrace
  660. " }}}
  661. " Un* Block {{{
  662. syntax region ttUnBlock
  663. \ matchgroup=ttBraces start=/{/ end=/}/
  664. \ contained
  665. syntax match ttUn "[^;{} ]\+"
  666. \ contained
  667. " }}}
  668. " Generic Block:
  669. " Falls Back To Generic Code Block {{{
  670. syntax region ttCodeBlock
  671. \ matchgroup=ttBraces start=/{/ end=/}/
  672. \ contains=ttCodeBlock,ttCmdSep,@ttCmds,ttNopComment
  673. " }}}
  674. " Error Block: {{{
  675. syntax region ttErrorBlock
  676. \ start=/\S\+/ end=/$\|;/
  677. \ keepend
  678. \ contains=ttCmdSep
  679. \ contained
  680. " }}}
  681. " }}}
  682. " Syntax Elements {{{
  683. " Numbers {{{
  684. syntax match ttInt "\d\+"
  685. \ containedin=ttCodeBlock,ttValueBlock,ttTimeNameBlock,ttExpressionBlock,ttVarIndex,ttLoopLowerBlock,ttLoopUpperBlock,ttFuncBlock,ttSessionPort,ttSessionPortBlock
  686. syntax match ttFloat "\d\+.\d\+"
  687. \ containedin=ttCodeBlock,ttValueBlock,ttTimeNameBlock,ttExpressionBlock,ttVarIndex,ttLoopLowerBlock,ttLoopUpperBlock,ttFuncBlock,ttSessionPort,ttSessionPortBlock
  688. " }}}
  689. " Lazy Match Patterns {{{
  690. syntax match ttMatchLazy "%[iIwWdDsS?.+*]"
  691. \ contained
  692. \ containedin=ttPatternBlock,ttPatternBlockHigh,ttPatternBlockSub,ttUn,ttUnBlock,ttReplaceFormatBlock,ttString
  693. " }}}
  694. " Match Special Regex Chars {{{
  695. syntax match ttMatchSpecial "\^\|\~\|\$"
  696. \ contained
  697. \ containedin=ttPatternBlock,ttPatternBlockHigh,ttPatternBlockSub,ttReplaceFormatBlock
  698. " }}}
  699. " Format specifiers {{{
  700. syntax match ttFormat "%\%[.+-][0-9]\{-}[acdfghlmnprstuwxADHLMSTUX]"
  701. \ contained
  702. \ containedin=ttFormatBlock,ttEchoBlock
  703. " }}}
  704. " RexEx {{{
  705. syntax match ttRegEx "\(\.\|+\|?\|*\|\\.\)"
  706. \ contained
  707. \ containedin=ttRegExBlock
  708. syntax match ttRegExBraces "\()\|(\|\]\|\[\||\)"
  709. \ contained
  710. \ containedin=ttRegExBlock
  711. " }}}
  712. " Math and Bitwise Operators {{{
  713. syntax match ttOperators "\(<<\|>>\|==\|!=\|^^\|||\|&&\|[-+*%&/^|<>!=]\)"
  714. \ contained
  715. \ containedin=ttExpressionBlock
  716. syntax match ttOperatorsParen "[)(]"
  717. \ contained
  718. \ containedin=ttExpressionBlock
  719. " }}}
  720. " Color codes {{{
  721. syntax match ttColor "<\d\d\d>"
  722. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  723. syntax match ttColor "<[a-fA-F][a-fA-F][a-fA-F]>"
  724. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  725. syntax match ttColor "<[gG]\d\{2}>"
  726. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  727. " }}}
  728. " Dynamic Variables {{{
  729. syntax match ttArgRef "%\d\{1,2}"
  730. \ containedin=ALLBUT,ttComment,ttNopComment
  731. syntax match ttRegExRef "&\d\{1,2}"
  732. \ containedin=ALLBUT,ttComment,ttNopComment
  733. " }}}
  734. " Character Escapes {{{
  735. syntax match ttEsc "\\[0abcenrt\\]"
  736. \ containedin=ALLBUT,ttComment,ttNopComment
  737. syntax match ttEsc "\\x\x\{2}"
  738. \ containedin=ALLBUT,ttComment,ttNopComment
  739. syntax match ttEsc "\\\d\d\d"
  740. \ containedin=ALLBUT,ttComment,ttNopComment
  741. " }}}
  742. " ANSI Escape/Control Codes {{{
  743. syntax match ttAnsiEsc /\\e\[[0-9;\\]\{-}m/
  744. \ containedin=ALLBUT,ttComment,ttNopComment
  745. " }}}
  746. " tintin Variables {{{
  747. syntax match ttVar "\$\%[{][a-zA-Z_][a-zA-Z0-9_.-]*"
  748. \ nextgroup=ttVarIndex
  749. \ containedin=ALLBUT,ttComment,ttNopComment
  750. syntax match ttVar "&\%[{][a-zA-Z_][a-zA-Z0-9_.-]*"
  751. \ nextgroup=ttVarIndex
  752. \ containedin=ALLBUT,ttComment,ttNopComment
  753. syntax match ttVar "\*\%[{][a-zA-Z_][a-zA-Z0-9_.-]*"
  754. \ nextgroup=ttVarIndex
  755. \ containedin=ALLBUT,ttComment,ttNopComment
  756. " }}}
  757. " Variable Blocks {{{
  758. syntax region ttVarBlock
  759. \ matchgroup=ttVarBraces start=/${/ end=/}/
  760. \ contains=ttVarIndex
  761. \ containedin=ALLBUT,ttComment,ttNopComment
  762. syntax region ttVarBlock
  763. \ matchgroup=ttVarBraces start=/&{/ end=/}/
  764. \ contains=ttVarIndex
  765. \ containedin=ALLBUT,ttComment,ttNopComment
  766. " }}}
  767. " Variable Index {{{
  768. syntax region ttVarIndex
  769. \ matchgroup=ttVarIndexBracket start=/\[/ end=/\]/
  770. \ contained
  771. \ containedin=ttVarBlock
  772. \ transparent
  773. \ nextgroup=ttVarIndex
  774. " }}}
  775. " @function calls and the obligatory braces around the arguments {{{
  776. syntax region ttFuncBlock
  777. \ matchgroup=ttBracesFunction start=/{/ skip=/$/ end=/}/
  778. \ contains=ttCodeBlock
  779. \ contained
  780. syntax match ttFunction "@\%[{][a-zA-Z_][a-zA-Z0-9_.-]*"
  781. \ containedin=ALLBUT,ttComment,ttNopComment
  782. \ nextgroup=ttFuncBlock
  783. " }}}
  784. " Optional SubCommand Braces {{{
  785. syntax match ttSubBrace "{\|}"
  786. \ contained
  787. " }}}
  788. " Command Terminator {{{
  789. syntax match ttCmdSep /;/
  790. \ containedin=ttCodeBlock,ttFuncBlock,ttForAllBlock,ttForEachBlock
  791. " }}}
  792. " }}}
  793. " Comments {{{
  794. " #nop comments
  795. syntax region ttNopComment
  796. \ matchgroup=ttNop start="#nop" end=/\;\|$/
  797. syntax region ttNopComment
  798. \ matchgroup=ttComment start="///=== {" end=/}/
  799. \ contains=ttCodeBlock,ttCmdSep,@ttCmds,ttNopComment
  800. " C-style multi-line comments
  801. syntax region ttComment start="/\*" end="\*/"
  802. \ contains=ttComment
  803. syntax region ttCommentError start="/\*" end="\*/"
  804. \ contained
  805. \ containedin=ttCodeBlock
  806. " Special notes in Comments
  807. syntax keyword ttTodo TODO FIXME XXX BUG DEBUG TBD NOTE
  808. \ contained
  809. \ containedin=ttComment,ttNopComment
  810. " }}}
  811. " Internal Highlink Linking {{{
  812. " Link ttCmd* to ttCmd Group {{{
  813. hi link ttCmdBranch ttCmd
  814. hi link ttCmdDebug ttCmd
  815. hi link ttCmdInput ttCmd
  816. hi link ttCmdLoop ttCmd
  817. hi link ttCmdRep ttCmd
  818. hi link ttCmdSwitch ttCmd
  819. hi link ttCmdTime ttCmd
  820. hi link ttCmdTrigger ttCmd
  821. hi link ttCmdUseless ttCmd
  822. hi link ttCmdVar ttCmd
  823. hi link ttCmdUn ttCmd
  824. hi link ttCmdScript ttCmd
  825. "}}}
  826. " Link Syntax Elements {{{
  827. hi link ttMatchLazy ttMacro
  828. hi link ttMatchSpecial ttMacro
  829. hi link ttFormat ttMacro
  830. hi link ttRegEx ttMacro
  831. hi link ttRegExBraces ttBraces
  832. hi link ttColor ttMacro
  833. hi link ttEsc ttMacro
  834. hi link ttAnsiEsc ttMacro
  835. hi link ttArgRef ttReference
  836. hi link ttRegExRef ttReference
  837. " }}}
  838. " tintin Lists and Sub commands are keywords {{{
  839. hi link ttListNameKill ttKeyword
  840. hi link ttListName ttKeyword
  841. hi link ttConfigBlock ttKeyword
  842. hi link ttListSub ttKeyword
  843. hi link ttPathSub ttKeyword
  844. hi link ttLogSub ttKeyword
  845. hi link ttClassSub ttKeyword
  846. hi link ttHistSub ttKeyword
  847. hi link ttEventBlock ttKeyword
  848. hi link ttCursorBlock ttKeyword
  849. hi link ttBufferSub ttKeyword
  850. hi link ttLineSub ttKeyword
  851. hi link ttLineSubSub ttKeyword
  852. hi link ttMapSub ttKeyword
  853. hi link ttMapSubSubSet ttKeyword
  854. hi link ttMapSubSubColor ttKeyword
  855. hi link ttMapSubSubFlag ttKeyword
  856. hi link ttMapSubSubRoomFlag ttKeyword
  857. hi link ttMapSubSubDirection ttKeyword
  858. " }}}
  859. hi link ttSessionURIBlock ttSessionURI
  860. hi link ttSessionURI ttString
  861. " Link all Braces together {{{
  862. hi link ttBracesMatch ttBraces
  863. hi link ttBracesFormat ttBraces
  864. hi link ttBracesValue ttBraces
  865. hi link ttBracesExpression ttBraces
  866. hi link ttVarIndexBracket ttBraces
  867. hi link ttRegExBraces ttBraces
  868. hi link ttOperatorsParen ttBraces
  869. hi link ttSubBrace ttBraces
  870. " }}}
  871. hi link ttBracesFunction ttFunction
  872. " Link Various Variable Names to ttVarName {{{
  873. hi link ttLoopVarBlock ttVarName
  874. hi link ttMathVarBlock ttVarName
  875. hi link ttFormatVarBlock ttVarName
  876. hi link ttRegexVarBlock ttVarName
  877. hi link ttReplaceVarBlock ttVarName
  878. hi link ttVarVarBlock ttVarName
  879. hi link ttListVarBlock ttVarName
  880. hi link ttPathVarBlock ttVarName
  881. hi link ttVarVar ttVarName
  882. hi link ttMathVar ttVarName
  883. hi link ttFormatVar ttVarName
  884. hi link ttRegexVar ttVarName
  885. hi link ttReplaceVar ttVarName
  886. hi link ttListVar ttVarName
  887. hi link ttPathVar ttVarName
  888. hi link ttScriptVarNameVar ttVarName
  889. " }}}
  890. " Link all pattern blocks together {{{
  891. hi link ttPatternBlockHigh ttPatternBlock
  892. hi link ttPatternBlockSub ttPatternBlock
  893. " }}}
  894. " Link all names to ttIdentifier {{{
  895. hi link ttClassName ttIdentifier
  896. hi link ttClassNameBlock ttIdentifier
  897. hi link ttTimeNameBlock ttIdentifier
  898. hi link ttSessionName ttIdentifier
  899. hi link ttSessionNameBlock ttIdentifier
  900. hi link ttSesSessionName ttIdentifier
  901. hi link ttSesSessionNameBlock ttIdentifier
  902. hi link ttRunSessionName ttIdentifier
  903. hi link ttRunSessionNameBlock ttIdentifier
  904. hi link ttUnBlock ttIdentifier
  905. hi link ttUn ttIdentifier
  906. " }}}
  907. " Link various number types to ttNumber {{{
  908. hi link ttInt ttNumber
  909. hi link ttFloat ttNumber
  910. " }}}
  911. hi link ttFunctionNameBlock ttFunction
  912. hi link ttFileNameBlock ttFileName
  913. hi link ttScriptShell ttShellCmd
  914. hi link ttVarBlock ttVar
  915. hi link ttVarBraces ttVar
  916. hi link ttNopComment ttComment
  917. hi link ttNop ttCmd
  918. hi link ttCommentError ttError
  919. hi link ttErrorBlock ttError
  920. " }}}
  921. " Link tt Highlighting Groups to Default Groups {{{
  922. hi default link ttVar Special
  923. hi default link ttCmd Statement
  924. hi default link ttBraces Delimiter
  925. hi default link ttCmdSep Delimiter
  926. hi default link ttFileName Character
  927. hi default link ttReference Special
  928. hi default link ttMacro Macro
  929. hi default link ttKeyword Keyword
  930. hi default link ttFunction Function
  931. hi default link ttShellCmd Character
  932. hi default link ttVarName Identifier
  933. hi default link ttIdentifier Identifier
  934. hi default link ttNumber Number
  935. hi default link ttString String
  936. hi default link ttOperators Operator
  937. hi default link ttCodeBlock Structure
  938. hi default link ttTodo Todo
  939. hi default link ttComment Comment
  940. hi default link ttError Error
  941. " }}}
  942. let b:current_syntax = "tt"