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=tctNodeBird,tctNodeColon,tctNodeComment,tctNodeUL,tctNodeOL,tctNodeBracket
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=tctNodeAt nextgroup=tctValueAt
30 syn match tctRowBar /[^<>:=| ]* *|/ contained contains=tctNodeBar nextgroup=tctValueBar
31 syn match tctRowBird /[^<>:=| ]* *>/ contained contains=tctNodeBird nextgroup=tctValueBird
32 syn match tctRowColon /[^<>:=| ]* *:\ze\( \|$\)/ contained contains=tctNodeColon nextgroup=tctValueColon
33 syn match tctRowEqual /[^<>:=| ]* *=/ contained contains=tctNodeEqual nextgroup=tctValueEqual
34 syn match tctRowBracket /\[[^]]*\]/ contained contains=tctNodeBracket nextgroup=tctValueBracket
35 syn match tctRowComment /-- / contained contains=tctNodeComment nextgroup=tctValueComment
36 syn match tctRowUL /-\ze / contained contains=tctNodeUL nextgroup=tctValueUL
37 syn match tctRowOL /\( *\d\+\.\)\+\ze\( \|$\)/ contained contains=tctNodeOL nextgroup=tctValueOL
38 syn match tctRowSection /#\+\ze / contained contains=tctNodeSection nextgroup=tctValueSection
40 syn match tctNodeAt /[^<>:=| ]* *@/ contained contains=tctSymAt,tctSymDot
41 syn match tctNodeBar /[^<>:=| ]* *|/ contained contains=tctSymBar,tctSymDot
42 syn match tctNodeBird /[^<>:=| ]* *>/ contained contains=tctSymBird,tctSymDot
43 syn match tctNodeColon /[^<>:=| ]* *:\ze\( \|$\)/ contained contains=tctSymColon,@tctColons,tctSymDot
44 syn match tctNodeEqual /[^<>:=| ]* *=/ contained contains=tctSymEqual,tctSymDot
45 syn match tctNodeBracket /\[[^]]*\]/ contained contains=tctSymBracket,@tctInline
46 syn match tctNodeComment /--/ contained
47 syn match tctNodeUL /-/ contained
48 syn match tctNodeOL /\( *\d\+\.\)\+/ contained contains=tctSymDot
49 syn match tctNodeSection /#\+/ 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 tctNodeAt cterm=NONE ctermfg=yellow guifg=yellow
74 hi tctNodeBar cterm=NONE ctermfg=DarkYellow guifg=yellow
75 hi tctNodeBird cterm=NONE ctermfg=DarkYellow guifg=yellow
76 hi tctNodeColon cterm=bold ctermfg=yellow guifg=yellow
77 hi tctNodeEqual cterm=bold ctermfg=DarkGrey guifg=yellow
78 hi tctNodeBracket cterm=NONE ctermfg=NONE guifg=NONE
79 hi tctNodeComment cterm=bold ctermfg=DarkGrey guifg=grey
80 hi tctNodeUL cterm=bold ctermfg=yellow guifg=yellow
81 hi tctNodeOL cterm=bold ctermfg=yellow guifg=yellow
82 hi tctNodeSection 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
145 syn match tctUnderline
146 \ /\(^\|[ *`’«»/"'’|,.:;@!?=~<>%(){}[\]\\#&+-]\)\zs_.*_\ze\([ *`’«»/"'’|,.:;@!?=~<>%(){}[\]\\#&+-]\|$\)/
147 \ contained contains=@tctInline
149 \ /[a-z+-]\+:\/\/[^| \t[\]]*\(\[[^\]]*\]\)\?/
150 \ contained contains=tctURLText
152 \ /\(\[\zs[^\]]*\ze\]\)\?/
153 \ contained contains=@tctInline
154 syn match tctEntity "&[^; \t]*;" contained contains=tctEntityPunct
155 syn match tctEntityPunct contained "[&.;]"
157 \ matchgroup=tctElem start=/<\ze[^ /!?<>"']/
158 \ matchgroup=tctElem end=/>/
159 \ contained contains=tctElemName,tctAttr,tctSymEqual,tctAttrValue
160 syn region tctElemEnd
161 \ matchgroup=tctElem start=/<\/\ze[^ /!?<>"']/
162 \ matchgroup=tctElem end=/>/
163 \ contained contains=tctElemName,tctAttrPunct
164 syn match tctNamespace
165 \ +\(<\|</\)\@2<=[^ /!?<>"':]\+\ze[:]+
167 syn match tctElemName
168 \ /\(<\|<\/\)\@2<=[^ /!?<>"']\+/
169 \ contained contains=tctNamespace,tctAttrPunct
171 \ +[-'"<]\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>\%(['">]\@!\|$\)+
172 \ contained contains=tctAttrPunct
173 syn match tctAttrPunct +[:.]+ contained
174 syn region tctAttrValue contained start=+"+ end=+"+ contains=tctEntity
175 syn region tctAttrValue contained start=+'+ end=+'+ contains=tctEntity
178 syn cluster tctInline contains=tctBold,tctCode,tctElem,tctElemEnd,tctEntity,tctQuoteFrench,tctItalic,tctQuote,tctTag,tctUnderline,tctURL
181 hi def link tctAttr Type
182 hi def link tctAttrPunct Comment
183 hi tctBold cterm=bold gui=bold
184 hi tctCode cterm=reverse ctermfg=white gui=reverse
185 hi tctESym cterm=bold ctermfg=cyan guifg=cyan
186 hi def link tctEntity Statement
187 hi def link tctEntityPunct Type
188 hi tctItalic cterm=italic gui=italic
189 hi def link tctNamespace Tag
190 hi tctQuote cterm=bold ctermfg=cyan guifg=cyan
191 hi tctQuoteFrench cterm=bold ctermfg=green guifg=green
192 hi tctTag cterm=bold ctermfg=cyan guifg=cyan
193 hi def link tctElem Function
194 hi def link tctElemEnd Identifier
195 hi tctElemName cterm=bold ctermfg=yellow guifg=yellow
196 hi def link tctAttrValue String
197 hi def link tctTodo Todo
198 hi def link tctURL Macro
199 hi def link tctURLText tctNormal
200 hi tctUnderline cterm=underline gui=underline
202 let b:current_syntax = "tct"