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