Merged from the latest developing branch.
[MacVim/jjgod.git] / runtime / syntax / tcl.vim
blobe9562d65083be09e669239927e8acc759fc1232d
1 " Vim syntax file
2 " Language:     TCL/TK
3 " Maintainer:   Brett Cannon <brett@python.org>
4 "               (previously Dean Copsey <copsey@cs.ucdavis.edu>)
5 "               (previously Matt Neumann <mattneu@purpleturtle.com>)
6 "               (previously Allan Kelly <allan@fruitloaf.co.uk>)
7 " Original:     Robin Becker <robin@jessikat.demon.co.uk>
8 " Last Change:  2006 Nov 17
10 " Keywords TODO: format clock click anchor
12 " For version 5.x: Clear all syntax items
13 " For version 6.x: Quit when a syntax file was already loaded
14 if version < 600
15   syntax clear
16 elseif exists("b:current_syntax")
17   finish
18 endif
20 " A bunch of useful keywords
21 syn keyword tclStatement  tell socket subst open eof pwd glob list exec pid
22 syn keyword tclStatement  auto_load_index time unknown eval lrange fblocked
23 syn keyword tclStatement  lsearch auto_import gets lappend proc variable llength
24 syn keyword tclStatement  auto_execok return linsert error catch clock info
25 syn keyword tclStatement  split array fconfigure concat join lreplace source
26 syn keyword tclStatement  fcopy global auto_qualify update close cd auto_load
27 syn keyword tclStatement  file append format read package set binary namespace
28 syn keyword tclStatement  scan trace seek flush after vwait uplevel lset rename
29 syn keyword tclStatement  fileevent regexp upvar unset encoding expr load regsub
30 syn keyword tclStatement interp exit puts incr lindex lsort tclLog string
31 syn keyword tclLabel            case default
32 syn keyword tclConditional      if then else elseif switch
33 syn keyword tclRepeat           while for foreach break continue
34 syn keyword tcltkSwitch contained       insert create polygon fill outline tag
36 " WIDGETS
37 " commands associated with widgets
38 syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
39 syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
40 syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
41 syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
42 syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
43 syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
44 syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
45 syn keyword tcltkWidgetSwitch contained state tabs width wrap
46 " button
47 syn keyword tcltkWidgetSwitch contained command default
48 " canvas
49 syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
50 " checkbutton, radiobutton
51 syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
52 " entry, frame
53 syn keyword tcltkWidgetSwitch contained show class colormap container visual
54 " listbox, menu
55 syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
56 " menubutton, message
57 syn keyword tcltkWidgetSwitch contained direction aspect justify
58 " scale
59 syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
60 " scrollbar
61 syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
62 " image
63 syn keyword tcltkWidgetSwitch contained delete names types create
64 " variable reference
65         " ::optional::namespaces
66 syn match tclVarRef "$\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"
67         " ${...} may contain any character except '}'
68 syn match tclVarRef "${[^}]*}"
69 " menu, mane add
70 syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
71 syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
72 syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
73 syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
74 syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
75 syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
76 "syn keyword tcltkWidgetSwitch contained
77 "syn match tcltkWidgetSwitch contained
78 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
79 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
81 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
82 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
83 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
84 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
85 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
86 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
87 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
88 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
89 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
90 syn 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
94 syn match tcltkWidgetSwitch contained "-text\(var\)\?"hs=s+1
95 syn match tcltkWidgetSwitch contained "-menu"hs=s+1
96 syn 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).
103 syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
104 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
105 " menu
106 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
107 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
108 " label
109 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
110 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
111 " text
112 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
113 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
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.
117 syn keyword tcltkWidgetColor    toplevel
120 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
121 syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
124 " NAMESPACE
125 " commands associated with namespace
126 syn keyword tcltkNamespaceSwitch contained children code current delete eval
127 syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
128 syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
129 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkNamespaceSwitch
131 " EXPR
132 " commands associated with expr
133 syn keyword tcltkMaths  contained       acos    cos     hypot   sinh
134 syn keyword tcltkMaths  contained       asin    cosh    log     sqrt
135 syn keyword tcltkMaths  contained       atan    exp     log10   tan
136 syn keyword tcltkMaths  contained       atan2   floor   pow     tanh
137 syn keyword tcltkMaths  contained       ceil    fmod    sin
138 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
140 " format
141 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
143 " PACK
144 " commands associated with pack
145 syn keyword tcltkPackSwitch     contained       forget info propogate slaves
146 syn keyword tcltkPackConfSwitch contained       after anchor before expand fill in ipadx ipady padx pady side
147 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
149 " STRING
150 " commands associated with string
151 syn keyword tcltkStringSwitch   contained       compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
152 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
154 " ARRAY
155 " commands associated with array
156 syn keyword tcltkArraySwitch    contained       anymore donesearch exists get names nextelement size startsearch set
157 " match from command name to ] or EOL
158 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
160 " LSORT
161 " switches for lsort
162 syn keyword tcltkLsortSwitch    contained       ascii dictionary integer real command increasing decreasing index
163 " match from command name to ] or EOL
164 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
166 syn keyword tclTodo contained   TODO
169 " String and Character contstants
170 " Highlight special characters (those which have a backslash) differently
171 syn match   tclSpecial contained "\\\d\d\d\=\|\\."
172 " A string needs the skip argument as it may legitimately contain \".
173 " Match at start of line
174 syn region  tclString             start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
175 "Match all other legal strings.
176 syn region  tclString             start=+[^\\]"+ms=s+1  end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
178 syn match   tclLineContinue "\\\s*$"
180 "integer number, or floating point number without a dot and with "f".
181 syn case ignore
182 syn match  tclNumber            "\<\d\+\(u\=l\=\|lu\|f\)\>"
183 "floating point number, with dot, optional exponent
184 syn match  tclNumber            "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
185 "floating point number, starting with a dot, optional exponent
186 syn match  tclNumber            "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
187 "floating point number, without dot, with exponent
188 syn match  tclNumber            "\<\d\+e[-+]\=\d\+[fl]\=\>"
189 "hex number
190 syn match  tclNumber            "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
191 "syn match  tclIdentifier       "\<[a-z_][a-z0-9_]*\>"
192 syn case match
194 syn region  tclComment          start="^\s*\#" skip="\\$" end="$" contains=tclTodo
195 syn region  tclComment          start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo
197 "syn sync ccomment tclComment
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
202 if 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
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
238   delcommand HiLink
239 endif
241 let b:current_syntax = "tcl"
243 " vim: ts=8