Commits

Nicola Paolucci committed d12f55a

Squashed '.vim/bundle/slim-template-vim-slim/' content from commit ee8f2a5

git-subtree-dir: .vim/bundle/slim-template-vim-slim
git-subtree-split: ee8f2a551d6da0823677939e2b83c035659f7db5

Comments (0)

Files changed (5)

+Copyright (C) 2011 Andrew Stone
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+vim-slim
+===
+
+slim syntax highlighting for vim.
+
+1. Install pathogen (if you haven't already)
+
+        mkdir -p ~/.vim/autoload ~/.vim/bundle; \
+        curl -so ~/.vim/autoload/pathogen.vim \
+          https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
+
+2. Edit `~/.vimrc` to run pathogen as the first line of the file (if you haven't already)
+
+        call pathogen#infect()
+
+3. Install slim-vim
+
+        pushd ~/.vim/bundle; \
+        git clone git@github.com:slim-template/vim-slim.git; \
+        popd

ftdetect/slim.vim

+autocmd BufNewFile,BufRead *.slim setf slim
+" Vim indent file
+" Language:	Slim
+
+if exists("b:did_indent")
+  finish
+endif
+runtime! indent/ruby.vim
+unlet! b:did_indent
+let b:did_indent = 1
+
+setlocal autoindent sw=2 et
+setlocal indentexpr=GetSlimIndent()
+setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when
+
+" Only define the function once.
+if exists("*GetSlimIndent")
+  finish
+endif
+
+let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)'
+let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*'
+
+if !exists('g:haml_self_closing_tags')
+  let g:haml_self_closing_tags = 'meta|link|img|hr|br'
+endif
+
+function! GetSlimIndent()
+  let lnum = prevnonblank(v:lnum-1)
+  if lnum == 0
+    return 0
+  endif
+  let line = substitute(getline(lnum),'\s\+$','','')
+  let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
+  let lastcol = strlen(line)
+  let line = substitute(line,'^\s\+','','')
+  let indent = indent(lnum)
+  let cindent = indent(v:lnum)
+  if cline =~# '\v^-\s*%(elsif|else|when)>'
+    let indent = cindent < indent ? cindent : indent - &sw
+  endif
+  let increase = indent + &sw
+  if indent == indent(lnum)
+    let indent = cindent <= indent ? -1 : increase
+  endif
+
+  let group = synIDattr(synID(lnum,lastcol,1),'name')
+
+  if line =~ '^doctype'
+    return indent
+  elseif line =~ '^/\%(\[[^]]*\]\)\=$'
+    return increase
+  elseif line =~ '^[\.#]'
+    return increase
+  elseif line =~? '^div'
+    return increase
+  elseif group == 'hamlFilter'
+    return increase
+  elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)'
+    return increase
+  elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$'
+    return increase
+  elseif line == '-#'
+    return increase
+  elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^\v('.g:haml_self_closing_tags.')>'
+    return indent
+  elseif group =~? '\v^(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$'
+    return increase
+  elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter'
+    return GetRubyIndent()
+  else
+    return indent
+  endif
+endfunction
+
+" vim:set sw=2:
+" 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"