30547
|
1 " Vim syntax file
|
|
2 " Language: HLS Playlist
|
|
3 " Maintainer: BenoƮt Ryder <benoit@ryder.fr>
|
|
4 " Latest Revision: 2022-09-23
|
|
5
|
|
6 if exists("b:current_syntax")
|
|
7 finish
|
|
8 endif
|
|
9
|
|
10 let s:cpo_save = &cpo
|
|
11 set cpo&vim
|
|
12
|
|
13 " Comment line
|
|
14 syn match hlsplaylistComment "^#\(EXT\)\@!.*$"
|
|
15 " Segment URL
|
|
16 syn match hlsplaylistUrl "^[^#].*$"
|
|
17
|
|
18 " Unknown tags, assume an attribute list or nothing
|
|
19 syn match hlsplaylistTagUnknown "^#EXT[^:]*$"
|
|
20 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagUnknown start="^#EXT[^:]*\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
21
|
|
22 " Basic Tags
|
|
23 syn match hlsplaylistTagHeader "^#EXTM3U$"
|
|
24 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-VERSION\ze:" end="$" keepend contains=hlsplaylistValueInt
|
|
25
|
|
26 " Media or Multivariant Playlist Tags
|
|
27 syn match hlsplaylistTagHeader "^#EXT-X-INDEPENDENT-SEGMENTS$"
|
|
28 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagDelimiter start="^#EXT-X-START\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
29 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-DEFINE\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
30
|
|
31 " Media Playlist Tags
|
|
32 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-TARGETDURATION\ze:" end="$" keepend contains=hlsplaylistValueFloat
|
|
33 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-MEDIA-SEQUENCE\ze:" end="$" keepend contains=hlsplaylistValueInt
|
|
34 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-DISCONTINUITY-SEQUENCE\ze:" end="$" keepend contains=hlsplaylistValueInt
|
|
35 syn match hlsplaylistTagDelimiter "^#EXT-X-ENDLIST$"
|
|
36 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-PLAYLIST-TYPE\ze:" end="$" keepend contains=hlsplaylistAttributeEnum
|
|
37 syn match hlsplaylistTagStandard "^#EXT-X-I-FRAME-ONLY$"
|
|
38 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-PART-INF\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
39 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagHeader start="^#EXT-X-SERVER-CONTROL\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
40
|
|
41 " Media Segment Tags
|
|
42 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXTINF\ze:" end="$" keepend contains=hlsplaylistValueFloat,hlsplaylistExtInfDesc
|
|
43 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-BYTERANGE\ze:" end="$" keepend contains=hlsplaylistValueInt
|
|
44 syn match hlsplaylistTagDelimiter "^#EXT-X-DISCONTINUITY$"
|
|
45 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-KEY\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
46 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-MAP\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
47 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-PROGRAM-DATE-TIME\ze:" end="$" keepend contains=hlsplaylistValueDateTime
|
|
48 syn match hlsplaylistTagDelimiter "^#EXT-X-GAP$"
|
|
49 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-BITRATE\ze:" end="$" keepend contains=hlsplaylistValueFloat
|
|
50 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXT-X-PART\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
51
|
|
52 " Media Metadata Tags
|
|
53 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-DATERANGE\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
54 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-SKIP\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
55 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXT-X-PRELOAD-HINT\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
56 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXT-X-RENDITION-REPORT\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
57
|
|
58 " Multivariant Playlist Tags
|
|
59 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-MEDIA\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
60 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXT-X-STREAM-INF\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
61 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStatement start="^#EXT-X-I-FRAME-STREAM-INF\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
62 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-SESSION-DATA\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
63 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-SESSION-KEY\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
64 syn region hlsplaylistTagLine matchgroup=hlsplaylistTagStandard start="^#EXT-X-CONTENT-STEERING\ze:" end="$" keepend contains=hlsplaylistAttributeList
|
|
65
|
|
66 " Attributes
|
|
67 syn region hlsplaylistAttributeList start=":" end="$" keepend contained
|
|
68 \ contains=hlsplaylistAttributeName,hlsplaylistAttributeInt,hlsplaylistAttributeHex,hlsplaylistAttributeFloat,hlsplaylistAttributeString,hlsplaylistAttributeEnum,hlsplaylistAttributeResolution,hlsplaylistAttributeUri
|
|
69 " Common attributes
|
|
70 syn match hlsplaylistAttributeName "[A-Za-z-]\+\ze=" contained
|
|
71 syn match hlsplaylistAttributeEnum "=\zs[A-Za-z][A-Za-z0-9-_]*" contained
|
|
72 syn match hlsplaylistAttributeString +=\zs"[^"]*"+ contained
|
|
73 syn match hlsplaylistAttributeInt "=\zs\d\+" contained
|
|
74 syn match hlsplaylistAttributeFloat "=\zs-\?\d*\.\d*" contained
|
|
75 syn match hlsplaylistAttributeHex "=\zs0[xX]\d*" contained
|
|
76 syn match hlsplaylistAttributeResolution "=\zs\d\+x\d\+" contained
|
|
77 " Allow different highligting for URI attributes
|
|
78 syn region hlsplaylistAttributeUri matchgroup=hlsplaylistAttributeName start="\zsURI\ze" end="\(,\|$\)" contained contains=hlsplaylistUriQuotes
|
|
79 syn region hlsplaylistUriQuotes matchgroup=hlsplaylistAttributeString start=+"+ end=+"+ keepend contained contains=hlsplaylistUriValue
|
|
80 syn match hlsplaylistUriValue /[^" ]\+/ contained
|
|
81 " Individual values
|
|
82 syn match hlsplaylistValueInt "[0-9]\+" contained
|
|
83 syn match hlsplaylistValueFloat "\(\d\+\|\d*\.\d*\)" contained
|
|
84 syn match hlsplaylistExtInfDesc ",\zs.*$" contained
|
|
85 syn match hlsplaylistValueDateTime "\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\(\.\d*\)\?\(Z\|\d\d:\?\d\d\)$" contained
|
|
86
|
|
87
|
|
88 " Define default highlighting
|
|
89
|
|
90 hi def link hlsplaylistComment Comment
|
|
91 hi def link hlsplaylistUrl NONE
|
|
92
|
|
93 hi def link hlsplaylistTagHeader Special
|
|
94 hi def link hlsplaylistTagStandard Define
|
|
95 hi def link hlsplaylistTagDelimiter Delimiter
|
|
96 hi def link hlsplaylistTagStatement Statement
|
|
97 hi def link hlsplaylistTagUnknown Special
|
|
98
|
|
99 hi def link hlsplaylistUriQuotes String
|
|
100 hi def link hlsplaylistUriValue Underlined
|
|
101 hi def link hlsplaylistAttributeQuotes String
|
|
102 hi def link hlsplaylistAttributeName Identifier
|
|
103 hi def link hlsplaylistAttributeInt Number
|
|
104 hi def link hlsplaylistAttributeHex Number
|
|
105 hi def link hlsplaylistAttributeFloat Float
|
|
106 hi def link hlsplaylistAttributeString String
|
|
107 hi def link hlsplaylistAttributeEnum Constant
|
|
108 hi def link hlsplaylistAttributeResolution Constant
|
|
109 hi def link hlsplaylistValueInt Number
|
|
110 hi def link hlsplaylistValueFloat Float
|
|
111 hi def link hlsplaylistExtInfDesc String
|
|
112 hi def link hlsplaylistValueDateTime Constant
|
|
113
|
|
114
|
|
115 let b:current_syntax = "hlsplaylist"
|
|
116
|
|
117 let &cpo = s:cpo_save
|
|
118 unlet s:cpo_save
|
|
119
|
|
120 " vim: sts=2 sw=2 et
|