Commits

Lars Yencken committed 2af3438

Add a preliminary vim syntax for drake.

  • Participants

Comments (0)

Files changed (3)

+.DS_Store
+*.orig
+*.bak
+*.log
+*.diff

ftdetect/drake.vim

+au BufNew,BufRead workflow.d set filetype=drake syntax=drake
+"
+"  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 drakeVariable "^[a-zA-Z-_][a-zA-Z-_]*" nextgroup=drakeSetIdentifier
+syn match drakeSetIdentifier "=" nextgroup=drakeString
+syn match drakeString "[^ ,]*" contained contains=drakeVariableRef
+
+" 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 match drakeRule "^[^<;][^;<]* <- [^,][^,]*\(, [^,][^,]*\)*$" contains=drakeTargets,drakeRuleIdentifier,drakeSources
+syn match drakeTargets "^[^<; ][^;< ]*" contained nextgroup=drakeRuleIdentifier contains=drakeString,drakeSourceSep
+syn match drakeRuleIdentifier " <- " contained nextgroup=drakeSources
+syn match drakeSources "[^<]*$" contained contains=drakeString,drakeSourceSep nextgroup=drakeActionBlock
+"syn region drakeActionBlock start="^[ \t]" end="^$" contains=@Shell
+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 drakeActionBlock matchgroup=Snip start='^[ ][ ]*' end='^$' containedin=@Drake contains=@Shell
+
+" 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'