Skip to content

Instantly share code, notes, and snippets.

@mjtorn
Created September 18, 2018 10:13
Show Gist options
  • Save mjtorn/14233ab28588f76eeb6e7553cf244cfb to your computer and use it in GitHub Desktop.
Save mjtorn/14233ab28588f76eeb6e7553cf244cfb to your computer and use it in GitHub Desktop.
Vim syntax file for Escoria scripts
" Vim syntax file
" Language: Escoria Script
" Maintainer: Markus Törnqvist
" Last Change: 2018 09 18
" Inspired heavily by python's syntax stuff
setlocal foldmethod=syntax
"" Magic words
syn match escWord "\<[a-z_]+\>" contained
syn keyword escTodo TODO FIXME XXX
\ contained
"" syntax groups
syn match escPreEvent "^:"
\ nextgroup=escEvent
syn match escEvent ".*"
\ contained
" XXX: The space-or-EOL regexps should be one somehow
syn match escCommand "^\s*\<[a-z_]*\>\s\|^\s*\<[a-z_]*\>$\|^\s*[\>?]"
syn match escComment
\ /#\%(.\%({{{\|}}}\)\@!\)*$/
\ contains=escTodo,@Spell
syn region escString
\ start=+"+
\ end=+"+
\ skip=+\\\\\|\\"+
\ contains=@Spell
\ oneline
" FIXME: This should be colored PreCondit, but doesn't work
syn keyword escDialog "- "
syn region escDialogChoice
\ start="- "ms=e+1
\ end=+:"\|$+me=s-1
\ contains=escWord
"" TODO: folds do not work yet
syn region escEventFold
\ start="^:"
\ end="\ze\%(\s*\n\)\+\%(\z1\s\)\@!."
\ fold transparent
syn region escCommentFold matchgroup=escComment
\ start='#.*{{{.*$'
\ end='#.*}}}.*$'
\ fold transparent
"" colors
hi link escPreEvent Statement
hi link escEvent Function
" It's not really a PreCondit but this is more readable
hi link escCommand PreCondit
hi link escComment Comment
hi link escString String
hi link escDialog PreCondit
hi link escDialogChoice Identifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment