2 " Language: YAML (YAML Ain't Markup Language)
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-04-19
6 if exists("b:current_syntax")
13 syn keyword yamlTodo contained TODO FIXME XXX NOTE
15 syn region yamlComment display oneline start='\%(^\|\s\)#' end='$'
16 \ contains=yamlTodo,@Spell
18 syn match yamlNodeProperty '!\%(![^\\^% ]\+\|[^!][^:/ ]*\)'
20 syn match yamlAnchor '&.\+'
22 syn match yamlAlias '\*.\+'
24 syn match yamlDelimiter '[-,:]'
25 syn match yamlBlock '[\[\]{}>|]'
26 syn match yamlOperator '[?+-]'
27 syn match yamlKey '\w\+\(\s\+\w\+\)*\ze\s*:'
29 syn region yamlString start=+"+ skip=+\\"+ end=+"+
31 syn region yamlString start=+'+ skip=+''+ end=+'+
32 \ contains=yamlSingleEscape
33 syn match yamlEscape contained display +\\[\\"abefnrtv^0_ NLP]+
34 syn match yamlEscape contained display '\\x\x\{2}'
35 syn match yamlEscape contained display '\\u\x\{4}'
36 syn match yamlEscape contained display '\\U\x\{8}'
37 " TODO: how do we get 0x85, 0x2028, and 0x2029 into this?
38 syn match yamlEscape display '\\\%(\r\n\|[\r\n]\)'
39 syn match yamlSingleEscape contained display +''+
41 " TODO: sexagecimal and fixed (20:30.15 and 1,230.15)
42 syn match yamlNumber display
43 \ '\<[+-]\=\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\='
44 syn match yamlNumber display '0\o\+'
45 syn match yamlNumber display '0x\x\+'
46 syn match yamlNumber display '([+-]\=[iI]nf)'
47 syn match yamlNumber display '(NaN)'
49 syn match yamlConstant '\<[~yn]\>'
50 syn keyword yamlConstant true True TRUE false False FALSE
51 syn keyword yamlConstant yes Yes on ON no No off OFF
52 syn keyword yamlConstant null Null NULL nil Nil NIL
54 syn match yamlTimestamp '\d\d\d\d-\%(1[0-2]\|\d\)-\%(3[0-2]\|2\d\|1\d\|\d\)\%( \%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\d\d [+-]\%([01]\d\|2[0-3]\):[0-5]\d\|t\%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\d\d[+-]\%([01]\d\|2[0-3]\):[0-5]\d\|T\%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\dZ\)\='
56 syn region yamlDocumentHeader start='---' end='$' contains=yamlDirective
57 syn match yamlDocumentEnd '\.\.\.'
59 syn match yamlDirective contained '%[^:]\+:.\+'
61 hi def link yamlTodo Todo
62 hi def link yamlComment Comment
63 hi def link yamlDocumentHeader PreProc
64 hi def link yamlDocumentEnd PreProc
65 hi def link yamlDirective Keyword
66 hi def link yamlNodeProperty Type
67 hi def link yamlAnchor Type
68 hi def link yamlAlias Type
69 hi def link yamlDelimiter Delimiter
70 hi def link yamlBlock Operator
71 hi def link yamlOperator Operator
72 hi def link yamlKey Identifier
73 hi def link yamlString String
74 hi def link yamlEscape SpecialChar
75 hi def link yamlSingleEscape SpecialChar
76 hi def link yamlNumber Number
77 hi def link yamlConstant Constant
78 hi def link yamlTimestamp Number
80 let b:current_syntax = "yaml"