1" Vim syntax file 2" Language: Tcl/Tk 3" Maintainer: Taylor Venable <[email protected]> 4" (previously Brett Cannon <[email protected]>) 5" (previously Dean Copsey <[email protected]>) 6" (previously Matt Neumann <[email protected]>) 7" (previously Allan Kelly <[email protected]>) 8" Original: Robin Becker <[email protected]> 9" Last Change: 2009/04/06 02:38:36 10" Version: 1.13 11" URL: http://real.metasyntax.net:2357/cvs/cvsweb.cgi/Config/vim/syntax/tcl.vim 12" 13" Keywords TODO: click anchor 14 15" For version 5.x: Clear all syntax items 16" For version 6.x: Quit when a syntax file was already loaded 17if version < 600 18 syntax clear 19elseif exists("b:current_syntax") 20 finish 21endif 22 23" Basic Tcl commands: http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm 24syn keyword tclCommand after append apply array bgerror binary catch cd chan clock 25syn keyword tclCommand close concat dde dict encoding eof error eval exec exit 26syn keyword tclCommand expr fblocked fconfigure fcopy file fileevent filename flush 27syn keyword tclCommand format gets glob global history incr info interp join 28syn keyword tclCommand lappend lassign lindex linsert list llength load lrange lrepeat 29syn keyword tclCommand lreplace lreverse lsearch lset lsort memory namespace open package 30syn keyword tclCommand pid proc puts pwd read regexp registry regsub rename return 31syn keyword tclCommand scan seek set socket source split string subst tell time 32syn keyword tclCommand trace unknown unload unset update uplevel upvar variable vwait 33 34" The 'Tcl Standard Library' commands: http://www.tcl.tk/man/tcl8.5/TclCmd/library.htm 35syn keyword tclCommand auto_execok auto_import auto_load auto_mkindex auto_mkindex_old 36syn keyword tclCommand auto_qualify auto_reset parray tcl_endOfWord tcl_findLibrary 37syn keyword tclCommand tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter 38syn keyword tclCommand tcl_wordBreakBefore 39 40" Commands that were added in Tcl 8.6 41 42syn keyword tclCommand my oo::copy oo::define oo::objdefine self 43syn keyword tclCommand coroutine tailcall throw yield 44 45" Global variables used by Tcl: http://www.tcl.tk/man/tcl8.5/TclCmd/tclvars.htm 46syn keyword tclVars env errorCode errorInfo tcl_library tcl_patchLevel tcl_pkgPath 47syn keyword tclVars tcl_platform tcl_precision tcl_rcFileName tcl_traceCompile 48syn keyword tclVars tcl_traceExec tcl_wordchars tcl_nonwordchars tcl_version argc argv 49syn keyword tclVars argv0 tcl_interactive geometry 50 51" Strings which expr accepts as boolean values, aside from zero / non-zero. 52syn keyword tclBoolean true false on off yes no 53 54syn keyword tclLabel case default 55syn keyword tclConditional if then else elseif switch 56syn keyword tclConditional try finally 57syn keyword tclRepeat while for foreach break continue 58syn keyword tcltkSwitch contained insert create polygon fill outline tag 59 60" WIDGETS 61" commands associated with widgets 62syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget 63syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth 64syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid 65syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus 66syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand 67syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand 68syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3 69syn keyword tcltkWidgetSwitch contained state tabs width wrap 70" button 71syn keyword tcltkWidgetSwitch contained command default 72" canvas 73syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient 74" checkbutton, radiobutton 75syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable 76" entry, frame 77syn keyword tcltkWidgetSwitch contained show class colormap container visual 78" listbox, menu 79syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type 80" menubutton, message 81syn keyword tcltkWidgetSwitch contained direction aspect justify 82" scale 83syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to 84" scrollbar 85syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth 86" image 87syn keyword tcltkWidgetSwitch contained delete names types create 88" variable reference 89 " ::optional::namespaces 90syn match tclVarRef "$\(\(::\)\?\([[:alnum:]_]*::\)*\)\a[[:alnum:]_]*" 91 " ${...} may contain any character except '}' 92syn match tclVarRef "${[^}]*}" 93 94" The syntactic unquote-splicing replacement for [expand]. 95syn match tclExpand '\s{\*}' 96syn match tclExpand '^{\*}' 97 98" menu, mane add 99syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator 100syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak 101syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue 102syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable 103syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke 104syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate 105"syn keyword tcltkWidgetSwitch contained 106"syn match tcltkWidgetSwitch contained 107syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 108syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 109 110syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 111syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 112syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 113syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 114syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 115syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 116syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 117syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 118syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 119syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 120" These words are dual purpose. 121" match switches 122"syn match tcltkWidgetSwitch contained "-text"hs=s+1 123syn match tcltkWidgetSwitch contained "-text\(var\)\?"hs=s+1 124syn match tcltkWidgetSwitch contained "-menu"hs=s+1 125syn match tcltkWidgetSwitch contained "-label"hs=s+1 126" match commands - 2 lines for pretty match. 127"variable 128" Special case - If a number follows a variable region, it must be at the end of 129" the pattern, by definition. Therefore, (1) either include a number as the region 130" end and exclude tclNumber from the contains list, or (2) make variable 131" keepend. As (1) would put variable out of step with everything else, use (2). 132syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand 133syn 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 134" menu 135syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 136syn 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 137" label 138syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 139syn 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 140" text 141syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString 142syn 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 143 144" This isn't contained (I don't think) so it's OK to just associate with the Color group. 145" TODO: This could be wrong. 146syn keyword tcltkWidgetColor toplevel 147 148 149syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend 150syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef 151 152 153" NAMESPACE 154" commands associated with namespace 155syn keyword tcltkNamespaceSwitch contained children code current delete eval 156syn keyword tcltkNamespaceSwitch contained export forget import inscope origin 157syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable 158syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkNamespaceSwitch 159 160" EXPR 161" commands associated with expr 162syn keyword tcltkMaths contained abs acos asin atan atan2 bool ceil cos cosh double entier 163syn keyword tcltkMaths contained exp floor fmod hypot int isqrt log log10 max min pow rand 164syn keyword tcltkMaths contained round sin sinh sqrt srand tan tanh wide 165 166syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf 167 168" format 169syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf 170 171" PACK 172" commands associated with pack 173syn keyword tcltkPackSwitch contained forget info propogate slaves 174syn keyword tcltkPackConfSwitch contained after anchor before expand fill in ipadx ipady padx pady side 175syn 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 176 177" STRING 178" commands associated with string 179syn keyword tcltkStringSwitch contained compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend 180syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand 181 182" ARRAY 183" commands associated with array 184syn keyword tcltkArraySwitch contained anymore donesearch exists get names nextelement size startsearch set 185" match from command name to ] or EOL 186syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand 187 188" LSORT 189" switches for lsort 190syn keyword tcltkLsortSwitch contained ascii dictionary integer real command increasing decreasing index 191" match from command name to ] or EOL 192syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand 193 194syn keyword tclTodo contained TODO 195 196" Sequences which are backslash-escaped: http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M16 197" Octal, hexadecimal, unicode codepoints, and the classics. 198" Tcl takes as many valid characters in a row as it can, so \xAZ in a string is newline followed by 'Z'. 199syn match tclSpecial contained '\\\([0-7]\{1,3}\|x\x\{1,2}\|u\x\{1,4}\|[abfnrtv]\)' 200syn match tclSpecial contained '\\[\[\]\{\}\"\$]' 201 202" Command appearing inside another command or inside a string. 203syn region tclEmbeddedStatement start='\[' end='\]' contained contains=tclCommand,tclNumber,tclLineContinue,tclString,tclVarRef,tclEmbeddedStatement 204" A string needs the skip argument as it may legitimately contain \". 205" Match at start of line 206syn region tclString start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+ 207"Match all other legal strings. 208syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=tclSpecial,tclVarRef,tclEmbeddedStatement skip=+\\\\\|\\"+ 209 210" Line continuation is backslash immediately followed by newline. 211syn match tclLineContinue '\\$' 212 213if exists('g:tcl_warn_continuation') 214 syn match tclNotLineContinue '\\\s\+$' 215endif 216 217"integer number, or floating point number without a dot and with "f". 218syn case ignore 219syn match tclNumber "\<\d\+\(u\=l\=\|lu\|f\)\>" 220"floating point number, with dot, optional exponent 221syn match tclNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" 222"floating point number, starting with a dot, optional exponent 223syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 224"floating point number, without dot, with exponent 225syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>" 226"hex number 227syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>" 228"syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>" 229syn case match 230 231syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo 232syn region tclComment start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo 233 234"syn sync ccomment tclComment 235 236" Define the default highlighting. 237" For version 5.7 and earlier: only when not done already 238" For version 5.8 and later: only when an item doesn't have highlighting yet 239if version >= 508 || !exists("did_tcl_syntax_inits") 240 if version < 508 241 let did_tcl_syntax_inits = 1 242 command -nargs=+ HiLink hi link <args> 243 else 244 command -nargs=+ HiLink hi def link <args> 245 endif 246 247 HiLink tcltkSwitch Special 248 HiLink tclExpand Special 249 HiLink tclLabel Label 250 HiLink tclConditional Conditional 251 HiLink tclRepeat Repeat 252 HiLink tclNumber Number 253 HiLink tclError Error 254 HiLink tclCommand Statement 255 HiLink tclString String 256 HiLink tclComment Comment 257 HiLink tclSpecial Special 258 HiLink tclTodo Todo 259 " Below here are the commands and their options. 260 HiLink tcltkCommandColor Statement 261 HiLink tcltkWidgetColor Structure 262 HiLink tclLineContinue WarningMsg 263if exists('g:tcl_warn_continuation') 264 HiLink tclNotLineContinue ErrorMsg 265endif 266 HiLink tcltkStringSwitch Special 267 HiLink tcltkArraySwitch Special 268 HiLink tcltkLsortSwitch Special 269 HiLink tcltkPackSwitch Special 270 HiLink tcltkPackConfSwitch Special 271 HiLink tcltkMaths Special 272 HiLink tcltkNamespaceSwitch Special 273 HiLink tcltkWidgetSwitch Special 274 HiLink tcltkPackConfColor Identifier 275 HiLink tclVarRef Identifier 276 277 delcommand HiLink 278endif 279 280let b:current_syntax = "tcl" 281 282" vim: ts=8 noet 283