tt.vim 27 KB

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