view rc/vim-syntax-slim @ 493:1ad9091c464e

Properly set window name for vim.
author edogawaconan <me@myconan.net>
date Sat, 09 Nov 2013 17:28:20 +0900
parents 86873b811343
children
line wrap: on
line source

" Vim syntax file
" Language: Slim
" Maintainer: Andrew Stone <andy@stonean.com>
" Version:  1
" Last Change:  2010 Sep 25
" TODO: Feedback is welcomed.

" Quit when a syntax file is already loaded.
if exists("b:current_syntax")
  finish
endif

if !exists("main_syntax")
  let main_syntax = 'slim'
endif

" Allows a per line syntax evaluation.
let b:ruby_no_expensive = 1

" Include Ruby syntax highlighting
syn include @slimRubyTop syntax/ruby.vim
unlet! b:current_syntax
" Include Haml syntax highlighting
syn include @slimHaml syntax/haml.vim
unlet! b:current_syntax

syn match slimBegin  "^\s*\(&[^= ]\)\@!" nextgroup=slimTag,slimClassChar,slimIdChar,slimRuby

syn region  rubyCurlyBlock start="{" end="}" contains=@slimRubyTop contained
syn cluster slimRubyTop    add=rubyCurlyBlock

syn cluster slimComponent contains=slimClassChar,slimIdChar,slimWrappedAttrs,slimRuby,slimAttr,slimInlineTagChar

syn keyword slimDocType        contained html 5 1.1 strict frameset mobile basic transitional
syn match   slimDocTypeKeyword "^\s*\(doctype\)\s\+" nextgroup=slimDocType

syn keyword slimTodo        FIXME TODO NOTE OPTIMIZE XXX contained

syn match slimTag           "\w\+"         contained contains=htmlTagName nextgroup=@slimComponent
syn match slimIdChar        "#{\@!"        contained nextgroup=slimId
syn match slimId            "\%(\w\|-\)\+" contained nextgroup=@slimComponent
syn match slimClassChar     "\."           contained nextgroup=slimClass
syn match slimClass         "\%(\w\|-\)\+" contained nextgroup=@slimComponent
syn match slimInlineTagChar "\s*:\s*"      contained nextgroup=slimTag,slimClassChar,slimIdChar

syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*{\s*" skip="}\s*\""  end="\s*}\s*"  contained contains=slimAttr nextgroup=slimRuby
syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*\[\s*" end="\s*\]\s*" contained contains=slimAttr nextgroup=slimRuby
syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*(\s*"  end="\s*)\s*"  contained contains=slimAttr nextgroup=slimRuby

syn match slimAttr "\s*\%(\w\|-\)\+\s*" contained contains=htmlArg nextgroup=slimAttrAssignment
syn match slimAttrAssignment "\s*=\s*" contained nextgroup=slimWrappedAttrValue,slimAttrString

syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="{" end="}" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar
syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="\[" end="\]" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar
syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="(" end=")" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar

syn region slimAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr,slimRuby,slimInlineTagChar
syn region slimAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr,slimRuby,slimInlineTagChar

syn region slimInnerAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr
syn region slimInnerAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr

syn region slimInterpolation matchgroup=slimInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD,slimWrappedAttrs
syn match  slimInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"

syn region slimRuby matchgroup=slimRubyOutputChar start="\s*[=]\==[']\=" skip=",\s*$" end="$" contained contains=@slimRubyTop keepend
syn region slimRuby matchgroup=slimRubyChar       start="\s*-"           skip=",\s*$" end="$" contained contains=@slimRubyTop keepend

syn match slimComment /^\(\s*\)[/].*\(\n\1\s.*\)*/ contains=slimTodo
syn match slimText    /^\(\s*\)[`|'].*\(\n\1\s.*\)*/

syn match slimFilter /\s*\w\+:\s*/                            contained
syn match slimHaml   /^\(\s*\)\<haml:\>.*\(\n\1\s.*\)*/       contains=@slimHaml,slimFilter

syn match slimIEConditional "\%(^\s*/\)\@<=\[\s*if\>[^]]*]" contained containedin=slimComment

hi def link slimAttrString                String
hi def link slimBegin                     String
hi def link slimClass                     Type
hi def link slimClassChar                 Type
hi def link slimComment                   Comment
hi def link slimDocType                   Identifier
hi def link slimDocTypeKeyword            Keyword
hi def link slimFilter                    Keyword
hi def link slimIEConditional             SpecialComment
hi def link slimId                        Identifier
hi def link slimIdChar                    Identifier
hi def link slimInnerAttrString           String
hi def link slimInterpolationDelimiter    Delimiter
hi def link slimRubyChar                  Special
hi def link slimRubyOutputChar            Special
hi def link slimText                      String
hi def link slimTodo                      Todo
hi def link slimWrappedAttrValueDelimiter Delimiter
hi def link slimWrappedAttrsDelimiter     Delimiter
hi def link slimInlineTagChar             Delimiter

let b:current_syntax = "slim"