summaryrefslogtreecommitdiffstats
path: root/vim/ftplugin/perl.vim
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-04 20:33:56 -0500
committerdoy <doy@tozt.net>2009-01-04 20:33:56 -0500
commit0068c84d377dfc0361ca2f81738e114e49df4588 (patch)
treef8a2accb3bd27f5717e7ee9037eaab2e181a2a0d /vim/ftplugin/perl.vim
parent6e8c69f0379c4afffdf9c65548c39485c269072e (diff)
downloadconf-0068c84d377dfc0361ca2f81738e114e49df4588.tar.gz
conf-0068c84d377dfc0361ca2f81738e114e49df4588.zip
make perl files use the help buffer thing with perldoc
Diffstat (limited to 'vim/ftplugin/perl.vim')
-rw-r--r--vim/ftplugin/perl.vim26
1 files changed, 14 insertions, 12 deletions
diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim
index 188b325..3fa6eaf 100644
--- a/vim/ftplugin/perl.vim
+++ b/vim/ftplugin/perl.vim
@@ -3,19 +3,21 @@ setlocal makeprg=$VIMRUNTIME/tools/efm_perl.pl\ -c\ %\ $*
setlocal errorformat=%f:%l:%m
" look up words in perldoc rather than man for K
-function! s:perldoc(visual)
- if a:visual
- let oldreg = @a
- normal `<"ay`>gv
- let word = @a
- let @a = oldreg
- else
- let word = expand('<cword>')
- endif
- exe '!perldoc -f "' . word . '" 2>/dev/null || perldoc "' . word . '"'
+function! s:perldoc(word)
+ let perldoc_pager = $PERLDOC_PAGER
+ let $PERLDOC_PAGER = 'cat'
+ exe 'read! perldoc -f "' . a:word . '" 2>/dev/null || perldoc "' . a:word . '"'
+ try
+ silent %s/\%x1b\[\d\+m//g
+ silent %s/.\%x08//g
+ catch /.*/
+ endtry
+ normal ggdd
+ let $PERLDOC_PAGER = perldoc_pager
+ set ft=man
endfunction
-nmap K :call <SID>perldoc(0)<CR>
-vmap K :call <SID>perldoc(1)<CR>
+nmap <silent>K :call Help(0, [':'], '<SID>perldoc')<CR>
+vmap <silent>K :call Help(1, [':'], '<SID>perldoc')<CR>
" treat use lines as include lines (for tab completion, etc)
" XXX: it would be really sweet to make gf work with this, but unfortunately