shout/vim/syntax/shout.vim

73 lines
2.4 KiB
VimL

" Vim syntax file for .shout files
" Language: shout (shell integration tests)
if exists("b:current_syntax")
finish
endif
" Directives — must appear before first command
syn match shoutDirectiveKey /^@env\s/ contained
syn match shoutDirectiveKey /^@setup\s/ contained
syn match shoutDirectiveKey /^@teardown\s/ contained
syn match shoutEnvDirective /^@env\s\+\S\+=.*$/ contains=shoutDirectiveKey,shoutEnvName
syn match shoutEnvName /\S\+\ze=/ contained nextgroup=shoutEnvEquals
syn match shoutEnvEquals /=/ contained nextgroup=shoutEnvValue
syn match shoutEnvValue /.*$/ contained
syn match shoutSetupDirective /^@setup\s\+.*$/ contains=shoutDirectiveKey
syn match shoutTeardownDirective /^@teardown\s\+.*$/ contains=shoutDirectiveKey
" Comment lines: # ..., $# ..., or $ # ...
syn match shoutCommentCommand /^#.*$/
syn match shoutCommentCommand /^\$#.*$/
syn match shoutCommentCommand /^\$\s\+#.*$/
" Command lines: $ command
syn match shoutPrompt /^\$\s/ contained
syn match shoutCommand /^\$\s.\+/ contains=shoutPrompt,shoutInlineComment
syn match shoutInlineComment /\s\+#[^"']*$/ contained
" Escaped dollar/hash in expected output
syn match shoutEscapedChar /^\\\$/ contained
syn match shoutEscapedChar /^\\#/ contained
syn match shoutEscapedLine /^\\\$.*$/ contains=shoutEscapedChar
syn match shoutEscapedLine /^\\#.*$/ contains=shoutEscapedChar
" Wildcards
syn match shoutWildcardLine /^\.\.\.$/
syn match shoutWildcardInline /\.\.\./ contained
" Exit code assertions
syn match shoutExitCode /^\[\d\+\]$/
syn match shoutExitCodeWild /^\[\*\]$/
" Expected output (anything not matched above)
syn match shoutExpectedOutput /^[^$@\[\\].*$/ contains=shoutWildcardInline
" Highlighting
hi def link shoutDirectiveKey Keyword
hi def link shoutEnvDirective PreProc
hi def link shoutEnvName Identifier
hi def link shoutEnvEquals Operator
hi def link shoutEnvValue String
hi def link shoutSetupDirective PreProc
hi def link shoutTeardownDirective PreProc
hi def link shoutCommentCommand Comment
hi def link shoutPrompt Special
hi def link shoutCommand Statement
hi def link shoutInlineComment Comment
hi def link shoutEscapedChar SpecialChar
hi def link shoutEscapedLine String
hi def link shoutWildcardLine WarningMsg
hi def link shoutWildcardInline WarningMsg
hi def link shoutExitCode Constant
hi def link shoutExitCodeWild Constant
hi def link shoutExpectedOutput String
let b:current_syntax = "shout"