Skip to content

Instantly share code, notes, and snippets.

@thinca
Forked from mattn/hatena-superpre-syntax.vim
Created June 24, 2009 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinca/134975 to your computer and use it in GitHub Desktop.
Save thinca/134975 to your computer and use it in GitHub Desktop.
" append to syntax/hatena.vim
let b:hatena_syntax_super_pre_loaded = {} " Reset when load.
function! s:update_super_pre()
let mx = '^>|\zs.*\ze|$'
for curline in getline(1, '$')
let ft = matchstr(curline, mx)
if ft != '' && !has_key(b:hatena_syntax_super_pre_loaded, ft)
\ && globpath(&rtp, 'syntax/' . ft . '.vim') != ''
unlet! b:current_syntax
let save_isk= &l:isk " For scheme.
execute printf('syntax include @hatenaSuperPre_%s syntax/%s.vim',
\ ft, ft)
let &l:isk= save_isk
execute printf('syntax region hatenaSuperPre '
\ . 'matchgroup=hatenaBlockDelimiter start="^>|%s|$" end="^||<$" '
\ . 'contains=@hatenaSuperPre_%s', ft, ft)
let b:hatena_syntax_super_pre_loaded[ft] = 1
end
endfor
" workaround for perl
syn cluster HatenaSuperPre_perl remove=perlFunctionName
endfunction
command! -buffer -bar HatenaSuperPreUpdate call s:update_super_pre()
HatenaSuperPreUpdate
" Optional. Append the following if you need.
augroup syntax-hatena-superpre
autocmd!
autocmd CursorHold,CursorHoldI * HatenaSuperPreUpdate
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment