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