# HG changeset patch # User edogawaconan # Date 1374464424 -32400 # Node ID 86873b8113432e16d627db392656f5c18054139e # Parent 8c637534d6cdd9d1cb67e626e0ab2430515853b2 Add slim syntax to vim. diff -r 8c637534d6cd -r 86873b811343 rc/vim-syntax-slim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rc/vim-syntax-slim Mon Jul 22 12:40:24 2013 +0900 @@ -0,0 +1,98 @@ +" Vim syntax file +" Language: Slim +" Maintainer: Andrew Stone +" 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 "\\\@.*\(\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" diff -r 8c637534d6cd -r 86873b811343 rc/vimrc --- a/rc/vimrc Sat Jul 20 04:25:06 2013 +0900 +++ b/rc/vimrc Mon Jul 22 12:40:24 2013 +0900 @@ -75,6 +75,7 @@ autocmd BufRead,BufNewFile *.erb :set ft=eruby autocmd BufRead,BufNewFile *.scss :set ft=scss autocmd BufRead,BufNewFile *.coffee :set ft=coffee + autocmd BufRead,BufNewFile *.slim :set ft=slim endif if has('autocmd') diff -r 8c637534d6cd -r 86873b811343 setup --- a/setup Sat Jul 20 04:25:06 2013 +0900 +++ b/setup Mon Jul 22 12:40:24 2013 +0900 @@ -145,6 +145,7 @@ _rc "${1}" "vim-syntax-coffee" ".vim/syntax/coffee.vim" _rc "${1}" "vim-syntax-scss" ".vim/syntax/scss.vim" _rc "${1}" "vim-syntax-json" ".vim/syntax/json.vim" + _rc "${1}" "vim-syntax-slim" ".vim/syntax/slim.vim" _rc "${1}" "vim-autoload-pathogen" ".vim/autoload/pathogen.vim" _rc "${1}" "vimrc" ".vimrc" ;;