]> git.donarmstrong.com Git - lilypond.git/blob - vim/lilypond-syntax.vim
Vim syntax: highlight embedded Scheme blocks.
[lilypond.git] / vim / lilypond-syntax.vim
1 " LilyPond syntax file
2 " Language:     LilyPond
3 " Maintainer:   Heikki Junes <hjunes@cc.hut.fi>
4 " Created:      Oct 17, 2002
5 " Last Change:  Aug 30, 2009
6 " Version:      6.1-1
7 "
8 " Installed As: vim/syntax/lilypond.vim
9 " Uses Generated File:  vim/syntax/lilypond-words.vim
10 "
11 " For version 5.x: Clear all syntax items
12 " For version 6.x: Quit when a syntax file was already loaded
13 if version < 600
14   syntax clear
15 elseif exists("b:current_syntax")
16   finish
17 endif
18
19 " Read the LilyPond syntax match groups: 
20 "   lilyKeyword, lilyReservedWord, lilyNote
21 if version < 600
22   so <sfile>:p:h/lilypond-words.vim
23 else
24   runtime! syntax/lilypond-words.vim
25   if exists("b:current_syntax")
26     unlet b:current_syntax
27   endif
28 endif
29
30 " Match also parethesis of angle type
31 setlocal mps+=<:>
32
33 " Case matters
34 syn case match
35
36 syn cluster lilyMatchGroup      contains=lilyMatcher,lilyString,lilyComment,lilyStatement,lilyNumber,lilyEquation,lilySlur,lilySpecial,lilyNote,lilyKeyword,lilyArticulation,lilyReservedWord
37
38 syn region lilyMatcher  matchgroup=Delimiter start="{" skip="\\\\\|\\[<>]"      end="}" contains=@lilyMatchGroup fold
39 syn region lilyMatcher  matchgroup=Delimiter start="\["         end="]" contains=@lilyMatchGroup fold
40 syn region lilyMatcher  matchgroup=Delimiter start="<" skip="\\\\\|\\[{<>}]" end=">"    contains=@lilyMatchGroup fold
41
42 syn region lilyString   start=/"/ end=/"/ skip=/\\"/
43 syn region lilyComment  start="%{" skip="%$" end="%}"
44 syn region lilyComment  start="%\([^{]\|$\)" end="$"
45
46 syn match lilyNumber    "[-_^.]\?\d\+[.]\?"
47 syn match lilyEquation  "\(#['`]\)\?\(\a*[-]\)*\a*\s*=\s*\(#[#'`]\?\)\?\a*"
48 syn match lilySlur      "[(~)]"
49 syn match lilySlur      "\\[()]"
50 syn match lilySpecial   "\\[<!>\\]"
51 " avoid highlighting the extra character in situations like
52 " c--\mf c^^\mf c__\mf
53 syn match lilyArticulation      "[-_^][-_^+|>.]"
54
55 " Include Scheme syntax highlighting, where appropriate
56 syn include @embeddedScheme syntax/scheme.vim
57 unlet b:current_syntax
58 syn region lilyScheme matchgroup=Delimiter start="#(" matchgroup=Delimiter end=")" contains=@embeddedScheme
59
60 " Rest of syntax highlighting rules start here
61 "
62 " " Define the default highlighting.
63 " " For version 5.7 and earlier: only when not done already
64 " " For version 5.8 and later: only when an item doesn't have highlighting yet
65 if version >= 508 || !exists("did_lily_syn_inits")
66   if version < 508
67     let did_lily_syn_inits = 1
68     command -nargs=+ HiLink hi link <args>
69   else
70     command -nargs=+ HiLink hi def link <args>
71   endif
72
73   HiLink Delimiter      Identifier
74   
75   HiLink lilyString     String
76   HiLink lilyComment    Comment
77  
78   HiLink lilyNote       Identifier
79   HiLink lilyArticulation       PreProc
80   HiLink lilyKeyword    Keyword
81   HiLink lilyReservedWord       Type
82
83   HiLink lilyNumber     Constant
84   HiLink lilySpecial    Special
85   HiLink lilySlur       ModeMsg
86
87   delcommand HiLink
88 endif
89
90 let b:current_syntax = "lilypond"