Created
April 21, 2011 14:11
-
-
Save lennart/934593 to your computer and use it in GitHub Desktop.
Coffee Script in ERB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| autocmd BufNewFile,BufRead *.erb set filetype=eruby-coffee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Better indent support for ERB by making it possible to indent CoffeeSCript sections | |
| " as well. | |
| if exists("b:did_indent") | |
| finish | |
| endif | |
| " This script pulls in the default indent/coffee.vim with the :runtime command | |
| " which could re-run this script recursively unless we catch that: | |
| if exists('s:doing_indent_inits') | |
| finish | |
| endif | |
| let s:doing_indent_inits = 1 | |
| runtime! indent/eruby.vim | |
| unlet b:did_indent | |
| runtime! indent/coffee.vim | |
| unlet s:doing_indent_inits | |
| function! GetERBCoffeeIndent(lnum) | |
| let eruby_ind = GetErubyIndent(a:lnum) | |
| let coffee_ind = GetCoffeeIndent() | |
| if eruby_ind > -1 | |
| let coffee = "<%\s*coffee_script.*do\s*%>" | |
| if 0 < searchpair(coffee, '', '<%\s*end\s*%>', 'nWb') || 0 < searchpair(coffee, '', '<%\s*end\s*%>', 'nW')) | |
| let coffee_ind = GetCoffeeIndent() | |
| endif | |
| return eruby_ind | |
| endif | |
| return -1 | |
| endfunction | |
| setlocal indentexpr=GetCoffeeIndent(v:lnum) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let b:current_syntax = '' | |
| unlet b:current_syntax | |
| runtime! syntax/eruby.vim | |
| let b:current_syntax = '' | |
| unlet b:current_syntax | |
| syntax include @eRuby syntax/eruby.vim | |
| let b:current_syntax = '' | |
| unlet b:current_syntax | |
| syntax include @Coffee syntax/coffee.vim | |
| syntax region coffeeCode matchgroup=Snip start=/<%\s*coffee_script.*do\s*%>/ end=/<%\s*end\s*%>/ containedin=@eRuby contains=@Coffee | |
| hi link Snip SpecialComment | |
| let b:current_syntax = 'eruby-coffee' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment