1 " Language: Texte Convivial Technique (TCT)
2 " License: GNU General Public License, version 3 or later (at your option)
3 " Maintainer: Julien Moutinho <julm+hdoc@autogeree.net>
4 " URL: git://git.autogeree.net/hdoc
7 " Copy this file to ~/.vim/syntax/tct.vim
8 " then add this line to ~/.vimrc :
9 " autocmd BufNewFile,BufRead *.tct set filetype=tct
11 if exists("b:current_syntax")
20 syn match tctPlain /.\+/ contains=@tctInline
21 hi def link tctPlain Normal
24 syn match tctPath /^\( *\([^<>:=| *`«»/"_,.;@^!?~%(){}[\]\\#&+]* *[:>]\|\[[^]]*\]\|- \|\( *\d\+\.\)\+\)\)* *\ze\([^<>:=| *`«»/"_,.;@^!?~%(){}[\]\\#&+]*\(@ \| *[>=|]\| *: \| *:$\)\|\[[^]]*\]\|-- \|- \|\( *\d\+\.\)\+\|@ \|#\+ \)/
25 \ contains=tctHeaderBird,tctHeaderColon,tctHeaderComment,tctHeaderUL,tctHeaderOL,tctHeaderBracket
26 \ nextgroup=@tctRowPath
27 syn cluster tctRowPath
28 \ contains=tctRowAt,tctRowBird,tctRowColon,tctRowEqual,tctRowBar,tctRowComment,tctRowUL,tctRowOL,tctRowBracket,tctRowSection
29 syn match tctRowAt /[^<>:=| ]*@ / contained contains=tctHeaderAt nextgroup=tctValueAt
30 syn match tctRowBar /[^<>:=| ]* *|/ contained contains=tctHeaderBar nextgroup=tctValueBar
31 syn match tctRowBird /[^<>:=| ]* *>/ contained contains=tctHeaderBird nextgroup=tctValueBird
32 syn match tctRowColon /[^<>:=| ]* *:\ze\( \|$\)/ contained contains=tctHeaderColon nextgroup=tctValueColon
33 syn match tctRowEqual /[^<>:=| ]* *=/ contained contains=tctHeaderEqual nextgroup=tctValueEqual
34 syn match tctRowBracket /\[[^]]*\]/ contained contains=tctHeaderBracket nextgroup=tctValueBracket
35 syn match tctRowComment /-- / contained contains=tctHeaderComment nextgroup=tctValueComment
36 syn match tctRowUL /-\ze / contained contains=tctHeaderUL nextgroup=tctValueUL
37 syn match tctRowOL /\( *\d\+\.\)\+\ze\( \|$\)/ contained contains=tctHeaderOL nextgroup=tctValueOL
38 syn match tctRowSection /#\+\ze / contained contains=tctHeaderSection nextgroup=tctValueSection
40 syn match tctHeaderAt /[^<>:=| ]*@ / contained contains=tctSymAt,tctSymDot
41 syn match tctHeaderBar /[^<>:=| ]* *|/ contained contains=tctSymBar,tctSymDot
42 syn match tctHeaderBird /[^<>:=| ]* *>/ contained contains=tctSymBird,tctSymDot
43 syn match tctHeaderColon /[^<>:=| ]* *:\ze\( \|$\)/ contained contains=tctSymColon,@tctColons,tctSymDot
44 syn match tctHeaderEqual /[^<>:=| ]* *=/ contained contains=tctSymEqual,tctSymDot
45 syn match tctHeaderBracket /\[[^]]*\]/ contained contains=tctSymBracket,@tctInline
46 syn match tctHeaderComment /--/ contained
47 syn match tctHeaderUL /-/ contained
48 syn match tctHeaderOL /\( *\d\+\.\)\+/ contained contains=tctSymDot
49 syn match tctHeaderSection /#\+/ contained
51 syn match tctSymAt /@/ contained
52 syn match tctSymBar /|/ contained
53 syn match tctSymBird />/ contained
54 syn match tctSymColon /:/ contained
55 syn match tctSymDot /[.]/ contained
56 syn match tctSymEqual /=/ contained
57 syn match tctSymBracket /\(\[\|\]\)/ contained
59 syn match tctValueAt /.*/ contained contains=@tctURL
60 syn match tctValueBar /.*/ contained
61 syn match tctValueBird /.*/ contained contains=@tctInline
62 syn match tctValueColon /.*/ contained contains=@tctInline
63 syn match tctValueEqual /.*/ contained contains=@tctInline
64 syn match tctValueBracket /.*/ contained contains=@tctInline
65 syn match tctValueComment /.*/ contained
66 syn match tctValueUL /.*/ contained contains=@tctInline
67 syn match tctValueOL /.*/ contained contains=@tctInline
68 syn match tctValueSection /.*/ contained contains=@tctInline
70 "syn match tctSection /^ *#\+ .*/ contains=@tctInline
73 hi tctHeaderAt cterm=NONE ctermfg=yellow guifg=yellow
74 hi tctHeaderBar cterm=NONE ctermfg=DarkYellow guifg=yellow
75 hi tctHeaderBird cterm=NONE ctermfg=DarkYellow guifg=yellow
76 hi tctHeaderColon cterm=bold ctermfg=yellow guifg=yellow
77 hi tctHeaderEqual cterm=bold ctermfg=DarkGrey guifg=yellow
78 hi tctHeaderBracket cterm=NONE ctermfg=NONE guifg=NONE
79 hi tctHeaderComment cterm=bold ctermfg=DarkGrey guifg=grey
80 hi tctHeaderUL cterm=bold ctermfg=yellow guifg=yellow
81 hi tctHeaderOL cterm=bold ctermfg=yellow guifg=yellow
82 hi tctHeaderSection cterm=bold ctermfg=magenta guifg=magenta gui=bold
84 hi tctSymAt cterm=bold ctermfg=cyan guifg=cyan
85 hi tctSymBar cterm=bold ctermfg=cyan guifg=cyan
86 hi tctSymBird cterm=bold ctermfg=cyan guifg=cyan
87 hi tctSymColon cterm=bold ctermfg=cyan guifg=cyan
88 hi tctSymDot cterm=bold ctermfg=DarkGrey guifg=grey
89 hi tctSymEqual cterm=bold ctermfg=cyan guifg=cyan
90 hi tctSymBracket cterm=bold ctermfg=cyan guifg=cyan
92 hi tctValueAt cterm=bold gui=bold
93 hi def link tctValueBar Normal
94 hi tctValueColon cterm=bold gui=bold
95 hi tctValueBird cterm=NONE gui=NONE
96 hi tctValueEqual cterm=NONE gui=NONE
97 hi tctValueComment ctermfg=DarkGrey cterm=bold gui=NONE guifg=grey
98 hi tctValueUL cterm=NONE gui=NONE
99 hi tctValueOL cterm=NONE gui=NONE
101 hi tctComment cterm=bold ctermfg=DarkGrey guifg=grey
102 hi tctRowSection cterm=bold ctermfg=magenta guifg=magenta gui=bold
103 hi tctValueSection cterm=bold ctermfg=magenta guifg=magenta gui=bold
106 " Semantic node names, these are not necessary but improves the view.
107 syn cluster tctColons contains=tctColonDONE,tctColonSOLVED,tctColonTODO
108 syn match tctColonDONE /\<DONE\ze *:/ contained
109 syn match tctColonSOLVED /\<SOLVED\ze *:/ contained
110 syn match tctColonTODO /\<TODO\ze *:/ contained
111 hi tctColonDONE ctermfg=green
112 hi tctColonSOLVED ctermfg=green
113 hi tctColonTODO ctermfg=red
115 syn cluster tctBlock contains=tctPath,tctSection
119 \ /\(^\|[ `’«»/"|,.:…;@^!?=~%(){}[\]\\&+]\)\zs\*[^ *]\([^*]*[^ *]\)\?\*\ze\([ `’«»/"|,.:…;@^!?=~%(){}[\]\\&+]\|$\)/
120 \ contained contains=@tctInline
122 \ /\(^\|[ *’«»/"|,.:…;@^!?=~%(){}[\]\\&+]\)\zs`[^ `]\([^`]*[^ `]\)\?`\ze\([ *’«»/"|,.:…;@^!?=~%(){}[\]\\&+]\|$\)/
123 \ contained contains=@tctInline
125 \ /<\/\?[^ >]\+\/\?>/
126 \ contained contains=tctESym,tctEAttr
133 syn match tctQuoteFrench
135 \ contained contains=@tctInline
137 \ /\(^\|[ *`’«»"'’|,.:…;@^!?=~<>%(){}[\]\\#&+]\)\zs\/[^ /]\([^/]*[^ /]\)\?\/\ze\([ *`’«»"'’|,.:…;@^!?=~<>%(){}[\]\\#&+]\|$\)/
138 \ contained contains=@tctInline
140 \ /\(^\|[ *`’«»/'’|,.:…;@^!?=~<>%(){}[\]\\#&+]\)\zs"[^ "]\([^"]*[^ "]\)\?"\ze\([ *`’«»/'’|,.:…;@^!?=~<>%(){}[\]\\#&+]\|$\)/
141 \ contained contains=@tctInline
143 \ /\(^\|[ *`’«»/"'’|,.:…;^!?=~<>%(){}[\]\\#&+]\)\zs@\([^ @]\([^@]*[^ @]\)\?@\|[^@ *`’«»/"'’|,.:…;^!?=~<>%(){}[\]\\#&+]*[^@ *`’«»/"'’|,.:…;^!?=~<>%(){}[\]\\#&+]\)\ze\([ *`’«»/"'’|,.:…;^!?=~<>%(){}[\]\\#&+]\|$\)/
144 \ contained contains=@tctInline
146 \ /\(^\|[ *`’«»/"'’|,.:…;@^!?=~<>%(){}[\]\\&+]\)\zs#\([^ #]\([^#]*[^ #]\)\?#\|[^# *`’«»/"'’|,.:…;@^!?=~<>%(){}[\]\\&+]*[^# *`’«»/"'’|,.:…;@^!?=~<>%(){}[\]\\&+]\)\ze\([ *`’«»/"'’|,.:…;@^!?=~<>%(){}[\]\\&+]\|$\)/
147 \ contained contains=@tctInline
149 \ /\(^\|[ *`’«»/"'’|,.:…;@^!?=~<>%(){}\\#&+]\)\zs\[[^[\] ]*\]\ze\([ *`’«»/"'’|,.:…;@^!?=~<>%(){}\\#&+]\|$\)/
150 \ contained contains=@tctInline
151 syn match tctUnderline
152 \ /\(^\|[ *`’«»/"'’|,.:…;@!?=~<>%(){}[\]\\#&+]\)\zs_.*_\ze\([ *`’«»/"'’|,.:…;@!?=~<>%(){}[\]\\#&+]\|$\)/
153 \ contained contains=@tctInline
155 \ /[a-z+-]\+:\/\/[^| \t[\]]*\(\[[^\]]*\]\)\?/
156 \ contained contains=tctURLText
158 \ /\(\[\zs[^\]]*\ze\]\)\?/
159 \ contained contains=@tctInline
160 syn match tctEntity "&[^; \t]*;" contained contains=tctEntityPunct
161 syn match tctEntityPunct contained "[&.;]"
163 \ matchgroup=tctElem start=/<\ze[^ /!?<>"']/
164 \ matchgroup=tctElem end=/>/
165 \ contained contains=tctElemName,tctAttr,tctSymEqual,tctAttrValue
166 syn region tctElemEnd
167 \ matchgroup=tctElem start=/<\/\ze[^ /!?<>"']/
168 \ matchgroup=tctElem end=/>/
169 \ contained contains=tctElemName,tctAttrPunct
170 syn match tctNamespace
171 \ +\(<\|</\)\@2<=[^ /!?<>"':]\+\ze[:]+
173 syn match tctElemName
174 \ /\(<\|<\/\)\@2<=[^ /!?<>"']\+/
175 \ contained contains=tctNamespace,tctAttrPunct
177 \ +[-'"<]\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>\%(['">]\@!\|$\)+
178 \ contained contains=tctAttrPunct
179 syn match tctAttrPunct +[:.]+ contained
180 syn region tctAttrValue contained start=+"+ end=+"+ contains=tctEntity
181 syn region tctAttrValue contained start=+'+ end=+'+ contains=tctEntity
184 syn cluster tctInline contains=tctBold,tctCode,tctElem,tctElemEnd,tctEntity,tctQuoteFrench,tctItalic,tctQuote,tctAt,tctTag,tctRef,tctUnderline,tctURL
187 hi def link tctAttr Type
188 hi def link tctAttrPunct Comment
189 hi tctBold cterm=bold gui=bold
190 hi tctCode cterm=reverse ctermfg=white gui=reverse
191 hi tctESym cterm=bold ctermfg=cyan guifg=cyan
192 hi def link tctEntity Statement
193 hi def link tctEntityPunct Type
194 hi tctItalic cterm=italic gui=italic
195 hi def link tctNamespace Tag
196 hi tctQuote cterm=bold ctermfg=cyan guifg=cyan
197 hi tctQuoteFrench cterm=bold ctermfg=green guifg=green
198 hi tctTag cterm=bold ctermfg=cyan guifg=cyan
199 hi tctAt ctermfg=red cterm=NONE guifg=DarkRed
200 hi tctRef ctermfg=cyan cterm=NONE guifg=DarkCyan
201 hi def link tctElem Function
202 hi def link tctElemEnd Identifier
203 hi tctElemName cterm=bold ctermfg=yellow guifg=yellow
204 hi def link tctAttrValue String
205 hi def link tctTodo Todo
206 hi def link tctURL Macro
207 hi def link tctURLText tctNormal
208 hi tctUnderline cterm=underline gui=underline
210 let b:current_syntax = "tct"