tt.vim 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. " VIM Syntax file for tintin++ scripts
  2. " TODO
  3. " Make #script more robust
  4. " Add proper support for #chat
  5. " Add proper support for #map
  6. " Finish support for #buffer get
  7. " Make Better use of Clusters
  8. " More Robust #script support
  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
  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
  64. \ skipwhite skipempty
  65. syntax keyword ttCmd #ses[sion]
  66. \ nextgroup=ttSessionNameBlock,ttSessionName
  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=ttHistSub1,ttHistSub2,ttHistSub3
  116. \ skipwhite skipempty
  117. syntax keyword ttCmdInput #cursor
  118. \ nextgroup=ttCursorBlock
  119. \ skipwhite skipempty
  120. syntax keyword ttCmdInput #buffer
  121. \ nextgroup=ttBufferSub1,ttBufferSub2,ttBufferSub3
  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=ttPathSub1,ttPathSub2,ttPathSub3
  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=ttLineSub1,ttLineSub2,ttLineSub3,ttLineSub4
  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 region ttCmdScriptBlock start=/#script\>/ skip=/}\_s\+{\|$/ end=/}$\|};$/
  214. \ contains=ttCmdScript,ttShellCmd,ttScriptVarName,ttCmdSep
  215. \ keepend
  216. syntax keyword ttCmdScript #script
  217. \ contained
  218. " }}}
  219. syntax keyword ttCmd #map
  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 region ttVarVarBlock
  349. \ matchgroup=ttBraces start=/{/ end=/}/
  350. \ contained
  351. \ contains=ttVarIndex
  352. \ skipwhite
  353. \ nextgroup=ttValueBlock
  354. syntax match ttVarVar "[\[\]0-9A-Za-z_]\+"
  355. \ contained
  356. \ contains=ttVarIndex
  357. \ skipwhite
  358. \ nextgroup=ttValueBlock
  359. syntax region ttFormatVarBlock
  360. \ matchgroup=ttBraces start=/{/ end=/}/
  361. \ contained
  362. \ contains=ttVarIndex
  363. \ skipwhite skipempty
  364. \ nextgroup=ttFormatBlock
  365. syntax match ttFormatVar "[\[\]0-9A-Za-z_]\+"
  366. \ contained
  367. \ contains=ttVarIndex
  368. \ skipwhite
  369. \ nextgroup=ttFormatBlock
  370. syntax region ttMathVarBlock
  371. \ matchgroup=ttBraces start=/{/ end=/}/
  372. \ contained
  373. \ contains=ttVarIndex
  374. \ skipwhite skipempty
  375. \ nextgroup=ttExpressionBlock
  376. syntax match ttMathVar "[\[\]0-9A-Za-z_]\+"
  377. \ contained
  378. \ contains=ttVarIndex
  379. \ skipwhite
  380. \ nextgroup=ttExpressionBlock
  381. syntax region ttRegexVarBlock
  382. \ matchgroup=ttBraces start=/{/ end=/}/
  383. \ contained
  384. \ contains=ttVarIndex
  385. \ skipwhite skipempty
  386. \ nextgroup=ttPatternBlock
  387. syntax match ttMRegexVar "[\[\]0-9A-Za-z_]\+"
  388. \ contained
  389. \ contains=ttVarIndex
  390. \ skipwhite
  391. \ nextgroup=ttFormatBlock
  392. syntax region ttReplaceVarBlock
  393. \ matchgroup=ttBraces start=/{/ end=/}/
  394. \ contained
  395. \ contains=ttVarIndex
  396. \ skipwhite skipempty
  397. \ nextgroup=ttReplaceFormatBlock
  398. syntax match ttReplaceVar "[\[\]0-9A-Za-z_]\+"
  399. \ contained
  400. \ contains=ttVarIndex
  401. \ skipwhite
  402. \ nextgroup=ttReplaceFormatBlock
  403. syntax region ttListVarBlock
  404. \ matchgroup=ttBraces start=/{/ end=/}/
  405. \ contained
  406. \ contains=ttVarIndex
  407. \ skipwhite skipempty
  408. \ nextgroup=ttListSub
  409. syntax match ttListVar "[\[\]0-9A-Za-z_]\+"
  410. \ contained
  411. \ contains=ttVarIndex
  412. \ skipwhite
  413. \ nextgroup=ttListSub
  414. syntax region ttPathVarBlock
  415. \ matchgroup=ttBraces start=/{/ end=/}/
  416. \ contained
  417. \ contains=ttVarIndex
  418. \ skipwhite skipempty
  419. \ nextgroup=ttListSub
  420. syntax match ttPathVar "[\[\]0-9A-Za-z_]\+"
  421. \ contained
  422. \ contains=ttVarIndex
  423. \ skipwhite
  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 region ttClassNameBlock
  433. \ matchgroup=ttBraces start=/{/ end=/}/
  434. \ contained
  435. \ skipwhite
  436. \ nextgroup=ttClassSub1,ttClassSub2
  437. syntax match ttClassName "\<\S\+\>"
  438. \ contained
  439. \ skipwhite
  440. \ nextgroup=ttClassSub1,ttClassSub2
  441. syntax match ttClassSub1 "\%[{]\(open\|close\|kill\)\%[}]"
  442. \ contained
  443. \ contains=ttSubBrace
  444. syntax match ttClassSub2 "\%[{]\(read\|write\)\%[}]"
  445. \ contained
  446. \ contains=ttSubBrace
  447. \ skipwhite
  448. \ nextgroup=ttFileNameBlock,ttFileName
  449. " }}}
  450. " List Block {{{
  451. syntax match ttListSub "\%[{]\(add\|cl\%[ear]\|create\|del\%[ete]\|ins\%[ert]\|get\|set\|size\|sort\)\%[}]"
  452. \ contained
  453. \ contains=ttSubBrace
  454. " }}}
  455. " Path Block {{{
  456. syntax match ttPathSub1 "\%[{]\(end\|del\|new\|run\|show\|walk\|zip\|unzip\)\%[}]"
  457. \ contained
  458. \ contains=ttSubBrace
  459. syntax match ttPathSub2 "\%[{]\(load\|save\)\%[}]"
  460. \ contained
  461. \ contains=ttSubBrace
  462. \ skipwhite
  463. \ nextgroup=ttPathVarBlock,ttPathVar
  464. syntax match ttPathSub3 "\%[{]\(ins\%[ert]\)\%[}]"
  465. \ contained
  466. \ contains=ttSubBrace
  467. \ skipwhite
  468. \ nextgroup=ttValueBlock
  469. " }}}
  470. " Log Block {{{
  471. syntax match ttLogSub "\%[{]\(a\%[ppend]\|ov\%[erwrite]\|of\%[f]\)\%[}]"
  472. \ contained
  473. \ contains=ttSubBrace
  474. \ skipwhite
  475. \ nextgroup=ttFileNameBlock,ttFileName
  476. " }}}
  477. " Buffer Block {{{
  478. syntax match ttBufferSub1 "\%[{]\(clear\|down\|end\|find\|home\|info\|lock\|up\)\%[}]"
  479. \ contained
  480. \ contains=ttSubBrace
  481. syntax match ttBufferSub2 "\%[{]write\%[}]"
  482. \ contained
  483. \ contains=ttSubBrace
  484. \ skipwhite
  485. \ nextgroup=ttFileNameBlock,ttFileName
  486. syntax match ttBufferSub3 "\%[{]get\%[}]"
  487. \ contained
  488. \ contains=ttSubBrace
  489. \ skipwhite
  490. " }}}
  491. " Event Name {{{
  492. syntax region ttEventBlock
  493. \ matchgroup=ttBraces start=/{/ end=/}/
  494. \ contained
  495. " }}}
  496. " Cursor Option {{{
  497. syntax region ttCursorBlock
  498. \ matchgroup=ttBraces start=/{/ end=/}/
  499. \ contained
  500. \ skipwhite skipempty
  501. \ nextgroup=ttKeyBlock
  502. " }}}
  503. "Session/Run Name Blocks {{{
  504. syntax region ttSessionNameBlock
  505. \ matchgroup=ttBraces start=/{/ end=/}/
  506. \ contained
  507. \ skipwhite
  508. \ nextgroup=ttSessionURIBlock,ttSessionURI
  509. syntax match ttSessionName "\<\S\+\>"
  510. \ contained
  511. \ skipwhite
  512. \ nextgroup=ttSessionURIBlock,ttSessionURI
  513. syntax region ttRunSessionNameBlock
  514. \ matchgroup=ttBraces start=/{/ end=/}/
  515. \ contained
  516. \ skipwhite
  517. \ nextgroup=ttShellCmd
  518. syntax match ttRunSessionName "\<\S\+\>"
  519. \ contained
  520. \ skipwhite
  521. \ nextgroup=ttShellCmd
  522. syntax region ttSessionURIBlock
  523. \ matchgroup=ttBraces start=/{/ end=/}/
  524. \ contained
  525. \ skipwhite
  526. \ nextgroup=ttSessionPortBlock,ttSessionPort
  527. syntax match ttSessionURI "\<\S\+\>"
  528. \ contained
  529. \ skipwhite
  530. \ nextgroup=ttSessionPortBlock,ttSessionPort
  531. syntax region ttSessionPortBlock
  532. \ matchgroup=ttBraces start=/{/ end=/}/
  533. \ contained
  534. syntax match ttSessionPort "\<\S\+\>"
  535. \ contained
  536. " }}}
  537. " History Block {{{
  538. syntax match ttHistSub1 "\%[{]\(delete\|list\)\%[}]"
  539. \ contained
  540. \ contains=ttSubBrace
  541. syntax match ttHistSub2 "\%[{]insert\%[}]"
  542. \ contained
  543. \ contains=ttSubBrace
  544. \ skipwhite
  545. \ nextgroup=ttValueBlock
  546. syntax match ttHistSub3 "\%[{]\(write\|read\)\%[}]"
  547. \ contained
  548. \ contains=ttSubBrace
  549. \ skipwhite
  550. \ nextgroup=ttFileNameBlock,ttFileName
  551. " }}}
  552. " Echo Block {{{
  553. syntax region ttEchoBlock
  554. \ matchgroup=ttBraces start=/{/ end=/}/
  555. \ contained
  556. \ contains=ttFormatBlock,ttEchoNumberBlock
  557. syntax match ttEchoNumberBlock "{\d\+}"
  558. \ contained
  559. \ contains=ttCodeBlock
  560. " }}}
  561. " RegEx Matching Block {{{
  562. syntax region ttRegExBlock
  563. \ matchgroup=ttRegExBraces start=/{/ end=/}/
  564. \ contained
  565. \ contains=ttRegExBlock
  566. \ containedin=ttPatternBlock,ttPatternBlockSub,ttPatternBlockHigh
  567. " }}}
  568. " String Block {{{
  569. syntax region ttString
  570. \ matchgroup=ttBraces start=/"/ skip=/\\"/ end=/"/
  571. \ contained
  572. \ contains=ttRegExBlock
  573. \ containedin=ttExpressionBlock
  574. " }}}
  575. " Config Block {{{
  576. syntax region ttConfigBlock
  577. \ matchgroup=ttBraces start=/{/ end=/}/
  578. \ contained
  579. " }}}
  580. " Script Block: {{{
  581. syntax match ttScriptVarName /\S\+\_s*{/
  582. \ contained
  583. \ keepend
  584. \ contains=ttScriptVarNameVar,ttSubBrace
  585. \ skipempty skipwhite
  586. \ nextgroup=ttScriptShell
  587. syntax match ttScriptVarNameVar /[A-Za-z_0-9]\+/
  588. \ contained
  589. syntax region ttScriptShell start=// skip=/$/ end=/}$\|};$/
  590. \ contained
  591. \ contains=ttSubBrace,ttShellCmd
  592. " }}}
  593. " Line Block {{{
  594. syntax match ttLineSub1 "\%[{]\(gag\)\%[}]"
  595. \ contained
  596. \ contains=ttSubBrace
  597. syntax match ttLineSub2 "\%[{]\(strip\|ignore\|verbose\)\%[}]"
  598. \ contained
  599. \ contains=ttSubBrace
  600. syntax match ttLineSub3 "\%[{]\(sub\%[titute]\)\%[}]"
  601. \ contained
  602. \ contains=ttSubBrace
  603. \ skipwhite
  604. \ nextgroup=ttLineSubSub
  605. syntax match ttLineSub4 "\%[{]\(log\%[verbatim]\)\%[}]"
  606. \ contained
  607. \ contains=ttSubBrace
  608. \ skipwhite
  609. \ nextgroup=ttFileNameBlock,ttFileName
  610. syntax match ttLineSubSub "\%[{]\(var\%[iables]\|functions\|colors\|escapes\|secure\|eol\|lnf\)\%[}]"
  611. \ contained
  612. \ contains=ttSubBrace
  613. " }}}
  614. " Un* Block {{{
  615. syntax region ttUnBlock
  616. \ matchgroup=ttBraces start=/{/ end=/}/
  617. \ contained
  618. syntax match ttUn "[^;{} ]\+"
  619. \ contained
  620. " }}}
  621. " Generic Block:
  622. " Falls Back To Generic Code Block {{{
  623. syntax region ttCodeBlock
  624. \ matchgroup=ttBraces start=/{/ end=/}/
  625. \ contains=ttCodeBlock,ttCmdSep,@ttCmds,ttNopComment
  626. " }}}
  627. " Error Block: {{{
  628. syntax region ttErrorBlock
  629. \ start=/\S\+/ end=/$\|;/
  630. \ keepend
  631. \ contains=ttCmdSep
  632. \ contained
  633. " }}}
  634. " }}}
  635. " Syntax Elements {{{
  636. " Optional SubCommand Braces {{{
  637. syntax match ttSubBrace "{\|}"
  638. \ contained
  639. " }}}
  640. " Command Terminator {{{
  641. syntax match ttCmdSep /;/
  642. \ containedin=ttCodeBlock,ttFuncBlock,ttForAllBlock,ttForEachBlock
  643. " }}}
  644. " Numbers {{{
  645. syntax match ttInt "\d\+"
  646. \ containedin=ttCodeBlock,ttValueBlock,ttTimeNameBlock,ttExpressionBlock,ttVarIndex,ttLoopLowerBlock,ttLoopUpperBlock,ttFuncBlock,ttSessionPort,ttSessionPortBlock
  647. syntax match ttFloat "\d\+.\d\+"
  648. \ containedin=ttCodeBlock,ttValueBlock,ttTimeNameBlock,ttExpressionBlock,ttVarIndex,ttLoopLowerBlock,ttLoopUpperBlock,ttFuncBlock,ttSessionPort,ttSessionPortBlock
  649. " }}}
  650. " Lazy Match Patterns {{{
  651. syntax match ttMatchLazy "%[wWdDsS?.+*]"
  652. \ contained
  653. \ containedin=ttPatternBlock,ttPatternBlockHigh,ttPatternBlockSub,ttUn,ttUnBlock,ttReplaceFormatBlock,ttString
  654. " }}}
  655. " Match Special Regex Chars {{{
  656. syntax match ttMatchSpecial "\^\|\~\|\$"
  657. \ contained
  658. \ containedin=ttPatternBlock,ttPatternBlockHigh,ttPatternBlockSub,ttReplaceFormatBlock
  659. " }}}
  660. " Format specifiers {{{
  661. syntax match ttFormat "%\%[.+-][0-9]\{-}[acdghlmnprstuwACLRTU]"
  662. \ contained
  663. \ containedin=ttFormatBlock,ttEchoBlock
  664. " }}}
  665. " RexEx {{{
  666. syntax match ttRegEx "\(\.\|+\|?\|*\||\)"
  667. \ contained
  668. \ containedin=ttRegExBlock
  669. syntax match ttRegExBraces "\()\|(\|\]\|\[\)"
  670. \ contained
  671. \ containedin=ttRegExBlock
  672. " }}}
  673. " Math and Bitwise Operators {{{
  674. syntax match ttOperators "\(<<\|>>\|==\|!=\|^^\|||\|&&\|[-+*%&/^|<>!=]\)"
  675. \ contained
  676. \ containedin=ttExpressionBlock
  677. syntax match ttOperatorsParen "[)(]"
  678. \ contained
  679. \ containedin=ttExpressionBlock
  680. " }}}
  681. " Color codes {{{
  682. syntax match ttColor "<\d\d\d>"
  683. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  684. syntax match ttColor "<[a-fA-F][a-fA-F][a-fA-F]>"
  685. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  686. syntax match ttColor "<[gG]\d\{2}>"
  687. \ containedin=ttFormatBlock,ttValueBlock,ttEchoBlock
  688. " }}}
  689. " Dynamic Variables {{{
  690. syntax match ttArgRef "%\d\{1,2}"
  691. \ containedin=ALLBUT,ttComment,ttNopComment
  692. syntax match ttRegExRef "&\d\{1,2}"
  693. \ containedin=ALLBUT,ttComment,ttNopComment
  694. " }}}
  695. " Character Escapes {{{
  696. syntax match ttEsc "\\[0abcenrt\\]"
  697. \ containedin=ALLBUT,ttComment,ttNopComment
  698. syntax match ttEsc "\\x\x\{2}"
  699. \ containedin=ALLBUT,ttComment,ttNopComment
  700. syntax match ttEsc "\\\d\d\d"
  701. \ containedin=ALLBUT,ttComment,ttNopComment
  702. " }}}
  703. " ANSI Escape/Control Codes {{{
  704. syntax match ttAnsiEsc /\\e\[[0-9;\\]\{-}m/
  705. \ containedin=ALLBUT,ttComment,ttNopComment
  706. " }}}
  707. " tintin Variables {{{
  708. syntax match ttVar "\$\%[{][a-zA-Z_]\+"
  709. \ nextgroup=ttVarIndex
  710. \ containedin=ALLBUT,ttComment,ttNopComment
  711. syntax match ttVar "&\%[{][a-zA-Z_]\+"
  712. \ nextgroup=ttVarIndex
  713. \ containedin=ALLBUT,ttComment,ttNopComment
  714. " }}}
  715. " Variable Blocks {{{
  716. syntax region ttVarBlock
  717. \ matchgroup=ttVarBraces start=/${/ end=/}/
  718. \ contains=ttVarIndex
  719. \ containedin=ALLBUT,ttComment,ttNopComment
  720. syntax region ttVarBlock
  721. \ matchgroup=ttVarBraces start=/&{/ end=/}/
  722. \ contains=ttVarIndex
  723. \ containedin=ALLBUT,ttComment,ttNopComment
  724. " }}}
  725. " Variable Index {{{
  726. syntax region ttVarIndex
  727. \ matchgroup=ttVarIndexBracket start=/\[/ end=/\]/
  728. \ contained
  729. \ containedin=ttVarBlock
  730. \ nextgroup=ttVarIndex
  731. " }}}
  732. " @function calls and the obligatory braces around the arguments {{{
  733. syntax region ttFuncBlock
  734. \ matchgroup=ttBracesFunction start=/{/ skip=/$/ end=/}/
  735. \ contains=ttCodeBlock
  736. \ contained
  737. syntax match ttFunction "@[A-Za-z_0-9]\+"
  738. \ containedin=ALLBUT,ttComment,ttNopComment
  739. \ nextgroup=ttFuncBlock
  740. " }}}
  741. " }}}
  742. " Comments {{{
  743. " #nop comments
  744. syntax region ttNopComment
  745. \ matchgroup=ttNop start="#nop" end=/\;\|$/
  746. " C-style multi-line comments
  747. syntax region ttComment start="/\*" end="\*/"
  748. syntax region ttCommentError start="/\*" end="\*/"
  749. \ contained
  750. \ containedin=ttCodeBlock
  751. " Special notes in Comments
  752. syntax keyword ttTodo TODO FIXME XXX BUG DEBUG
  753. \ contained
  754. \ containedin=ttComment,ttNopComment
  755. " }}}
  756. " Internal Highlink Linking {{{
  757. " Link ttCmd* to ttCmd Group {{{
  758. hi link ttCmdBranch ttCmd
  759. hi link ttCmdDebug ttCmd
  760. hi link ttCmdInput ttCmd
  761. hi link ttCmdLoop ttCmd
  762. hi link ttCmdRep ttCmd
  763. hi link ttCmdSwitch ttCmd
  764. hi link ttCmdTime ttCmd
  765. hi link ttCmdTrigger ttCmd
  766. hi link ttCmdUseless ttCmd
  767. hi link ttCmdVar ttCmd
  768. hi link ttCmdUn ttCmd
  769. hi link ttCmdScript ttCmd
  770. "}}}
  771. " Link Syntax Elements {{{
  772. hi link ttMatchLazy ttMacro
  773. hi link ttMatchSpecial ttMacro
  774. hi link ttFormat ttMacro
  775. hi link ttRegEx ttMacro
  776. hi link ttRegExBraces ttMacro
  777. hi link ttColor ttMacro
  778. hi link ttEsc ttMacro
  779. hi link ttAnsiEsc ttMacro
  780. hi link ttArgRef ttReference
  781. hi link ttRegExRef ttReference
  782. " }}}
  783. " tintin Lists and Sub commands are keywords {{{
  784. hi link ttListNameKill ttKeyword
  785. hi link ttListName ttKeyword
  786. hi link ttConfigBlock ttKeyword
  787. hi link ttListSub ttKeyword
  788. hi link ttPathSub1 ttKeyword
  789. hi link ttPathSub2 ttKeyword
  790. hi link ttPathSub3 ttKeyword
  791. hi link ttLogSub ttKeyword
  792. hi link ttClassSub1 ttKeyword
  793. hi link ttClassSub2 ttKeyword
  794. hi link ttHistSub1 ttKeyword
  795. hi link ttHistSub2 ttKeyword
  796. hi link ttHistSub3 ttKeyword
  797. hi link ttEventBlock ttKeyword
  798. hi link ttCursorBlock ttKeyword
  799. hi link ttBufferSub1 ttKeyword
  800. hi link ttBufferSub2 ttKeyword
  801. hi link ttBufferSub3 ttKeyword
  802. hi link ttLineSub1 ttKeyword
  803. hi link ttLineSub2 ttKeyword
  804. hi link ttLineSub3 ttKeyword
  805. hi link ttLineSub4 ttKeyword
  806. hi link ttLineSubSub ttKeyword
  807. " }}}
  808. hi link ttSessionURIBlock ttSessionURI
  809. hi link ttSessionURI ttString
  810. " Link all Braces together {{{
  811. hi link ttBracesMatch ttBraces
  812. hi link ttBracesFormat ttBraces
  813. hi link ttBracesValue ttBraces
  814. hi link ttBracesExpression ttBraces
  815. hi link ttVarIndexBracket ttBraces
  816. hi link ttRegExBraces ttBraces
  817. hi link ttOperatorsParen ttBraces
  818. hi link ttSubBrace ttBraces
  819. " }}}
  820. hi link ttBracesFunction ttFunction
  821. " Link Various Variable Names to ttVarName {{{
  822. hi link ttLoopVarBlock ttVarName
  823. hi link ttMathVarBlock ttVarName
  824. hi link ttFormatVarBlock ttVarName
  825. hi link ttRegexVarBlock ttVarName
  826. hi link ttReplaceVarBlock ttVarName
  827. hi link ttVarVarBlock ttVarName
  828. hi link ttListVarBlock ttVarName
  829. hi link ttPathVarBlock ttVarName
  830. hi link ttVarVar ttVarName
  831. hi link ttMathVar ttVarName
  832. hi link ttFormatVar ttVarName
  833. hi link ttRegexVar ttVarName
  834. hi link ttReplaceVar ttVarName
  835. hi link ttListVar ttVarName
  836. hi link ttPathVar ttVarName
  837. hi link ttScriptVarNameVar ttVarName
  838. " }}}
  839. " Link all pattern blocks together {{{
  840. hi link ttPatternBlockHigh ttPatternBlock
  841. hi link ttPatternBlockSub ttPatternBlock
  842. " }}}
  843. " Link all names to ttIdentifier {{{
  844. hi link ttClassName ttIdentifier
  845. hi link ttClassNameBlock ttIdentifier
  846. hi link ttTimeNameBlock ttIdentifier
  847. hi link ttSessionNameBlock ttIdentifier
  848. hi link ttSessionName ttIdentifier
  849. hi link ttRunSessionNameBlock ttIdentifier
  850. hi link ttRunSessionName ttIdentifier
  851. hi link ttUnBlock ttIdentifier
  852. hi link ttUn ttIdentifier
  853. " }}}
  854. " Link various number types to ttNumber {{{
  855. hi link ttInt ttNumber
  856. hi link ttFloat ttNumber
  857. " }}}
  858. hi link ttFunctionNameBlock ttFunction
  859. hi link ttFileNameBlock ttFileName
  860. hi link ttScriptShell ttShellCmd
  861. hi link ttVarBlock ttVar
  862. hi link ttVarBraces ttVar
  863. hi link ttNopComment ttComment
  864. hi link ttNop ttCmd
  865. hi link ttCommentError ttError
  866. hi link ttErrorBlock ttError
  867. " }}}
  868. " Link tt Highlighting Groups to Default Groups {{{
  869. hi default link ttVar Special
  870. hi default link ttCmd Statement
  871. hi default link ttBraces Delimiter
  872. hi default link ttCmdSep Delimiter
  873. hi default link ttFileName Character
  874. hi default link ttReference Special
  875. hi default link ttMacro Macro
  876. hi default link ttKeyword Keyword
  877. hi default link ttFunction Function
  878. hi default link ttShellCmd Character
  879. hi default link ttVarName Identifier
  880. hi default link ttIdentifier Identifier
  881. hi default link ttNumber Number
  882. hi default link ttString String
  883. hi default link ttOperators Operator
  884. hi default link ttCodeBlock Structure
  885. hi default link ttTodo Todo
  886. hi default link ttComment Comment
  887. hi default link ttError Error
  888. " }}}
  889. let b:current_syntax = "tt"