Skip to content

Instantly share code, notes, and snippets.

@ghprince
Created October 12, 2012 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghprince/3878484 to your computer and use it in GitHub Desktop.
Save ghprince/3878484 to your computer and use it in GitHub Desktop.
ISU syntax file for VIM
" Vim syntax file
" Language: ISU
" Maintainer: Gordon Gao <gordon.gao@oracle.com>
" Last Change: 2012 Oct 11
" Add the following line into your ~/.vimrc for auto detection
" autocmd BufRead,BufNewFile *.isu set filetype=isu
" Based on expect.vim and tcl.vim
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
" TODO isu part of syn and link
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Tcl Part of syn
" Basic Tcl commands: http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
syn keyword tclCommand after append apply array bgerror binary catch cd chan clock
syn keyword tclCommand close concat dde dict encoding eof error eval exec exit
syn keyword tclCommand expr fblocked fconfigure fcopy file fileevent filename flush
syn keyword tclCommand format gets glob global history incr info interp join
syn keyword tclCommand lappend lassign lindex linsert list llength load lrange lrepeat
syn keyword tclCommand lreplace lreverse lsearch lset lsort memory namespace open package
syn keyword tclCommand pid proc puts pwd read regexp registry regsub rename return
syn keyword tclCommand scan seek set socket source split string subst tell time
syn keyword tclCommand trace unknown unload unset update uplevel upvar variable vwait
" The 'Tcl Standard Library' commands: http://www.tcl.tk/man/tcl8.5/TclCmd/library.htm
syn keyword tclCommand auto_execok auto_import auto_load auto_mkindex auto_mkindex_old
syn keyword tclCommand auto_qualify auto_reset parray tcl_endOfWord tcl_findLibrary
syn keyword tclCommand tcl_startOfNextWord tcl_startOfPreviousWord tcl_wordBreakAfter
syn keyword tclCommand tcl_wordBreakBefore
" Commands that were added in Tcl 8.6
syn keyword tclCommand my oo::copy oo::define oo::objdefine self
syn keyword tclCommand coroutine tailcall throw yield
" Global variables used by Tcl: http://www.tcl.tk/man/tcl8.5/TclCmd/tclvars.htm
syn keyword tclVars env errorCode errorInfo tcl_library tcl_patchLevel tcl_pkgPath
syn keyword tclVars tcl_platform tcl_precision tcl_rcFileName tcl_traceCompile
syn keyword tclVars tcl_traceExec tcl_wordchars tcl_nonwordchars tcl_version argc argv
syn keyword tclVars argv0 tcl_interactive geometry
" Strings which expr accepts as boolean values, aside from zero / non-zero.
syn keyword tclBoolean true false on off yes no
syn keyword tclLabel case default
syn keyword tclConditional if then else elseif switch
syn keyword tclConditional try finally
syn keyword tclRepeat while for foreach break continue
syn keyword tcltkSwitch contained insert create polygon fill outline tag
" WIDGETS
" commands associated with widgets
syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
syn keyword tcltkWidgetSwitch contained state tabs width wrap
" button
syn keyword tcltkWidgetSwitch contained command default
" canvas
syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
" checkbutton, radiobutton
syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
" entry, frame
syn keyword tcltkWidgetSwitch contained show class colormap container visual
" listbox, menu
syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
" menubutton, message
syn keyword tcltkWidgetSwitch contained direction aspect justify
" scale
syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
" scrollbar
syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
" image
syn keyword tcltkWidgetSwitch contained delete names types create
" variable reference
" ::optional::namespaces
syn match tclVarRef "$\(\(::\)\?\([[:alnum:]_]*::\)*\)\a[[:alnum:]_]*"
" ${...} may contain any character except '}'
syn match tclVarRef "${[^}]*}"
" The syntactic unquote-splicing replacement for [expand].
syn match tclExpand '\s{\*}'
syn match tclExpand '^{\*}'
" menu, mane add
syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
"syn keyword tcltkWidgetSwitch contained
"syn match tcltkWidgetSwitch contained
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
" These words are dual purpose.
" match switches
"syn match tcltkWidgetSwitch contained "-text"hs=s+1
syn match tcltkWidgetSwitch contained "-text\(var\)\?"hs=s+1
syn match tcltkWidgetSwitch contained "-menu"hs=s+1
syn match tcltkWidgetSwitch contained "-label"hs=s+1
" match commands - 2 lines for pretty match.
"variable
" Special case - If a number follows a variable region, it must be at the end of" the pattern, by definition. Therefore, (1) either include a number as the region
" end and exclude tclNumber from the contains list, or (2) make variable
" keepend. As (1) would put variable out of step with everything else, use (2).
syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
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
" menu
syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
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
" label
syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
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
" text
syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
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
" This isn't contained (I don't think) so it's OK to just associate with the Color group.
" TODO: This could be wrong.
syn keyword tcltkWidgetColor toplevel
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
syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
" NAMESPACE
" commands associated with namespace
syn keyword tcltkNamespaceSwitch contained children code current delete eval
syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkNamespaceSwitch
" EXPR
" commands associated with expr
syn keyword tcltkMaths contained abs acos asin atan atan2 bool ceil cos cosh double entier
syn keyword tcltkMaths contained exp floor fmod hypot int isqrt log log10 max min pow rand
syn keyword tcltkMaths contained round sin sinh sqrt srand tan tanh wide
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
" format
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
" PACK
" commands associated with pack
syn keyword tcltkPackSwitch contained forget info propogate slaves
syn keyword tcltkPackConfSwitch contained after anchor before expand fill in ipadx ipady padx pady side
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
" STRING
" commands associated with string
syn keyword tcltkStringSwitch contained compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
" ARRAY
" commands associated with array
syn keyword tcltkArraySwitch contained anymore donesearch exists get names nextelement size startsearch set
" match from command name to ] or EOL
syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
" LSORT
" switches for lsort
syn keyword tcltkLsortSwitch contained ascii dictionary integer real command increasing decreasing index
" match from command name to ] or EOL
syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
syn keyword tclTodo contained TODO
" Sequences which are backslash-escaped: http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M16
" Octal, hexadecimal, unicode codepoints, and the classics.
" Tcl takes as many valid characters in a row as it can, so \xAZ in a string is newline followed by 'Z'.
syn match tclSpecial contained '\\\([0-7]\{1,3}\|x\x\{1,2}\|u\x\{1,4}\|[abfnrtv]\)'
syn match tclSpecial contained '\\[\[\]\{\}\"\$]'
" Command appearing inside another command or inside a string.
syn region tclEmbeddedStatement start='\[' end='\]' contained contains=tclCommand,tclNumber,tclLineContinue,tclString,tclVarRef,tclEmbeddedStatement
" A string needs the skip argument as it may legitimately contain \".
" Match at start of line
syn region tclString start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
"Match all other legal strings.
syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=tclSpecial,tclVarRef,tclEmbeddedStatement skip=+\\\\\|\\"+
" Line continuation is backslash immediately followed by newline.
syn match tclLineContinue '\\$'
if exists('g:tcl_warn_continuation')
syn match tclNotLineContinue '\\\s\+$'
endif
"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match tclNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
"floating point number, with dot, optional exponent
syn match tclNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, starting with a dot, optional exponent
syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>"
"hex number
syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
"syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>"
syn case match
syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo
syn region tclComment start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo
" Expect part of syn
" Reserved Expect variable prefixes.
syn match expectVariables "\$exp[a-zA-Z0-9_]*\|\$inter[a-zA-Z0-9_]*"
syn match expectVariables "\$spawn[a-zA-Z0-9_]*\|\$timeout[a-zA-Z0-9_]*"
" Normal Expect variables.
syn match expectVariables "\$env([^)]*)"
syn match expectVariables "\$any_spawn_id\|\$argc\|\$argv\d*"
syn match expectVariables "\$user_spawn_id\|\$spawn_id\|\$timeout"
" Expect variable arrays.
syn match expectVariables "\$\(expect\|interact\)_out([^)]*)" contains=expectOutVar
" User defined variables.
syn match expectVariables "\$[a-zA-Z_][a-zA-Z0-9_]*"
" Reserved Expect command prefixes.
syn match expectCommand "exp_[a-zA-Z0-9_]*"
" Normal Expect commands.
syn keyword expectStatement close debug disconnect
syn keyword expectStatement exit exp_continue exp_internal exp_open
syn keyword expectStatement exp_pid exp_version
syn keyword expectStatement fork inter_return interpreter
syn keyword expectStatement log_file log_user match_max overlay
syn keyword expectStatement parity remove_nulls return
syn keyword expectStatement send send_error send_log send_user
syn keyword expectStatement sleep spawn strace stty system
syn keyword expectStatement timestamp trace trap wait
" Tcl commands recognized and used by Expect.
syn keyword expectCommand proc
syn keyword expectConditional if else
syn keyword expectRepeat while for foreach
" Expect commands with special arguments.
syn keyword expectStatement expect expect_after expect_background nextgroup=expectExpectOpts
syn keyword expectStatement expect_before expect_user interact nextgroup=expectExpectOpts
syn match expectSpecial contained "\\."
" Options for "expect", "expect_after", "expect_background",
" "expect_before", "expect_user", and "interact".
syn keyword expectExpectOpts default eof full_buffer null return timeout
syn keyword expectOutVar contained spawn_id seconds seconds_total
syn keyword expectOutVar contained string start end buffer
" Numbers (Tcl style).
syn case ignore
syn match expectNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
"floating point number, with dot, optional exponent
syn match expectNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, starting with a dot, optional exponent
syn match expectNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match expectNumber "\<\d\+e[-+]\=\d\+[fl]\=\>"
"hex number
syn match expectNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
"syn match expectIdentifier "\<[a-z_][a-z0-9_]*\>"
syn case match
syn region expectString start=+"+ end=+"+ contains=expectVariables,expectSpecial
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_isu_syntax_inits")
if version < 508
let did_isu_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" Tcl part of link
HiLink tcltkSwitch Special
HiLink tclExpand Special
HiLink tclLabel Label
HiLink tclConditional Conditional
HiLink tclRepeat Repeat
HiLink tclNumber Number
HiLink tclError Error
HiLink tclCommand Statement
HiLink tclString String
HiLink tclComment Comment
HiLink tclSpecial Special
HiLink tclTodo Todo
" Below here are the commands and their options.
HiLink tcltkCommandColor Statement
HiLink tcltkWidgetColor Structure
HiLink tclLineContinue WarningMsg
if exists('g:tcl_warn_continuation')
HiLink tclNotLineContinue ErrorMsg
endif
HiLink tcltkStringSwitch Special
HiLink tcltkArraySwitch Special
HiLink tcltkLsortSwitch Special
HiLink tcltkPackSwitch Special
HiLink tcltkPackConfSwitch Special
HiLink tcltkMaths Special
HiLink tcltkNamespaceSwitch Special
HiLink tcltkWidgetSwitch Special
HiLink tcltkPackConfColor Identifier
HiLink tclVarRef Identifier
" Expect part of link
HiLink expectVariables Special
HiLink expectCommand Function
HiLink expectStatement Statement
HiLink expectConditional Conditional
HiLink expectRepeat Repeat
HiLink expectExpectOpts Keyword
HiLink expectOutVar Special
HiLink expectSpecial Special
HiLink expectNumber Number
HiLink expectString String
delcommand HiLink
endif
let b:current_syntax = "isu"
" vim: ts=8
let did_isu_syntax_inits = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment