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