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