Source

vim-drake-syntax / syntax / drake.vim

Full commit
"
"  Vim syntax file for drake
"  Language: drake
"  Maintainer: Lars Yencken <lars@yencken.org>
"  Latest Revision: 2013-01-31
"

if exists("b:current_syntax")
  finish
endif

let b:current_syntax = ''
unlet b:current_syntax
syn include @Shell syntax/sh.vim

let b:current_syntax = ''
unlet b:current_syntax
syn include @Python syntax/python.vim

" Comments
syn match drakeComment ";.*$" contains=drakeTodo

" Variable definitions
syn match drakeSetVariable "^[a-zA-Z-_][a-zA-Z-_]*=[^ ,]*$" contains=drakeVariable
syn match drakeVariable "^[a-zA-Z-_][a-zA-Z-_]*" nextgroup=drakeSetIdentifier containedin=drakeVariable
syn match drakeSetIdentifier "=" nextgroup=drakeString
syn match drakeString "[^ ,]*" contained contains=drakeVariableRef containedin=drakeSetVariable

" Variable references in strings
syn region drakeVariableRef matchgroup=VarBraces start='\$\[' end='\]' contained containedin=drakeString contains=drakeVariableName
syn match drakeVariableName "[a-zA-Z-_][a-zA-Z-_]*" contained containedin=drakeVariableRef

" Rule blocks
syn region drakeBlock start="[^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)* <- [^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)*" end="^$" contains=drakeRule
syn match drakeRule "[^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)* <- [^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)*" contains=drakeTargets
syn match drakeTargets "[^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)*" contained nextgroup=drakeRuleIdentifier contains=drakeString,drakeSourceSep
syn match drakeSources "[^<;, ][^<;, ]*\(, [^<;, ][^<;, ]*\)*" contained contains=drakeString,drakeSourceSep
syn match drakeRuleIdentifier " <- " contained nextgroup=drakeSources
syn match drakeSourceSep ", " contained containedin=drakeTargets,drakeSources

" Todos in comments
syn keyword drakeTodo contained TODO NOTE FIXME XXX

hi link drakeComment Comment
hi link drakeTodo Todo
hi link drakeVariable	Identifier
hi link drakeSetIdentifier Delimiter
hi link drakeRuleIdentifier Delimiter
hi link drakeString String
hi link drakeVariableName Identifier
hi link VarBraces SpecialComment
hi link drakeSourceSep Delimiter

" Embedded shell region in block
syn region drakeDefaultShBlock matchgroup=Snip start='^[ \t][ \t]*' end='^$' containedin=drakeBlock contains=@Shell
syn region drakeShBlock matchgroup=Snip start=' \[shell\]$' end='^$' containedin=drakeBlock contains=@Shell
syn region drakePyBlock matchgroup=Snip start=' \[python\]$' end='^$' containedin=drakeBlock contains=@Python

" Embedded shell regions in strings
syn region shellBrackets matchgroup=SnipBraces start='\$(' end=')' containedin=drakeString contains=@Shell

hi link Snip SpecialComment
hi link SnipBraces SpecialComment
hi link drakeVariableRef Identifier

let b:current_syntax = 'drake'