neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

chordpro.vim (6633B)


      1 " Vim syntax file
      2 " Language:     ChordPro 6 (https://www.chordpro.org)
      3 " Maintainer:   Niels Bo Andersen <niels@niboan.dk>
      4 " Last Change:  2022-04-15
      5 " 2024 Dec 31:  add "keys" as syntax keyword (via: https://groups.google.com/g/vim_dev/c/vP4epus0euM/m/mNoDY6hsCQAJ)
      6 
      7 " Quit when a syntax file was already loaded
      8 if exists("b:current_syntax")
      9  finish
     10 endif
     11 
     12 let s:cpo_save = &cpo
     13 set cpo&vim
     14 
     15 syn case ignore
     16 
     17 " Include embedded abc syntax
     18 syn include @Abc syntax/abc.vim
     19 
     20 " Lilypond and Pango syntaxes could be embedded as well, but they are not
     21 " available in the distribution.
     22 
     23 " Directives without arguments
     24 syn 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
     54 
     55 " Directives with arguments. Some directives are in both groups, as they can
     56 " be used both with and without arguments
     57 syn 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
     99 
    100 syn keyword chordproMetaKeyword contained meta
    101 syn keyword chordproMetadata contained title sorttitle subtitle artist composer lyricist arranger copyright album year key time tempo duration capo
    102 syn keyword chordproStandardMetadata contained songindex page pages pagerange today tuning instrument user
    103 syn match chordproStandardMetadata /instrument\.type/ contained
    104 syn match chordproStandardMetadata /instrument\.description/ contained
    105 syn match chordproStandardMetadata /user\.name/ contained
    106 syn match chordproStandardMetadata /user\.fullname/ contained
    107 
    108 syn keyword chordproDefineKeyword contained frets fingers keys
    109 syn match chordproDefineKeyword /base-fret/ contained
    110 
    111 syn match chordproArgumentsNumber /\d\+/ contained
    112 
    113 syn match chordproCustom /x_\w\+/ contained
    114 
    115 syn match chordproDirMatch /{\w\+\(-\w\+\)\?}/ contains=chordproDirective contained transparent
    116 syn match chordproDirArgMatch /{\w\+\(-\w\+\)\?[: ]/ contains=chordproDirWithArg contained transparent
    117 syn match chordproMetaMatch /{meta\(-\w\+\)\?[: ]\+\w\+/ contains=chordproMetaKeyword,chordproMetadata contained transparent
    118 syn match chordproCustomMatch /{x_\w\+\(-\w\+\)\?[: ]/ contains=chordproCustom contained transparent
    119 
    120 syn match chordproConditional /-\w\+/ contained
    121 
    122 syn match chordproMetaDataOperator /[=|]/ contained
    123 syn 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
    126 syn region chordproMetaDataTag start=/%{\w*/ skip=/%{[^}]*}/ end=/}/ contains=chordproMetaDataValue,chordproMetaDataOperator,chordproMetadataTag contained
    127 
    128 syn region chordproArguments start=/{\w\+\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproDirArgMatch,chordproArgumentsNumber,chordproMetaDataTag contained
    129 syn region chordproArguments start=/{\(define\|chord\)\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproDirArgMatch,chordproDefineKeyword,chordproArgumentsNumber contained
    130 syn region chordproArguments start=/{meta\(-\w\+\)\?[: ]/hs=e+1 skip=/%{[^}]*}/ end=/}/he=s-1 contains=chordproMetaMatch,chordproMetaDataTag contained
    131 syn region chordproArguments start=/{x_\w\+\(-\w\+\)\?[: ]/hs=e+1 end=/}/he=s-1 contains=chordproCustomMatch contained
    132 
    133 syn region chordproTag start=/{/ skip=/%{[^}]*}/ end=/}/ contains=chordproDirMatch,chordproArguments oneline
    134 
    135 syn region chordproChord matchgroup=chordproBracket start=/\[/ end=/]/ oneline
    136 
    137 syn region chordproAnnotation matchgroup=chordproBracket start=/\[\*/ end=/]/ oneline
    138 
    139 syn 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 
    141 syn 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 
    143 syn 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 
    145 syn region chordproAbc start=/{start_of_abc\(-\w\+\)\?\([: ].\+\)\?}/hs=e+1 end=/{end_of_abc}/me=s-1 contains=chordproTag,@Abc keepend
    146 
    147 syn match chordproComment /^#.*/
    148 
    149 " Define the default highlighting.
    150 hi def link chordproDirective Statement
    151 hi def link chordproDirWithArg Statement
    152 hi def link chordproConditional Statement
    153 hi def link chordproCustom Statement
    154 hi def link chordproMetaKeyword Statement
    155 hi def link chordproMetaDataOperator Operator
    156 hi def link chordproMetaDataTag Function
    157 hi def link chordproArguments Special
    158 hi def link chordproArgumentsNumber Number
    159 hi def link chordproChord Type
    160 hi def link chordproAnnotation Identifier
    161 hi def link chordproTag Constant
    162 hi def link chordproTab PreProc
    163 hi def link chordproComment Comment
    164 hi def link chordproBracket Constant
    165 hi def link chordproDefineKeyword Identifier
    166 hi def link chordproMetadata Identifier
    167 hi def link chordproStandardMetadata Identifier
    168 hi def chordproChorus term=bold cterm=bold gui=bold
    169 hi def chordproBridge term=italic cterm=italic gui=italic
    170 
    171 let b:current_syntax = "chordpro"
    172 
    173 let &cpo = s:cpo_save
    174 unlet s:cpo_save