Created
February 1, 2012 18:39
-
-
Save af/1718564 to your computer and use it in GitHub Desktop.
Obloq syntax highlighting for vim
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
" Syntax highlighting for obloq blocks. This is pretty experimental, and I can only get it | |
" to work with MacVim.app so far (doesn't work with command-line vim). It doesn't yet | |
" work for every file (not sure why). It's also probably really terrible vimscript. | |
" | |
" Supports: | |
" * mustache templates (highlighted as html) | |
" * stylus (highlighted as CSS) | |
" * javascript (.js and .sjs blocks) | |
" | |
" Drop the following into your .vimrc and restart MacVim.app: | |
"=============================================================================== | |
" Obloq filetype-detection and syntax highlighting | |
"=============================================================================== | |
au BufNewFile,BufRead *.md set ft=markdown.obloq | |
" vim syntax regions: http://vimdoc.sourceforge.net/htmldoc/syntax.html | |
" see also http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file | |
" http://vim.wikia.com/wiki/Creating_your_own_syntax_files#Regions | |
" http://stackoverflow.com/questions/519753/vimembedded-syntax-highligting | |
function! ObloqSyntax() abort | |
exe 'runtime! syntax/markdown.vim' | |
exe 'unlet b:current_syntax' | |
exe 'syntax include @Html syntax/html.vim' | |
exe 'syntax region mustache start=/^ file: .*\.mustache/ end=/^\#/re=s-1 contains=@Html' | |
exe 'unlet b:current_syntax' | |
exe 'syntax include @Stylus syntax/css.vim' | |
exe 'syntax region stylus start=/^ file: .*\.stylus/ end=/^\#/re=s-1 contains=@Stylus' | |
exe 'unlet b:current_syntax' | |
exe 'syntax include @Javascript syntax/javascript.vim' | |
exe 'syntax region clientJS start=/^ file: .*\.js/ end=/^\#/re=s-1 contains=@Javascript' | |
exe 'syntax region serverJS start=/^ file: .*\.sjs/ end=/^\#/re=s-1 contains=@Javascript' | |
exe 'unlet b:current_syntax' | |
endfunction | |
autocmd FileType markdown.obloq exe "call ObloqSyntax()" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment