xref: /vim-8.2.3635/runtime/syntax/haml.vim (revision 2387773d)
1" Vim syntax file
2" Language:	Haml
3" Maintainer:	Tim Pope <[email protected]>
4" Filenames:	*.haml
5" Last Change:	2019 Dec 05
6
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
24syn region  rubyCurlyBlock   start="{" end="}" contains=@hamlRubyTop contained
25syn 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
29syn cluster hamlTop          contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment
30
31syn match   hamlBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=hamlTag,hamlClassChar,hamlIdChar,hamlRuby,hamlPlainChar,hamlInterpolatable
32
33syn match   hamlTag        "%\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent
34syn 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
37syn match   hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable
38syn match   hamlSelfCloser "/" contained
39syn match   hamlClassChar "\." contained nextgroup=hamlClass
40syn match   hamlIdChar "#{\@!" contained nextgroup=hamlId
41syn match   hamlClass "\%(\w\|-\|\:\)\+" contained nextgroup=@hamlComponent
42syn match   hamlId    "\%(\w\|-\)\+" contained nextgroup=@hamlComponent
43syn region  hamlDocType start="^\s*!!!" end="$"
44
45syn 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
47syn match   hamlPlainChar "\\" contained
48syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="!\===\|!=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape,@hamlHtmlTop
49syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="&==\|&=\@!"   end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape
50syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD
51syn match  hamlInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
52syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop
53
54syn 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
58syn 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
60
61syn cluster hamlHtmlTop contains=@htmlTop,htmlBold,htmlItalic,htmlUnderline
62syn 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
64syn 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
66syn 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
68syn region  hamlSassFilter       matchgroup=hamlFilter start="^\z(\s*\):sass\s*$"       end="^\%(\z1 \| *$\)\@!" contains=@hamlSassTop
69
70syn region  hamlJavascriptBlock start="^\z(\s*\)%script\%((type=[\"']text/javascript[\"'])\)\=\s*$" 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
72syn match   hamlError "\$" contained
73
74syn region  hamlComment     start="^\z(\s*\)-#" end="^\%(\z1 \| *$\)\@!" contains=rubyTodo
75syn region  hamlHtmlComment start="^\z(\s*\)/"  end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,rubyTodo
76syn 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
90hi def link hamlInterpolationEscape    Special
91hi def link hamlAttributeString        String
92hi def link hamlAttributeVariable      Identifier
93hi 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
105if main_syntax == "haml"
106  unlet main_syntax
107endif
108
109" vim:set sw=2:
110