tt.vim 28 KB

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