diff options
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/health/provider.vim | 40 | ||||
-rw-r--r-- | runtime/autoload/provider/perl.vim | 28 |
2 files changed, 42 insertions, 26 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 0482cb7f3c..418d7f880a 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -689,29 +689,31 @@ function! s:check_perl() abort return endif - if !executable('perl') || !executable('cpanm') - call health#report_warn( - \ '`perl` and `cpanm` must be in $PATH.', - \ ['Install Perl and cpanminus and verify that `perl` and `cpanm` commands work.']) - return + let [perl_exec, perl_errors] = provider#perl#Detect() + if empty(perl_exec) + if !empty(perl_errors) + call health#report_error('perl provider error:', perl_errors) + else + call health#report_warn('No usable perl executable found') + endif + return endif - let perl_v = get(split(s:system(['perl', '-W', '-e', 'print $^V']), "\n"), 0, '') - call health#report_info('Perl: '. perl_v) + + call health#report_info('perl executable: '. perl_exec) + + " we cannot use cpanm that is on the path, as it may not be for the perl + " set with g:perl_host_prog + call s:system([perl_exec, '-W', '-MApp::cpanminus', '-e', '']) if s:shell_error - call health#report_warn('Nvim perl host does not support '.perl_v) - " Skip further checks, they are nonsense if perl is too old. - return + return [perl_exec, '"App::cpanminus" module is not installed'] endif - let host = provider#perl#Detect() - if empty(host) - call health#report_warn('Missing "Neovim::Ext" cpan module.', - \ ['Run in shell: cpanm Neovim::Ext']) - return - endif - call health#report_info('Nvim perl host: '. host) + let latest_cpan_cmd = [perl_exec, + \ '-MApp::cpanminus::fatscript', '-e', + \ 'my $app = App::cpanminus::script->new; + \ $app->parse_options ("--info", "-q", "Neovim::Ext"); + \ exit $app->doit'] - let latest_cpan_cmd = 'cpanm --info -q Neovim::Ext' let latest_cpan = s:system(latest_cpan_cmd) if s:shell_error || empty(latest_cpan) call health#report_error('Failed to run: '. latest_cpan_cmd, @@ -735,7 +737,7 @@ function! s:check_perl() abort return endif - let current_cpan_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] + let current_cpan_cmd = [perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] let current_cpan = s:system(current_cpan_cmd) if s:shell_error call health#report_error('Failed to run: '. string(current_cpan_cmd), diff --git a/runtime/autoload/provider/perl.vim b/runtime/autoload/provider/perl.vim index 36ca2bbf14..24f2b018bb 100644 --- a/runtime/autoload/provider/perl.vim +++ b/runtime/autoload/provider/perl.vim @@ -5,15 +5,25 @@ endif let s:loaded_perl_provider = 1 function! provider#perl#Detect() abort - " use g:perl_host_prof if set or check if perl is on the path + " use g:perl_host_prog if set or check if perl is on the path let prog = exepath(get(g:, 'perl_host_prog', 'perl')) if empty(prog) - return '' + return ['', ''] + endif + + " if perl is available, make sure we have 5.22+ + call system([prog, '-e', 'use v5.22']) + if v:shell_error + return ['', 'Perl version is too old, 5.22+ required'] endif " if perl is available, make sure the required module is available call system([prog, '-W', '-MNeovim::Ext', '-e', '']) - return v:shell_error ? '' : prog + if v:shell_error + return ['', '"Neovim::Ext" cpan module is not installed'] + endif + + return [prog, ''] endfunction function! provider#perl#Prog() abort @@ -46,7 +56,7 @@ function! provider#perl#Call(method, args) abort if !exists('s:host') try - let s:host = remote#host#Require('perl') + let s:host = remote#host#Require('legacy-perl-provider') catch let s:err = v:exception echohl WarningMsg @@ -58,12 +68,16 @@ function! provider#perl#Call(method, args) abort return call('rpcrequest', insert(insert(a:args, 'perl_'.a:method), s:host)) endfunction -let s:err = '' -let s:prog = provider#perl#Detect() +let [s:prog, s:err] = provider#perl#Detect() let g:loaded_perl_provider = empty(s:prog) ? 1 : 2 if g:loaded_perl_provider != 2 let s:err = 'Cannot find perl or the required perl module' endif -call remote#host#RegisterPlugin('perl-provider', 'perl', []) + +" The perl provider plugin will run in a separate instance of the perl +" host. +call remote#host#RegisterClone('legacy-perl-provider', 'perl') +call remote#host#RegisterPlugin('legacy-perl-provider', 'ScriptHost.pm', []) + |