blob: bf7a07363305a56177137f4b88469fedea7637e3 [file] [log] [blame]
Bram Moolenaarc236c162008-07-13 17:41:49 +00001" Vim syntax file
Bram Moolenaar0ed0eea2010-07-26 22:21:27 +02002" Language: Haml
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4" Filenames: *.haml
Bram Moolenaar6af737f2010-08-09 20:13:35 +02005" Last Change: 2010 Aug 09
Bram Moolenaarc236c162008-07-13 17:41:49 +00006
7if exists("b:current_syntax")
8 finish
9endif
10
11if !exists("main_syntax")
12 let main_syntax = 'haml'
13endif
14let b:ruby_no_expensive = 1
15
16runtime! syntax/html.vim
17unlet! b:current_syntax
18silent! syn include @hamlSassTop syntax/sass.vim
19unlet! b:current_syntax
20syn include @hamlRubyTop syntax/ruby.vim
21
22syn case match
23
Bram Moolenaar6af737f2010-08-09 20:13:35 +020024syn region rubyCurlyBlock start="{" end="}" contains=@hamlRubyTop contained
Bram Moolenaar7a329912010-05-21 12:05:36 +020025syn cluster hamlRubyTop add=rubyCurlyBlock
26
27syn cluster hamlComponent contains=hamlAttributes,hamlAttributesHash,hamlClassChar,hamlIdChar,hamlObject,hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
28syn cluster hamlEmbeddedRuby contains=hamlAttributesHash,hamlObject,hamlRuby,hamlRubyFilter
Bram Moolenaarc236c162008-07-13 17:41:49 +000029syn cluster hamlTop contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment
30
Bram Moolenaar7a329912010-05-21 12:05:36 +020031syn match hamlBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=hamlTag,hamlClassChar,hamlIdChar,hamlRuby,hamlPlainChar,hamlInterpolatable
Bram Moolenaarc236c162008-07-13 17:41:49 +000032
Bram Moolenaar0ed0eea2010-07-26 22:21:27 +020033syn match hamlTag "%\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent
Bram Moolenaar7a329912010-05-21 12:05:36 +020034syn region hamlAttributes matchgroup=hamlAttributesDelimiter start="(" end=")" contained contains=htmlArg,hamlAttributeString,hamlAttributeVariable,htmlEvent,htmlCssDefinition nextgroup=@hamlComponent
35syn region hamlAttributesHash matchgroup=hamlAttributesDelimiter start="{" end="}" contained contains=@hamlRubyTop nextgroup=@hamlComponent
36syn region hamlObject matchgroup=hamlObjectDelimiter start="\[" end="\]" contained contains=@hamlRubyTop nextgroup=@hamlComponent
Bram Moolenaarc236c162008-07-13 17:41:49 +000037syn match hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
38syn match hamlSelfCloser "/" contained
39syn match hamlClassChar "\." contained nextgroup=hamlClass
Bram Moolenaar7a329912010-05-21 12:05:36 +020040syn match hamlIdChar "#{\@!" contained nextgroup=hamlId
Bram Moolenaarc236c162008-07-13 17:41:49 +000041syn match hamlClass "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
42syn match hamlId "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
43syn region hamlDocType start="^\s*!!!" end="$"
44
Bram Moolenaar7a329912010-05-21 12:05:36 +020045syn region hamlRuby matchgroup=hamlRubyOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend
46syn region hamlRuby matchgroup=hamlRubyChar start="-" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend
Bram Moolenaarc236c162008-07-13 17:41:49 +000047syn match hamlPlainChar "\\" contained
Bram Moolenaar7a329912010-05-21 12:05:36 +020048syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="!\===\|!=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape,@hamlHtmlTop
49syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="&==\|&=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape
Bram Moolenaar6af737f2010-08-09 20:13:35 +020050syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD
Bram Moolenaar7a329912010-05-21 12:05:36 +020051syn match hamlInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
Bram Moolenaared39e1d2008-08-09 17:55:22 +000052syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop
Bram Moolenaarc236c162008-07-13 17:41:49 +000053
Bram Moolenaar7a329912010-05-21 12:05:36 +020054syn region hamlAttributeString start=+\%(=\s*\)\@<='+ skip=+\%(\\\\\)*\\'+ end=+'+ contains=hamlInterpolation,hamlInterpolationEscape
55syn region hamlAttributeString start=+\%(=\s*\)\@<="+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=hamlInterpolation,hamlInterpolationEscape
56syn match hamlAttributeVariable "\%(=\s*\)\@<=\%(@@\=\|\$\)\=\w\+" contained
57
Bram Moolenaar6af737f2010-08-09 20:13:35 +020058syn match hamlHelper "\<action_view?\|\<block_is_haml?\|\<is_haml?\|\.\@<!\<flatten" contained containedin=@hamlEmbeddedRuby,@hamlRubyTop
59syn keyword hamlHelper capture_haml escape_once find_and_preserve haml_concat haml_indent haml_tag html_attrs html_esape init_haml_helpers list_of non_haml precede preserve succeed surround tab_down tab_up page_class contained containedin=@hamlEmbeddedRuby,@hamlRubyTop
Bram Moolenaarc236c162008-07-13 17:41:49 +000060
Bram Moolenaared39e1d2008-08-09 17:55:22 +000061syn cluster hamlHtmlTop contains=@htmlTop,htmlBold,htmlItalic,htmlUnderline
Bram Moolenaar6af737f2010-08-09 20:13:35 +020062syn region hamlPlainFilter matchgroup=hamlFilter start="^\z(\s*\):\%(plain\|preserve\|redcloth\|textile\|markdown\|maruku\)\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlInterpolation
63syn region hamlEscapedFilter matchgroup=hamlFilter start="^\z(\s*\):\%(escaped\|cdata\)\s*$" end="^\%(\z1 \| *$\)\@!" contains=hamlInterpolation
Bram Moolenaar7a329912010-05-21 12:05:36 +020064syn region hamlErbFilter matchgroup=hamlFilter start="^\z(\s*\):erb\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlErbInterpolation
65syn region hamlRubyFilter matchgroup=hamlFilter start="^\z(\s*\):ruby\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlRubyTop
Bram Moolenaar6af737f2010-08-09 20:13:35 +020066syn region hamlJavascriptFilter matchgroup=hamlFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1 \| *$\)\@!" contains=@htmlJavaScript,hamlInterpolation keepend
67syn region hamlCSSFilter matchgroup=hamlFilter start="^\z(\s*\):css\s*$" end="^\%(\z1 \| *$\)\@!" contains=@htmlCss,hamlInterpolation keepend
Bram Moolenaar7a329912010-05-21 12:05:36 +020068syn region hamlSassFilter matchgroup=hamlFilter start="^\z(\s*\):sass\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlSassTop
Bram Moolenaarc236c162008-07-13 17:41:49 +000069
Bram Moolenaar7a329912010-05-21 12:05:36 +020070syn region hamlJavascriptBlock start="^\z(\s*\)%script" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlJavaScript keepend
71syn region hamlCssBlock start="^\z(\s*\)%style" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlCss keepend
Bram Moolenaarc236c162008-07-13 17:41:49 +000072syn match hamlError "\$" contained
73
Bram Moolenaar7a329912010-05-21 12:05:36 +020074syn region hamlComment start="^\z(\s*\)-#" end="^\%(\z1 \| *$\)\@!" contains=rubyTodo
75syn region hamlHtmlComment start="^\z(\s*\)/" end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,rubyTodo
Bram Moolenaarc236c162008-07-13 17:41:49 +000076syn match hamlIEConditional "\%(^\s*/\)\@<=\[if\>[^]]*]" contained containedin=hamlHtmlComment
77
78hi def link hamlSelfCloser Special
79hi def link hamlDespacer Special
80hi def link hamlClassChar Special
81hi def link hamlIdChar Special
82hi def link hamlTag Special
83hi def link hamlClass Type
84hi def link hamlId Identifier
85hi def link hamlPlainChar Special
86hi def link hamlInterpolatableChar hamlRubyChar
87hi def link hamlRubyOutputChar hamlRubyChar
88hi def link hamlRubyChar Special
89hi def link hamlInterpolationDelimiter Delimiter
Bram Moolenaar7a329912010-05-21 12:05:36 +020090hi def link hamlInterpolationEscape Special
91hi def link hamlAttributeString String
92hi def link hamlAttributeVariable Identifier
Bram Moolenaarc236c162008-07-13 17:41:49 +000093hi def link hamlDocType PreProc
94hi def link hamlFilter PreProc
95hi def link hamlAttributesDelimiter Delimiter
96hi def link hamlObjectDelimiter Delimiter
97hi def link hamlHelper Function
98hi def link hamlHtmlComment hamlComment
99hi def link hamlComment Comment
100hi def link hamlIEConditional SpecialComment
101hi def link hamlError Error
102
103let b:current_syntax = "haml"
104
Bram Moolenaar7a329912010-05-21 12:05:36 +0200105if main_syntax == "haml"
106 unlet main_syntax
107endif
108
Bram Moolenaarc236c162008-07-13 17:41:49 +0000109" vim:set sw=2: