blob: e9562d65083be09e669239927e8acc759fc1232d [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: TCL/TK
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00003" Maintainer: Brett Cannon <brett@python.org>
4" (previously Dean Copsey <copsey@cs.ucdavis.edu>)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" (previously Matt Neumann <mattneu@purpleturtle.com>)
6" (previously Allan Kelly <allan@fruitloaf.co.uk>)
7" Original: Robin Becker <robin@jessikat.demon.co.uk>
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00008" Last Change: 2006 Nov 17
Bram Moolenaar071d4272004-06-13 20:20:40 +00009"
10" Keywords TODO: format clock click anchor
11
12" For version 5.x: Clear all syntax items
13" For version 6.x: Quit when a syntax file was already loaded
14if version < 600
15 syntax clear
16elseif exists("b:current_syntax")
17 finish
18endif
19
20" A bunch of useful keywords
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000021syn keyword tclStatement tell socket subst open eof pwd glob list exec pid
22syn keyword tclStatement auto_load_index time unknown eval lrange fblocked
23syn keyword tclStatement lsearch auto_import gets lappend proc variable llength
24syn keyword tclStatement auto_execok return linsert error catch clock info
25syn keyword tclStatement split array fconfigure concat join lreplace source
26syn keyword tclStatement fcopy global auto_qualify update close cd auto_load
27syn keyword tclStatement file append format read package set binary namespace
28syn keyword tclStatement scan trace seek flush after vwait uplevel lset rename
29syn keyword tclStatement fileevent regexp upvar unset encoding expr load regsub
30syn keyword tclStatement interp exit puts incr lindex lsort tclLog string
Bram Moolenaar071d4272004-06-13 20:20:40 +000031syn keyword tclLabel case default
32syn keyword tclConditional if then else elseif switch
33syn keyword tclRepeat while for foreach break continue
34syn keyword tcltkSwitch contained insert create polygon fill outline tag
35
36" WIDGETS
37" commands associated with widgets
38syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
39syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
40syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
41syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
42syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
43syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
44syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
45syn keyword tcltkWidgetSwitch contained state tabs width wrap
46" button
47syn keyword tcltkWidgetSwitch contained command default
48" canvas
49syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
50" checkbutton, radiobutton
51syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
52" entry, frame
53syn keyword tcltkWidgetSwitch contained show class colormap container visual
54" listbox, menu
55syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
56" menubutton, message
57syn keyword tcltkWidgetSwitch contained direction aspect justify
58" scale
59syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
60" scrollbar
61syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
62" image
63syn keyword tcltkWidgetSwitch contained delete names types create
64" variable reference
65 " ::optional::namespaces
66syn match tclVarRef "$\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"
67 " ${...} may contain any character except '}'
68syn match tclVarRef "${[^}]*}"
69" menu, mane add
70syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
71syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
72syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
73syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
74syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
75syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
76"syn keyword tcltkWidgetSwitch contained
77"syn match tcltkWidgetSwitch contained
78syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
79syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
80
81syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
82syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
83syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
84syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
85syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
86syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
87syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
88syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
89syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
90syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
91" These words are dual purpose.
92" match switches
93"syn match tcltkWidgetSwitch contained "-text"hs=s+1
94syn match tcltkWidgetSwitch contained "-text\(var\)\?"hs=s+1
95syn match tcltkWidgetSwitch contained "-menu"hs=s+1
96syn match tcltkWidgetSwitch contained "-label"hs=s+1
97" match commands - 2 lines for pretty match.
98"variable
99" Special case - If a number follows a variable region, it must be at the end of
100" the pattern, by definition. Therefore, (1) either include a number as the region
101" end and exclude tclNumber from the contains list, or (2) make variable
102" keepend. As (1) would put variable out of step with everything else, use (2).
103syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
104syn region tcltkCommand matchgroup=tcltkCommandColor start="\s\<variable\>\|\[\<variable\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
105" menu
106syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
107syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<menu\>\|\[\<menu\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
108" label
109syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
110syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<label\>\|\[\<label\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
111" text
112syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
113syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<text\>\|\[\<text\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
114
115" This isn't contained (I don't think) so it's OK to just associate with the Color group.
116" TODO: This could be wrong.
117syn keyword tcltkWidgetColor toplevel
118
119
120syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend
121syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
122
123
124" NAMESPACE
125" commands associated with namespace
126syn keyword tcltkNamespaceSwitch contained children code current delete eval
127syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
128syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
129syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkNamespaceSwitch
130
131" EXPR
132" commands associated with expr
133syn keyword tcltkMaths contained acos cos hypot sinh
134syn keyword tcltkMaths contained asin cosh log sqrt
135syn keyword tcltkMaths contained atan exp log10 tan
136syn keyword tcltkMaths contained atan2 floor pow tanh
137syn keyword tcltkMaths contained ceil fmod sin
138syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
139
140" format
141syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
142
143" PACK
144" commands associated with pack
145syn keyword tcltkPackSwitch contained forget info propogate slaves
146syn keyword tcltkPackConfSwitch contained after anchor before expand fill in ipadx ipady padx pady side
147syn region tcltkCommand matchgroup=tcltkCommandColor start="\<pack\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkPackSwitch,tcltkPackConf,tcltkPackConfSwitch,tclNumber,tclVarRef,tclString,tcltkCommand keepend
148
149" STRING
150" commands associated with string
151syn keyword tcltkStringSwitch contained compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
152syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
153
154" ARRAY
155" commands associated with array
156syn keyword tcltkArraySwitch contained anymore donesearch exists get names nextelement size startsearch set
157" match from command name to ] or EOL
158syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
159
160" LSORT
161" switches for lsort
162syn keyword tcltkLsortSwitch contained ascii dictionary integer real command increasing decreasing index
163" match from command name to ] or EOL
164syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
165
166syn keyword tclTodo contained TODO
167
168
169" String and Character contstants
170" Highlight special characters (those which have a backslash) differently
171syn match tclSpecial contained "\\\d\d\d\=\|\\."
172" A string needs the skip argument as it may legitimately contain \".
173" Match at start of line
174syn region tclString start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
175"Match all other legal strings.
176syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
177
178syn match tclLineContinue "\\\s*$"
179
180"integer number, or floating point number without a dot and with "f".
181syn case ignore
182syn match tclNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
183"floating point number, with dot, optional exponent
184syn match tclNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
185"floating point number, starting with a dot, optional exponent
186syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
187"floating point number, without dot, with exponent
188syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>"
189"hex number
190syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
191"syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>"
192syn case match
193
194syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo
195syn region tclComment start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo
196
197"syn sync ccomment tclComment
198
199" Define the default highlighting.
200" For version 5.7 and earlier: only when not done already
201" For version 5.8 and later: only when an item doesn't have highlighting yet
202if version >= 508 || !exists("did_tcl_syntax_inits")
203 if version < 508
204 let did_tcl_syntax_inits = 1
205 command -nargs=+ HiLink hi link <args>
206 else
207 command -nargs=+ HiLink hi def link <args>
208 endif
209
210 HiLink tcltkSwitch Special
211 HiLink tclLabel Label
212 HiLink tclConditional Conditional
213 HiLink tclRepeat Repeat
214 HiLink tclNumber Number
215 HiLink tclError Error
216 HiLink tclStatement Statement
217 "HiLink tclStatementColor Statement
218 HiLink tclString String
219 HiLink tclComment Comment
220 HiLink tclSpecial Special
221 HiLink tclTodo Todo
222 " Below here are the commands and their options.
223 HiLink tcltkCommandColor Statement
224 HiLink tcltkWidgetColor Structure
225 HiLink tclLineContinue WarningMsg
226 HiLink tcltkStringSwitch Special
227 HiLink tcltkArraySwitch Special
228 HiLink tcltkLsortSwitch Special
229 HiLink tcltkPackSwitch Special
230 HiLink tcltkPackConfSwitch Special
231 HiLink tcltkMaths Special
232 HiLink tcltkNamespaceSwitch Special
233 HiLink tcltkWidgetSwitch Special
234 HiLink tcltkPackConfColor Identifier
235 "HiLink tcltkLsort Statement
236 HiLink tclVarRef Identifier
237
238 delcommand HiLink
239endif
240
241let b:current_syntax = "tcl"
242
243" vim: ts=8