Skip to content

Commit

Permalink
ref-perldoc Support carton.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamichidu committed May 16, 2015
1 parent 63cef8f commit 5a25164
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions autoload/ref/perldoc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ if !exists('g:ref_perldoc_auto_append_f') " {{{2
let g:ref_perldoc_auto_append_f = 0
endif


let s:source = {'name': 'perldoc'} " {{{1

function! s:source.available()
Expand All @@ -47,8 +46,7 @@ function! s:source.get_body(query)
let cmdarg += ['-m']
endif

let res = ref#system((type(g:ref_perldoc_cmd) == type('') ?
\ split(g:ref_perldoc_cmd, '\s\+') : g:ref_perldoc_cmd) + cmdarg + [q])
let res = ref#system(s:perldoc_cmd() + cmdarg + [q])

if res.stdout == ''
throw printf('No documentation found for "%s".', q)
Expand Down Expand Up @@ -214,7 +212,7 @@ endfunction

function! s:basepod_list(name)
let basepods = []
let base = ref#system(['perl', '-MConfig', '-e',
let base = ref#system(s:perl_cmd() + ['-MConfig', '-e',
\ 'print $Config{installprivlib}']).stdout
for dir in ['pod', 'pods']
if filereadable(printf('%s/%s/perl.pod', base, dir))
Expand All @@ -232,7 +230,7 @@ function! s:basepod_list(name)
endfunction

function! s:modules_list(name)
let inc = ref#system(['perl', '-e', 'print join('';'', @INC)']).stdout
let inc = ref#system(s:perl_cmd() + ['-e', 'print join('';'', @INC)']).stdout
let sep = '[/\\]'
let files = {}
let modules = []
Expand All @@ -252,7 +250,7 @@ function! s:modules_list(name)
endfunction

function! s:func_list(name)
let doc = ref#system('perldoc -u perlfunc').stdout
let doc = ref#system(s:perldoc_cmd() + ['-u', 'perlfunc']).stdout
let i = 0
let funcs = []
while 1
Expand All @@ -270,6 +268,23 @@ function! s:func(name)
return function(matchstr(expand('<sfile>'), '<SNR>\d\+_\zefunc$') . a:name)
endfunction

function! s:perl_cmd()
if filereadable('cpanfile.snapshot') && executable('carton')
return ['carton', 'exec', '--', 'perl']
else
return ['perl']
endif
endfunction

function! s:perldoc_cmd()
if filereadable('cpanfile.snapshot') && executable('carton')
return ['carton', 'exec', '--', 'perldoc']
else
return type(g:ref_perldoc_cmd) == type('')
\ split(g:ref_perldoc_cmd, '\s\+') : g:ref_perldoc_cmd
endif
endfunction

function! ref#perldoc#define()
return s:source
endfunction
Expand Down

0 comments on commit 5a25164

Please sign in to comment.