2 " Language: Mason (Perl embedded in HTML)
3 " Maintainer: Andrew Smith <andrewdsmith@yahoo.com>
4 " Last change: 2003 May 11
5 " URL: http://www.masonhq.com/editors/mason.vim
7 " This seems to work satisfactorily with html.vim and perl.vim for version 5.5.
8 " Please mail any fixes or improvements to the above address. Things that need
11 " - Add match for component names in <& &> blocks.
12 " - Add match for component names in <%def> and <%method> block delimiters.
13 " - Fix <%text> blocks to show HTML tags but ignore Mason tags.
16 " Clear previous syntax settings unless this is v6 or above, in which case just
17 " exit without doing anything.
21 elseif exists("b:current_syntax")
25 " The HTML syntax file included below uses this variable.
27 if !exists("main_syntax")
28 let main_syntax = 'mason'
31 " First pull in the HTML syntax.
34 so <sfile>:p:h/html.vim
36 runtime! syntax/html.vim
37 unlet b:current_syntax
40 syn cluster htmlPreproc add=@masonTop
42 " Now pull in the Perl syntax.
45 syn include @perlTop <sfile>:p:h/perl.vim
47 syn include @perlTop syntax/perl.vim
50 " It's hard to reduce down to the correct sub-set of Perl to highlight in some
51 " of these cases so I've taken the safe option of just using perlTop in all of
52 " them. If you have any suggestions, please let me know.
54 syn region masonLine matchgroup=Delimiter start="^%" end="$" contains=@perlTop
55 syn region masonExpr matchgroup=Delimiter start="<%" end="%>" contains=@perlTop
56 syn region masonPerl matchgroup=Delimiter start="<%perl>" end="</%perl>" contains=@perlTop
57 syn region masonComp keepend matchgroup=Delimiter start="<&" end="&>" contains=@perlTop
59 syn region masonArgs matchgroup=Delimiter start="<%args>" end="</%args>" contains=@perlTop
61 syn region masonInit matchgroup=Delimiter start="<%init>" end="</%init>" contains=@perlTop
62 syn region masonCleanup matchgroup=Delimiter start="<%cleanup>" end="</%cleanup>" contains=@perlTop
63 syn region masonOnce matchgroup=Delimiter start="<%once>" end="</%once>" contains=@perlTop
64 syn region masonShared matchgroup=Delimiter start="<%shared>" end="</%shared>" contains=@perlTop
66 syn region masonDef matchgroup=Delimiter start="<%def[^>]*>" end="</%def>" contains=@htmlTop
67 syn region masonMethod matchgroup=Delimiter start="<%method[^>]*>" end="</%method>" contains=@htmlTop
69 syn region masonFlags matchgroup=Delimiter start="<%flags>" end="</%flags>" contains=@perlTop
70 syn region masonAttr matchgroup=Delimiter start="<%attr>" end="</%attr>" contains=@perlTop
72 syn region masonFilter matchgroup=Delimiter start="<%filter>" end="</%filter>" contains=@perlTop
74 syn region masonDoc matchgroup=Delimiter start="<%doc>" end="</%doc>"
75 syn region masonText matchgroup=Delimiter start="<%text>" end="</%text>"
77 syn cluster masonTop contains=masonLine,masonExpr,masonPerl,masonComp,masonArgs,masonInit,masonCleanup,masonOnce,masonShared,masonDef,masonMethod,masonFlags,masonAttr,masonFilter,masonDoc,masonText
79 " Set up default highlighting. Almost all of this is done in the included
82 if version >= 508 || !exists("did_mason_syn_inits")
84 let did_mason_syn_inits = 1
85 com -nargs=+ HiLink hi link <args>
87 com -nargs=+ HiLink hi def link <args>
90 HiLink masonDoc Comment
95 let b:current_syntax = "mason"
97 if main_syntax == 'mason'