From e112d781ea5ffc4186e7d70dba595b5a233335a8 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 30 Dec 2011 11:28:30 -0700 Subject: Added vim highlighting for stage scripts. --- support/vim/ftdetect/stage.vim | 1 + support/vim/ftplugin/stage.vim | 24 +++++++++++++ support/vim/syntax/stage.vim | 77 ++++++++++++++++++++++++++++++++++++++++++ test.stage | 5 +++ 4 files changed, 107 insertions(+) create mode 100644 support/vim/ftdetect/stage.vim create mode 100644 support/vim/ftplugin/stage.vim create mode 100644 support/vim/syntax/stage.vim diff --git a/support/vim/ftdetect/stage.vim b/support/vim/ftdetect/stage.vim new file mode 100644 index 0000000..b826efe --- /dev/null +++ b/support/vim/ftdetect/stage.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.stage set filetype=stage diff --git a/support/vim/ftplugin/stage.vim b/support/vim/ftplugin/stage.vim new file mode 100644 index 0000000..96ed1b5 --- /dev/null +++ b/support/vim/ftplugin/stage.vim @@ -0,0 +1,24 @@ +" Vim filetype plugin file +" Language: Stage + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +" Set format options -- allow comment formatting with gq, but disable +" other processing +setlocal fo-=tcrowan2 fo+=q + +" Set 'comments' to be the same as C/C++ +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// + +" Win32 can filter files in the browse dialog +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = "Stage files (*.stage)\t*.stage\n" . + \ "All Files (*.*)\t*.*\n" +endif + diff --git a/support/vim/syntax/stage.vim b/support/vim/syntax/stage.vim new file mode 100644 index 0000000..b5dab28 --- /dev/null +++ b/support/vim/syntax/stage.vim @@ -0,0 +1,77 @@ +" Vim syntax file +" Language: Stage +" Maintainer: Mike Buland :) +" Last Change: 2012 Dec 30 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Keywords +syn keyword Conditional if then else +syn keyword Loop for each do in while +syn keyword Logic not and or +syn keyword Statement setup enter +syn keyword Todo TODO FIXME XXX +syn keyword Type function command situation game global player +syn keyword Constant null true false +syn keyword Builtins display goto exists delete + +syn match TargetProcess /[a-zA-Z_][a-zA-Z0-9_]*:/he=e-1 + +syn cluster CommentGroup contains=Todo + +syn match Special display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" +syn match Special display contained "\\\(u\x\{4}\|U\x\{8}\)" + +" TODO: do we want to end at end of line too? +syn region tripSingleString start=+'''+ skip=+\\\\\|\\'+ end=+'''+ contains=Special,CmdEx +syn region tripDoubleString start=+"""+ skip=+\\\\\|\\"+ end=+"""+ contains=Special,CmdEx +syn region singleString start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=Special,CmdEx +syn region doubleString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=Special,CmdEx +syn region sitName start=+<<+ end=+>>+ contains=Special,CmdEx + +syn region CmdEx start=+$(+ skip=+"\|\\)\|\\\\+ end=+)+ + +syn case ignore +syn match Numbers display transparent "\<\d\|\.\d" contains=Number,Float,OctalError,Octal +syn match Number display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" +" Hex +syn match Number display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" +syn match Octal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero +syn match OctalZero display contained "\<0" +syn match Float display contained "\d\+f" +syn match Float display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" +syn match Float display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" +syn match Float display contained "\d\+e[-+]\=\d\+[fl]\=\>" +" Flag bad digits in octal +syn match OctalError display contained "0\o*[89]\d*" +syn case match + + +syn region cppComment start="#" skip="\\$" end="$" contains=@CommentGroup keepend +syn region cComment start="/\*" end="\*/" contains=@CommentGroup fold +syn region cppComment start="//" skip="\\$" end="$" contains=@CommentGroup keepend + + +syntax region Block start="{" end="}" transparent fold + +hi def link OctalError Error +hi def link cComment Comment +hi def link cppComment Comment +hi def link tripSingleString String +hi def link tripDoubleString String +hi def link singleString String +hi def link doubleString String +hi def link sitName String +hi def link cmdEx String +hi def link Constructor Operator +hi def link Logic Statement +hi def link Loop Conditional +hi def link Builtins Function +hi def link TargetProcess Type + diff --git a/test.stage b/test.stage index 38e3735..0963143 100644 --- a/test.stage +++ b/test.stage @@ -69,6 +69,11 @@ situation <> { display("You can't eat " + object ); } + + command: "eat" object "now" + { + display("Alright, fine, eat " + object + " now..." ); + } setup { -- cgit v1.2.3