blob: 02c34b8466286dbe7486e8167201175e6ebe38ff [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
nibo8dc98bf2024-12-31 11:24:46 +01005" 2024 Dec 31: add "keys" as syntax keyword (via: https://groups.google.com/g/vim_dev/c/vP4epus0euM/m/mNoDY6hsCQAJ)
Bram Moolenaar57657d82006-04-21 22:12:41 +00006
7" Quit when a syntax file was already loaded
8if exists("b:current_syntax")
9 finish
10endif
11
12let s:cpo_save = &cpo
13set cpo&vim
14
Bram Moolenaar57657d82006-04-21 22:12:41 +000015syn case ignore
16
Bram Moolenaarce001a32022-04-27 15:25:03 +010017" Include embedded abc syntax
18syn include @Abc syntax/abc.vim
Bram Moolenaar57657d82006-04-21 22:12:41 +000019
Bram Moolenaarce001a32022-04-27 15:25:03 +010020" Lilypond and Pango syntaxes could be embedded as well, but they are not
21" available in the distribution.
Bram Moolenaar57657d82006-04-21 22:12:41 +000022
Bram Moolenaarce001a32022-04-27 15:25:03 +010023" Directives without arguments
24syn keyword chordproDirective contained nextgroup=chordproConditional
25 \ new_song ns
26 \ start_of_chorus soc
27 \ chorus
28 \ start_of_verse sov
29 \ start_of_bridge sob
30 \ start_of_tab sot
31 \ start_of_grid sog
32 \ start_of_abc
33 \ start_of_ly
34 \ end_of_chorus eoc
35 \ end_of_verse eov
36 \ end_of_bridge eob
37 \ end_of_tab eot
38 \ end_of_grid eog
39 \ end_of_abc
40 \ end_of_ly
41 \ new_page np
42 \ new_physical_page npp
43 \ column_break cb
44 \ grid g
45 \ no_grid ng
46 \ transpose
47 \ chordfont cf chordsize cs chordcolour
48 \ footerfont footersize footercolour
49 \ gridfont gridsize gridcolour
50 \ tabfont tabsize tabcolour
51 \ tocfont tocsize toccolour
52 \ textfont tf textsize ts textcolour
53 \ titlefont titlesize titlecolour
Bram Moolenaar57657d82006-04-21 22:12:41 +000054
Bram Moolenaarce001a32022-04-27 15:25:03 +010055" Directives with arguments. Some directives are in both groups, as they can
56" be used both with and without arguments
57syn keyword chordproDirWithArg contained nextgroup=chordproConditional
58 \ title t
59 \ subtitle st
60 \ sorttitle
61 \ artist
62 \ composer
63 \ lyricist
64 \ arranger
65 \ copyright
66 \ album
67 \ year
68 \ key
69 \ time
70 \ tempo
71 \ duration
72 \ capo
73 \ comment c
74 \ highlight
75 \ comment_italic ci
76 \ comment_box cb
77 \ image
78 \ start_of_chorus soc
79 \ chorus
80 \ start_of_verse sov
81 \ start_of_bridge sob
82 \ start_of_tab sot
83 \ start_of_grid sog
84 \ start_of_abc
85 \ start_of_ly
86 \ define
87 \ chord
88 \ transpose
89 \ chordfont cf chordsize cs chordcolour
90 \ footerfont footersize footercolour
91 \ gridfont gridsize gridcolour
92 \ tabfont tabsize tabcolour
93 \ tocfont tocsize toccolour
94 \ textfont tf textsize ts textcolour
95 \ titlefont titlesize titlecolour
96 \ pagetype
97 \ titles
98 \ columns col
Bram Moolenaar57657d82006-04-21 22:12:41 +000099
Bram Moolenaarce001a32022-04-27 15:25:03 +0100100syn keyword chordproMetaKeyword contained meta
101syn keyword chordproMetadata contained title sorttitle subtitle artist composer lyricist arranger copyright album year key time tempo duration capo
102syn keyword chordproStandardMetadata contained songindex page pages pagerange today tuning instrument user
103syn match chordproStandardMetadata /instrument\.type/ contained
104syn match chordproStandardMetadata /instrument\.description/ contained
105syn match chordproStandardMetadata /user\.name/ contained
106syn match chordproStandardMetadata /user\.fullname/ contained
Bram Moolenaar57657d82006-04-21 22:12:41 +0000107
nibo8dc98bf2024-12-31 11:24:46 +0100108syn keyword chordproDefineKeyword contained frets fingers keys
Bram Moolenaarce001a32022-04-27 15:25:03 +0100109syn match chordproDefineKeyword /base-fret/ contained
110
111syn match chordproArgumentsNumber /\d\+/ contained
112
113syn match chordproCustom /x_\w\+/ contained
114
115syn match chordproDirMatch /{\w\+\(-\w\+\)\?}/ contains=chordproDirective contained transparent
116syn match chordproDirArgMatch /{\w\+\(-\w\+\)\?[: ]/ contains=chordproDirWithArg contained transparent
117syn match chordproMetaMatch /{meta\(-\w\+\)\?[: ]\+\w\+/ contains=chordproMetaKeyword,chordproMetadata contained transparent
118syn match chordproCustomMatch /{x_\w\+\(-\w\+\)\?[: ]/ contains=chordproCustom contained transparent
119
120syn match chordproConditional /-\w\+/ contained
121
122syn match chordproMetaDataOperator /[=|]/ contained
123syn match chordproMetaDataValue /%{\w*/ contains=chordproMetaData,chordproStandardMetadata contained transparent
124" Handles nested metadata tags, but the end of the containing chordproTag is
125" not highlighted correctly, if there are more than two levels of nesting
126syn region chordproMetaDataTag start=/%{\w*/ skip=/%{[^}]*}/ end=/}/ contains=chordproMetaDataValue,chordproMetaDataOperator,chordproMetadataTag contained
127
128syn region chordproArguments start=/{\w\+\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproDirArgMatch,chordproArgumentsNumber,chordproMetaDataTag contained
129syn region chordproArguments start=/{\(define\|chord\)\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproDirArgMatch,chordproDefineKeyword,chordproArgumentsNumber contained
130syn region chordproArguments start=/{meta\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproMetaMatch,chordproMetaDataTag contained
131syn region chordproArguments start=/{x_\w\+\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproCustomMatch contained
132
133syn region chordproTag start=/{/ skip=/%{[^}]*}/ end=/}/ contains=chordproDirMatch,chordproArguments oneline
Bram Moolenaar57657d82006-04-21 22:12:41 +0000134
135syn region chordproChord matchgroup=chordproBracket start=/\[/ end=/]/ oneline
136
Bram Moolenaarce001a32022-04-27 15:25:03 +0100137syn region chordproAnnotation matchgroup=chordproBracket start=/\[\*/ end=/]/ oneline
Bram Moolenaar57657d82006-04-21 22:12:41 +0000138
Bram Moolenaarce001a32022-04-27 15:25:03 +0100139syn region chordproTab start=/{start_of_tab\(-\w\+\)\?\([: ].\+\)\?}\|{sot\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_tab}\|{eot}/me=s-1 contains=chordproTag,chordproComment keepend
140
141syn 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
142
143syn 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
144
145syn 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 +0000146
147syn match chordproComment /^#.*/
148
149" Define the default highlighting.
150hi def link chordproDirective Statement
Bram Moolenaarce001a32022-04-27 15:25:03 +0100151hi def link chordproDirWithArg Statement
152hi def link chordproConditional Statement
153hi def link chordproCustom Statement
154hi def link chordproMetaKeyword Statement
155hi def link chordproMetaDataOperator Operator
156hi def link chordproMetaDataTag Function
157hi def link chordproArguments Special
158hi def link chordproArgumentsNumber Number
Bram Moolenaar57657d82006-04-21 22:12:41 +0000159hi def link chordproChord Type
Bram Moolenaarce001a32022-04-27 15:25:03 +0100160hi def link chordproAnnotation Identifier
Bram Moolenaar57657d82006-04-21 22:12:41 +0000161hi def link chordproTag Constant
162hi def link chordproTab PreProc
163hi def link chordproComment Comment
164hi def link chordproBracket Constant
Bram Moolenaarce001a32022-04-27 15:25:03 +0100165hi def link chordproDefineKeyword Identifier
166hi def link chordproMetadata Identifier
167hi def link chordproStandardMetadata Identifier
Bram Moolenaar57657d82006-04-21 22:12:41 +0000168hi def chordproChorus term=bold cterm=bold gui=bold
Bram Moolenaarce001a32022-04-27 15:25:03 +0100169hi def chordproBridge term=italic cterm=italic gui=italic
Bram Moolenaar57657d82006-04-21 22:12:41 +0000170
171let b:current_syntax = "chordpro"
172
173let &cpo = s:cpo_save
174unlet s:cpo_save