blob: 41a0a1e9d164363b517dfc25a3d0f0376ebdc653 [file] [log] [blame]
Bram Moolenaar57657d82006-04-21 22:12:41 +00001" Vim syntax file
Bram Moolenaarce001a32022-04-27 15:25:03 +01002" Language: ChordPro 6 (https://www.chordpro.org)
Bram Moolenaar57657d82006-04-21 22:12:41 +00003" Maintainer: Niels Bo Andersen <niels@niboan.dk>
Bram Moolenaarce001a32022-04-27 15:25:03 +01004" Last Change: 2022-04-15
Bram Moolenaar57657d82006-04-21 22:12:41 +00005
6" Quit when a syntax file was already loaded
7if exists("b:current_syntax")
8 finish
9endif
10
11let s:cpo_save = &cpo
12set cpo&vim
13
Bram Moolenaar57657d82006-04-21 22:12:41 +000014syn case ignore
15
Bram Moolenaarce001a32022-04-27 15:25:03 +010016" Include embedded abc syntax
17syn include @Abc syntax/abc.vim
Bram Moolenaar57657d82006-04-21 22:12:41 +000018
Bram Moolenaarce001a32022-04-27 15:25:03 +010019" Lilypond and Pango syntaxes could be embedded as well, but they are not
20" available in the distribution.
Bram Moolenaar57657d82006-04-21 22:12:41 +000021
Bram Moolenaarce001a32022-04-27 15:25:03 +010022" Directives without arguments
23syn keyword chordproDirective contained nextgroup=chordproConditional
24 \ new_song ns
25 \ start_of_chorus soc
26 \ chorus
27 \ start_of_verse sov
28 \ start_of_bridge sob
29 \ start_of_tab sot
30 \ start_of_grid sog
31 \ start_of_abc
32 \ start_of_ly
33 \ end_of_chorus eoc
34 \ end_of_verse eov
35 \ end_of_bridge eob
36 \ end_of_tab eot
37 \ end_of_grid eog
38 \ end_of_abc
39 \ end_of_ly
40 \ new_page np
41 \ new_physical_page npp
42 \ column_break cb
43 \ grid g
44 \ no_grid ng
45 \ transpose
46 \ chordfont cf chordsize cs chordcolour
47 \ footerfont footersize footercolour
48 \ gridfont gridsize gridcolour
49 \ tabfont tabsize tabcolour
50 \ tocfont tocsize toccolour
51 \ textfont tf textsize ts textcolour
52 \ titlefont titlesize titlecolour
Bram Moolenaar57657d82006-04-21 22:12:41 +000053
Bram Moolenaarce001a32022-04-27 15:25:03 +010054" Directives with arguments. Some directives are in both groups, as they can
55" be used both with and without arguments
56syn keyword chordproDirWithArg contained nextgroup=chordproConditional
57 \ title t
58 \ subtitle st
59 \ sorttitle
60 \ artist
61 \ composer
62 \ lyricist
63 \ arranger
64 \ copyright
65 \ album
66 \ year
67 \ key
68 \ time
69 \ tempo
70 \ duration
71 \ capo
72 \ comment c
73 \ highlight
74 \ comment_italic ci
75 \ comment_box cb
76 \ image
77 \ start_of_chorus soc
78 \ chorus
79 \ start_of_verse sov
80 \ start_of_bridge sob
81 \ start_of_tab sot
82 \ start_of_grid sog
83 \ start_of_abc
84 \ start_of_ly
85 \ define
86 \ chord
87 \ transpose
88 \ chordfont cf chordsize cs chordcolour
89 \ footerfont footersize footercolour
90 \ gridfont gridsize gridcolour
91 \ tabfont tabsize tabcolour
92 \ tocfont tocsize toccolour
93 \ textfont tf textsize ts textcolour
94 \ titlefont titlesize titlecolour
95 \ pagetype
96 \ titles
97 \ columns col
Bram Moolenaar57657d82006-04-21 22:12:41 +000098
Bram Moolenaarce001a32022-04-27 15:25:03 +010099syn keyword chordproMetaKeyword contained meta
100syn keyword chordproMetadata contained title sorttitle subtitle artist composer lyricist arranger copyright album year key time tempo duration capo
101syn keyword chordproStandardMetadata contained songindex page pages pagerange today tuning instrument user
102syn match chordproStandardMetadata /instrument\.type/ contained
103syn match chordproStandardMetadata /instrument\.description/ contained
104syn match chordproStandardMetadata /user\.name/ contained
105syn match chordproStandardMetadata /user\.fullname/ contained
Bram Moolenaar57657d82006-04-21 22:12:41 +0000106
Bram Moolenaarce001a32022-04-27 15:25:03 +0100107syn keyword chordproDefineKeyword contained frets fingers
108syn match chordproDefineKeyword /base-fret/ contained
109
110syn match chordproArgumentsNumber /\d\+/ contained
111
112syn match chordproCustom /x_\w\+/ contained
113
114syn match chordproDirMatch /{\w\+\(-\w\+\)\?}/ contains=chordproDirective contained transparent
115syn match chordproDirArgMatch /{\w\+\(-\w\+\)\?[: ]/ contains=chordproDirWithArg contained transparent
116syn match chordproMetaMatch /{meta\(-\w\+\)\?[: ]\+\w\+/ contains=chordproMetaKeyword,chordproMetadata contained transparent
117syn match chordproCustomMatch /{x_\w\+\(-\w\+\)\?[: ]/ contains=chordproCustom contained transparent
118
119syn match chordproConditional /-\w\+/ contained
120
121syn match chordproMetaDataOperator /[=|]/ contained
122syn match chordproMetaDataValue /%{\w*/ contains=chordproMetaData,chordproStandardMetadata contained transparent
123" Handles nested metadata tags, but the end of the containing chordproTag is
124" not highlighted correctly, if there are more than two levels of nesting
125syn region chordproMetaDataTag start=/%{\w*/ skip=/%{[^}]*}/ end=/}/ contains=chordproMetaDataValue,chordproMetaDataOperator,chordproMetadataTag contained
126
127syn region chordproArguments start=/{\w\+\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproDirArgMatch,chordproArgumentsNumber,chordproMetaDataTag contained
128syn region chordproArguments start=/{\(define\|chord\)\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproDirArgMatch,chordproDefineKeyword,chordproArgumentsNumber contained
129syn region chordproArguments start=/{meta\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproMetaMatch,chordproMetaDataTag contained
130syn region chordproArguments start=/{x_\w\+\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproCustomMatch contained
131
132syn region chordproTag start=/{/ skip=/%{[^}]*}/ end=/}/ contains=chordproDirMatch,chordproArguments oneline
Bram Moolenaar57657d82006-04-21 22:12:41 +0000133
134syn region chordproChord matchgroup=chordproBracket start=/\[/ end=/]/ oneline
135
Bram Moolenaarce001a32022-04-27 15:25:03 +0100136syn region chordproAnnotation matchgroup=chordproBracket start=/\[\*/ end=/]/ oneline
Bram Moolenaar57657d82006-04-21 22:12:41 +0000137
Bram Moolenaarce001a32022-04-27 15:25:03 +0100138syn region chordproTab start=/{start_of_tab\(-\w\+\)\?\([: ].\+\)\?}\|{sot\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_tab}\|{eot}/me=s-1 contains=chordproTag,chordproComment keepend
139
140syn region chordproChorus start=/{start_of_chorus\(-\w\+\)\?\([: ].\+\)\?}\|{soc\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_chorus}\|{eoc}/me=s-1 contains=chordproTag,chordproChord,chordproAnnotation,chordproComment keepend
141
142syn region chordproBridge start=/{start_of_bridge\(-\w\+\)\?\([: ].\+\)\?}\|{sob\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_bridge}\|{eob}/me=s-1 contains=chordproTag,chordproChord,chordproAnnotation,chordproComment keepend
143
144syn region chordproAbc start=/{start_of_abc\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_abc}/me=s-1 contains=chordproTag,@Abc keepend
Bram Moolenaar57657d82006-04-21 22:12:41 +0000145
146syn match chordproComment /^#.*/
147
148" Define the default highlighting.
149hi def link chordproDirective Statement
Bram Moolenaarce001a32022-04-27 15:25:03 +0100150hi def link chordproDirWithArg Statement
151hi def link chordproConditional Statement
152hi def link chordproCustom Statement
153hi def link chordproMetaKeyword Statement
154hi def link chordproMetaDataOperator Operator
155hi def link chordproMetaDataTag Function
156hi def link chordproArguments Special
157hi def link chordproArgumentsNumber Number
Bram Moolenaar57657d82006-04-21 22:12:41 +0000158hi def link chordproChord Type
Bram Moolenaarce001a32022-04-27 15:25:03 +0100159hi def link chordproAnnotation Identifier
Bram Moolenaar57657d82006-04-21 22:12:41 +0000160hi def link chordproTag Constant
161hi def link chordproTab PreProc
162hi def link chordproComment Comment
163hi def link chordproBracket Constant
Bram Moolenaarce001a32022-04-27 15:25:03 +0100164hi def link chordproDefineKeyword Identifier
165hi def link chordproMetadata Identifier
166hi def link chordproStandardMetadata Identifier
Bram Moolenaar57657d82006-04-21 22:12:41 +0000167hi def chordproChorus term=bold cterm=bold gui=bold
Bram Moolenaarce001a32022-04-27 15:25:03 +0100168hi def chordproBridge term=italic cterm=italic gui=italic
Bram Moolenaar57657d82006-04-21 22:12:41 +0000169
170let b:current_syntax = "chordpro"
171
172let &cpo = s:cpo_save
173unlet s:cpo_save