Skip to content

Instantly share code, notes, and snippets.

@mattn
Created January 16, 2009 02:45
Show Gist options
  • Save mattn/47777 to your computer and use it in GitHub Desktop.
Save mattn/47777 to your computer and use it in GitHub Desktop.
" append to syntax/hatena.vim
function SyntaxSuperPre()
let lnum = 1
let lmax = line("$")
let mx = '^>|\(.*\)|$'
while lnum <= lmax
let curline = getline(lnum)
if curline =~ mx
let lang = substitute(curline, mx, '\1', '')
exec 'runtime! syntax/'.lang.'.vim'
unlet b:current_syntax
let syntaxfile = fnameescape(substitute(globpath(&rtp, 'syntax/'.lang.'.vim'), '[\r\n].*$', '', ''))
if len(syntaxfile)
exec 'syntax include @inline_'.lang.' '.syntaxfile
exec 'syn region hatenaSuperPre matchgroup=hatenaBlockDelimiter start=+^>|'.lang.'|$+ end=+^||<$+ contains=@inline_'.lang
endif
end
let lnum = lnum + 1
endwhile
" workaround for perl
syn cluster inline_perl remove=perlFunctionName
endfunction
call SyntaxSuperPre()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment