3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
6 if exists("b:current_syntax")
10 if !exists("main_syntax")
11 let main_syntax = 'haml'
13 let b:ruby_no_expensive = 1
15 runtime! syntax/html.vim
16 unlet! b:current_syntax
17 silent! syn include @hamlSassTop syntax/sass.vim
18 unlet! b:current_syntax
19 syn include @hamlRubyTop syntax/ruby.vim
23 syn cluster hamlComponent contains=hamlAttributes,hamlClassChar,hamlIdChar,hamlObject,hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
24 syn cluster hamlEmbeddedRuby contains=hamlAttributes,hamlObject,hamlRuby,hamlRubyFilter
25 syn cluster hamlTop contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment
27 syn match hamlBegin "^\s*[<>&]\@!" nextgroup=hamlTag,hamlAttributes,hamlClassChar,hamlIdChar,hamlObject,hamlRuby,hamlPlainChar,hamlInterpolatable
29 syn match hamlTag "%\w\+" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent
30 syn region hamlAttributes matchgroup=hamlAttributesDelimiter start="{" end="}" contained contains=@hamlRubyTop nextgroup=@hamlComponent
31 syn region hamlObject matchgroup=hamlObjectDelimiter start="\[" end="\]" contained contains=@hamlRubyTop nextgroup=@hamlComponent
32 syn match hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
33 syn match hamlSelfCloser "/" contained
34 syn match hamlClassChar "\." contained nextgroup=hamlClass
35 syn match hamlIdChar "#" contained nextgroup=hamlId
36 syn match hamlClass "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
37 syn match hamlId "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
38 syn region hamlDocType start="^\s*!!!" end="$"
40 syn region hamlRuby matchgroup=hamlRubyOutputChar start="[=~]" end="$" contained contains=@hamlRubyTop keepend
41 syn region hamlRuby matchgroup=hamlRubyChar start="-" end="$" contained contains=@hamlRubyTop keepend
42 syn match hamlPlainChar "\\" contained
43 syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="==" end="$" keepend contained contains=hamlInterpolation
44 syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contained contains=@hamlRubyTop
45 syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop
47 syn match hamlHelper "\<action_view?\|\.\@<!\<\%(flatten\|open\|puts\)" contained containedin=@hamlEmbeddedRuby,@hamlRubyTop,rubyInterpolation
48 syn keyword hamlHelper capture_haml find_and_preserve html_attrs init_haml_helpers list_of preced preserve succeed surround tab_down tab_up page_class contained containedin=@hamlEmbeddedRuby,@hamlRubyTop,rubyInterpolation
50 syn cluster hamlHtmlTop contains=@htmlTop,htmlBold,htmlItalic,htmlUnderline
51 syn region hamlPlainFilter matchgroup=hamlFilter start="^\z(\s*\):\%(plain\|preserve\|erb\|redcloth\|textile\|markdown\)\s*$" end="^\%(\z1 \)\@!" contains=@hamlHtmlTop,rubyInterpolation
52 syn region hamlEscapedFilter matchgroup=hamlFilter start="^\z(\s*\):\%(escaped\)\s*$" end="^\%(\z1 \)\@!" contains=rubyInterpolation
53 syn region hamlErbFilter matchgroup=hamlFilter start="^\z(\s*\):erb\s*$" end="^\%(\z1 \)\@!" contains=@hamlHtmlTop,hamlErbInterpolation
54 syn region hamlRubyFilter matchgroup=hamlFilter start="^\z(\s*\):ruby\s*$" end="^\%(\z1 \)\@!" contains=@hamlRubyTop
55 syn region hamlSassFilter matchgroup=hamlFilter start="^\z(\s*\):sass\s*$" end="^\%(\z1 \)\@!" contains=@hamlSassTop
57 syn region hamlJavascriptBlock start="^\z(\s*\)%script" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \)\@!" contains=@hamlTop,@htmlJavaScript keepend
58 syn region hamlCssBlock start="^\z(\s*\)%style" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \)\@!" contains=@hamlTop,@htmlCss keepend
59 syn match hamlError "\$" contained
61 syn region hamlComment start="^\z(\s*\)-#" end="^\%(\z1 \)\@!" contains=rubyTodo
62 syn region hamlHtmlComment start="^\z(\s*\)/" end="^\%(\z1 \)\@!" contains=@hamlTop,rubyTodo
63 syn match hamlIEConditional "\%(^\s*/\)\@<=\[if\>[^]]*]" contained containedin=hamlHtmlComment
65 hi def link hamlSelfCloser Special
66 hi def link hamlDespacer Special
67 hi def link hamlClassChar Special
68 hi def link hamlIdChar Special
69 hi def link hamlTag Special
70 hi def link hamlClass Type
71 hi def link hamlId Identifier
72 hi def link hamlPlainChar Special
73 hi def link hamlInterpolatableChar hamlRubyChar
74 hi def link hamlRubyOutputChar hamlRubyChar
75 hi def link hamlRubyChar Special
76 hi def link hamlInterpolationDelimiter Delimiter
77 hi def link hamlDocType PreProc
78 hi def link hamlFilter PreProc
79 hi def link hamlAttributesDelimiter Delimiter
80 hi def link hamlObjectDelimiter Delimiter
81 hi def link hamlHelper Function
82 hi def link hamlHtmlComment hamlComment
83 hi def link hamlComment Comment
84 hi def link hamlIEConditional SpecialComment
85 hi def link hamlError Error
87 let b:current_syntax = "haml"