Bram Moolenaar | c236c16 | 2008-07-13 17:41:49 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Haml |
| 3 | " Maintainer: Tim Pope <vimNOSPAM@tpope.info> |
| 4 | " Filenames: *.haml |
| 5 | |
| 6 | if exists("b:current_syntax") |
| 7 | finish |
| 8 | endif |
| 9 | |
| 10 | if !exists("main_syntax") |
| 11 | let main_syntax = 'haml' |
| 12 | endif |
| 13 | let b:ruby_no_expensive = 1 |
| 14 | |
| 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 |
| 20 | |
| 21 | syn case match |
| 22 | |
| 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 |
| 26 | |
| 27 | syn match hamlBegin "^\s*[<>&]\@!" nextgroup=hamlTag,hamlAttributes,hamlClassChar,hamlIdChar,hamlObject,hamlRuby,hamlPlainChar,hamlInterpolatable |
| 28 | |
| 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="$" |
| 39 | |
| 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 |
Bram Moolenaar | ed39e1d | 2008-08-09 17:55:22 +0000 | [diff] [blame] | 45 | syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop |
Bram Moolenaar | c236c16 | 2008-07-13 17:41:49 +0000 | [diff] [blame] | 46 | |
| 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 |
| 49 | |
Bram Moolenaar | ed39e1d | 2008-08-09 17:55:22 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | c236c16 | 2008-07-13 17:41:49 +0000 | [diff] [blame] | 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 |
| 56 | |
| 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 |
| 60 | |
| 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 |
| 64 | |
| 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 |
| 86 | |
| 87 | let b:current_syntax = "haml" |
| 88 | |
| 89 | " vim:set sw=2: |