tt.vim 27 KB

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