summaryrefslogtreecommitdiffstats
path: root/vim/ftplugin/perl.vim
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-04 05:34:04 -0500
committerdoy <doy@tozt.net>2009-01-04 05:34:04 -0500
commite264db140d20aeb8b3bed877b61c03342df1e49c (patch)
tree6c684cf330c363f94d946324743e011d335b133a /vim/ftplugin/perl.vim
parentdbd609695ae9aacb0c3ef25c35a679ad6ea6ccfc (diff)
downloadconf-e264db140d20aeb8b3bed877b61c03342df1e49c.tar.gz
conf-e264db140d20aeb8b3bed877b61c03342df1e49c.zip
check for both perl functions and perl modules when using perldoc for K in perl files
Diffstat (limited to 'vim/ftplugin/perl.vim')
-rw-r--r--vim/ftplugin/perl.vim14
1 files changed, 13 insertions, 1 deletions
diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim
index ecd8f31..62694ca 100644
--- a/vim/ftplugin/perl.vim
+++ b/vim/ftplugin/perl.vim
@@ -3,7 +3,19 @@ setlocal makeprg=$VIMRUNTIME/tools/efm_perl.pl\ -c\ %\ $*
setlocal errorformat=%f:%l:%m
" look up words in perldoc rather than man for K
-setlocal keywordprg=perldoc\ -f
+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 . '"'
+endfunction
+nmap K :call <SID>perldoc(0)<CR>
+vmap K :call <SID>perldoc(1)<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