1" Vim syntax file 2" Language: TCL/TK 3" Maintainer: Dean Copsey <[email protected]> 4" (previously Matt Neumann <[email protected]>) 5" (previously Allan Kelly <[email protected]>) 6" Original: Robin Becker <[email protected]> 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 13if version < 600 14 syntax clear 15elseif exists("b:current_syntax") 16 finish 17endif 18 19" A bunch of useful keywords 20syn keyword tclStatement proc global return lindex 21syn keyword tclStatement llength lappend lreplace lrange list concat incr 22syn keyword tclStatement upvar set 23syn keyword tclLabel case default 24syn keyword tclConditional if then else elseif switch 25syn keyword tclRepeat while for foreach break continue 26syn keyword tcltkSwitch contained insert create polygon fill outline tag 27 28" WIDGETS 29" commands associated with widgets 30syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget 31syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth 32syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid 33syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus 34syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand 35syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand 36syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3 37syn keyword tcltkWidgetSwitch contained state tabs width wrap 38" button 39syn keyword tcltkWidgetSwitch contained command default 40" canvas 41syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient 42" checkbutton, radiobutton 43syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable 44" entry, frame 45syn keyword tcltkWidgetSwitch contained show class colormap container visual 46" listbox, menu 47syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type 48" menubutton, message 49syn keyword tcltkWidgetSwitch contained direction aspect justify 50" scale 51syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to 52" scrollbar 53syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth 54" image 55syn keyword tcltkWidgetSwitch contained delete names types create 56" variable reference 57 " ::optional::namespaces 58syn match tclVarRef "$\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*" 59 " ${...} may contain any character except '}' 60syn match tclVarRef "${[^}]*}" 61" menu, mane add 62syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator 63syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak 64syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue 65syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable 66syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke 67syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate 68"syn keyword tcltkWidgetSwitch contained 69"syn match tcltkWidgetSwitch contained 70syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 71syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 72 73syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 74syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 75syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 76syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 77syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 78syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 79syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 80syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 81syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 82syn 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 86syn match tcltkWidgetSwitch contained "-text\(var\)\?"hs=s+1 87syn match tcltkWidgetSwitch contained "-menu"hs=s+1 88syn 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). 95syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand 96syn 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 98syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 99syn 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 101syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 102syn 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 104syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString 105syn 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. 109syn keyword tcltkWidgetColor toplevel 110 111 112syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend 113syn 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 118syn keyword tcltkNamespaceSwitch contained children code current delete eval 119syn keyword tcltkNamespaceSwitch contained export forget import inscope origin 120syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable 121syn 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 125syn keyword tcltkMaths contained acos cos hypot sinh 126syn keyword tcltkMaths contained asin cosh log sqrt 127syn keyword tcltkMaths contained atan exp log10 tan 128syn keyword tcltkMaths contained atan2 floor pow tanh 129syn keyword tcltkMaths contained ceil fmod sin 130syn 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 133syn 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 137syn keyword tcltkPackSwitch contained forget info propogate slaves 138syn keyword tcltkPackConfSwitch contained after anchor before expand fill in ipadx ipady padx pady side 139syn 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 143syn keyword tcltkStringSwitch contained compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend 144syn 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 148syn keyword tcltkArraySwitch contained anymore donesearch exists get names nextelement size startsearch set 149" match from command name to ] or EOL 150syn 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 154syn keyword tcltkLsortSwitch contained ascii dictionary integer real command increasing decreasing index 155" match from command name to ] or EOL 156syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand 157 158syn keyword tclTodo contained TODO 159 160 161" String and Character contstants 162" Highlight special characters (those which have a backslash) differently 163syn match tclSpecial contained "\\\d\d\d\=\|\\." 164" A string needs the skip argument as it may legitimately contain \". 165" Match at start of line 166syn region tclString start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+ 167"Match all other legal strings. 168syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=tclSpecial skip=+\\\\\|\\"+ 169 170syn match tclLineContinue "\\\s*$" 171 172"integer number, or floating point number without a dot and with "f". 173syn case ignore 174syn match tclNumber "\<\d\+\(u\=l\=\|lu\|f\)\>" 175"floating point number, with dot, optional exponent 176syn match tclNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" 177"floating point number, starting with a dot, optional exponent 178syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 179"floating point number, without dot, with exponent 180syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>" 181"hex number 182syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>" 183"syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>" 184syn case match 185 186syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo 187syn 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 194if 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 231endif 232 233let b:current_syntax = "tcl" 234 235" vim: ts=8 236