aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-01-20 17:27:28 -0800
committerGitHub <noreply@github.com>2020-01-20 17:27:28 -0800
commit99aec382596bffaa91d0a944dc9474e42331ad93 (patch)
tree6da5117b428b925fdb46386c8c02b84a92cff6a3
parentf245c0218adc9ff3452660dff97e62cea8e9a411 (diff)
parentb4e4ed844a25aa0ec43404e4ec318d0b54e0e1dd (diff)
downloadrneovim-99aec382596bffaa91d0a944dc9474e42331ad93.tar.gz
rneovim-99aec382596bffaa91d0a944dc9474e42331ad93.tar.bz2
rneovim-99aec382596bffaa91d0a944dc9474e42331ad93.zip
Merge #11703 'CI: install perl provider'
-rw-r--r--.travis.yml3
-rw-r--r--appveyor.yml3
-rwxr-xr-xci/before_install.sh1
-rw-r--r--ci/build.ps127
-rwxr-xr-xci/install.sh3
-rw-r--r--runtime/autoload/health/provider.vim74
-rw-r--r--runtime/autoload/provider/perl.vim69
-rw-r--r--runtime/autoload/remote/host.vim4
-rw-r--r--runtime/doc/provider.txt25
-rw-r--r--src/nvim/eval.c1
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/functional/provider/perl_spec.lua80
12 files changed, 276 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml
index 4bb5c00251..53faf29cc5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -71,6 +71,7 @@ addons:
- build-essential
- clang
- cmake
+ - cpanminus
- cscope
- gcc-multilib
- gdb
@@ -90,7 +91,9 @@ addons:
- powershell
packages:
- ccache
+ - cpanminus
- ninja
+ - perl
jobs:
include:
diff --git a/appveyor.yml b/appveyor.yml
index 7e2aef345b..01ca16f930 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -22,9 +22,6 @@ init:
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
matrix:
fast_finish: true
-install: []
-before_build:
-- ps: Install-Product node 10
build_script:
- powershell ci\build.ps1
after_build:
diff --git a/ci/before_install.sh b/ci/before_install.sh
index 5810bec71a..0303936bdd 100755
--- a/ci/before_install.sh
+++ b/ci/before_install.sh
@@ -44,7 +44,6 @@ fi
source ~/.nvm/nvm.sh
nvm install 10
-nvm use 10
if [[ -n "$CMAKE_URL" ]]; then
echo "Installing custom CMake: $CMAKE_URL"
diff --git a/ci/build.ps1 b/ci/build.ps1
index 524dabdf3e..627dc69e88 100644
--- a/ci/build.ps1
+++ b/ci/build.ps1
@@ -29,6 +29,30 @@ function exitIfFailed() {
}
}
+# https://github.com/lukesampson/scoop#installation
+$scoop = (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
+& {
+ Set-StrictMode -Off
+ Invoke-Expression $scoop
+}
+
+scoop install diffutils perl
+diff3 --version
+perl --version
+cpanm.bat --version
+
+if (-not $NoTests) {
+ scoop install nodejs-lts
+ node --version
+ npm.cmd --version
+
+ cpanm.bat -n Neovim::Ext
+ if ($LastExitCode -ne 0) {
+ Get-Content -Path "$env:USERPROFILE\.cpanm\build.log"
+ }
+ perl -W -e 'use Neovim::Ext; print $Neovim::Ext::VERSION'; exitIfFailed
+}
+
if (-Not (Test-Path -PathType container $env:DEPS_BUILD_DIR)) {
write-host "cache dir not found: $($env:DEPS_BUILD_DIR)"
mkdir $env:DEPS_BUILD_DIR
@@ -57,7 +81,7 @@ if ($compiler -eq 'MINGW') {
# in MSYS2, but we cannot build inside the MSYS2 shell.
$cmakeGenerator = 'Ninja'
$cmakeGeneratorArgs = '-v'
- $mingwPackages = @('ninja', 'cmake', 'perl', 'diffutils').ForEach({
+ $mingwPackages = @('ninja', 'cmake').ForEach({
"mingw-w64-$arch-$_"
})
@@ -115,7 +139,6 @@ if (-not $NoTests) {
if (-Not (Test-Path -PathType Leaf "$env:TREE_SITTER_DIR\bin\c.dll")) {
exit 1
}
-
}
if ($compiler -eq 'MSVC') {
diff --git a/ci/install.sh b/ci/install.sh
index 3364edfe70..b3ec9e7f65 100755
--- a/ci/install.sh
+++ b/ci/install.sh
@@ -50,3 +50,6 @@ else
gcc -m32 -o "$TREE_SITTER_DIR/bin/c.so" -shared parser.c -I.
fi
test -f "$TREE_SITTER_DIR/bin/c.so"
+
+sudo cpanm -n Neovim::Ext || cat "$HOME/.cpanm/build.log"
+perl -W -e 'use Neovim::Ext; print $Neovim::Ext::VERSION'
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index ad7a614ff5..cc7d86d0c1 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -566,7 +566,7 @@ function! s:check_node() abort
endif
let node_v = get(split(s:system('node -v'), "\n"), 0, '')
call health#report_info('Node.js: '. node_v)
- if !s:shell_error && s:version_cmp(node_v[1:], '6.0.0') < 0
+ if s:shell_error || s:version_cmp(node_v[1:], '6.0.0') < 0
call health#report_warn('Neovim node.js host does not support '.node_v)
" Skip further checks, they are nonsense if nodejs is too old.
return
@@ -595,14 +595,12 @@ function! s:check_node() abort
\ 'Are you behind a firewall or proxy?'])
return
endif
- if !empty(latest_npm)
- try
- let pkg_data = json_decode(latest_npm)
- catch /E474/
- return 'error: '.latest_npm
- endtry
- let latest_npm = get(get(pkg_data, 'dist-tags', {}), 'latest', 'unable to parse')
- endif
+ try
+ let pkg_data = json_decode(latest_npm)
+ catch /E474/
+ return 'error: '.latest_npm
+ endtry
+ let latest_npm = get(get(pkg_data, 'dist-tags', {}), 'latest', 'unable to parse')
let current_npm_cmd = ['node', host, '--version']
let current_npm = s:system(current_npm_cmd)
@@ -623,10 +621,68 @@ function! s:check_node() abort
endif
endfunction
+function! s:check_perl() abort
+ call health#report_start('Perl provider (optional)')
+
+ if s:disabled_via_loaded_var('perl')
+ 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
+ endif
+ let perl_v = get(split(s:system(['perl', '-W', '-e', 'print $^V']), "\n"), 0, '')
+ call health#report_info('Perl: '. perl_v)
+ if s:shell_error
+ call health#report_warn('Neovim perl host does not support '.perl_v)
+ " Skip further checks, they are nonsense if perl is too old.
+ return
+ 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('Neovim perl host: '. host)
+
+ let latest_cpan_cmd = 'cpanm --info 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,
+ \ ["Make sure you're connected to the internet.",
+ \ 'Are you behind a firewall or proxy?'])
+ return
+ endif
+ let latest_cpan = matchstr(latest_cpan, '\(\.\?\d\)\+')
+
+ let current_cpan_cmd = [host, '-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),
+ \ ['Report this issue with the output of: ', string(current_cpan_cmd)])
+ return
+ endif
+
+ if s:version_cmp(current_cpan, latest_cpan) == -1
+ call health#report_warn(
+ \ printf('Module "Neovim::Ext" is out-of-date. Installed: %s, latest: %s',
+ \ current_cpan, latest_cpan),
+ \ ['Run in shell: cpanm Neovim::Ext'])
+ else
+ call health#report_ok('Latest "Neovim::Ext" cpan module is installed: '. current_cpan)
+ endif
+endfunction
+
function! health#provider#check() abort
call s:check_clipboard()
call s:check_python(2)
call s:check_python(3)
call s:check_ruby()
call s:check_node()
+ call s:check_perl()
endfunction
diff --git a/runtime/autoload/provider/perl.vim b/runtime/autoload/provider/perl.vim
new file mode 100644
index 0000000000..36ca2bbf14
--- /dev/null
+++ b/runtime/autoload/provider/perl.vim
@@ -0,0 +1,69 @@
+if exists('s:loaded_perl_provider')
+ finish
+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
+ let prog = exepath(get(g:, 'perl_host_prog', 'perl'))
+ if empty(prog)
+ return ''
+ endif
+
+ " if perl is available, make sure the required module is available
+ call system([prog, '-W', '-MNeovim::Ext', '-e', ''])
+ return v:shell_error ? '' : prog
+endfunction
+
+function! provider#perl#Prog() abort
+ return s:prog
+endfunction
+
+function! provider#perl#Require(host) abort
+ if s:err != ''
+ echoerr s:err
+ return
+ endif
+
+ let prog = provider#perl#Prog()
+ let args = [s:prog, '-e', 'use Neovim::Ext; start_host();']
+
+ " Collect registered perl plugins into args
+ let perl_plugins = remote#host#PluginsForHost(a:host.name)
+ for plugin in perl_plugins
+ call add(args, plugin.path)
+ endfor
+
+ return provider#Poll(args, a:host.orig_name, '$NVIM_PERL_LOG_FILE')
+endfunction
+
+function! provider#perl#Call(method, args) abort
+ if s:err != ''
+ echoerr s:err
+ return
+ endif
+
+ if !exists('s:host')
+ try
+ let s:host = remote#host#Require('perl')
+ catch
+ let s:err = v:exception
+ echohl WarningMsg
+ echomsg v:exception
+ echohl None
+ return
+ endtry
+ endif
+ return call('rpcrequest', insert(insert(a:args, 'perl_'.a:method), s:host))
+endfunction
+
+let s:err = ''
+let s:prog = 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', [])
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index 1cf328e08d..c34ff4bee7 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -203,3 +203,7 @@ call remote#host#Register('ruby', '*.rb',
" nodejs
call remote#host#Register('node', '*',
\ function('provider#node#Require'))
+
+" perl
+call remote#host#Register('perl', '*',
+ \ function('provider#perl#Require'))
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index 46ff075cef..0a6cdc60e8 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -127,6 +127,31 @@ To use the RVM "system" Ruby installation: >
let g:ruby_host_prog = 'rvm system do neovim-ruby-host'
==============================================================================
+Perl integration *provider-perl*
+
+Nvim supports Perl |remote-plugin|s.
+https://github.com/jacquesg/p5-Neovim-Ext
+
+
+PERL QUICKSTART~
+
+To use perl remote-plugins with Nvim, install the "Neovim::Ext" cpan package: >
+ cpanm -n Neovim::Ext
+
+Run |:checkhealth| to see if your system is up-to-date.
+
+
+PERL PROVIDER CONFIGURATION~
+ *g:loaded_perl_provider*
+To disable Perl support: >
+ :let g:loaded_perl_provider = 0
+<
+ *g:perl_host_prog*
+Command to start the Perl executable. Must be set before any
+check for has("perl"). >
+ let g:perl_host_prog = '/path/to/perl'
+<
+==============================================================================
Node.js integration *provider-nodejs*
Nvim supports Node.js |remote-plugin|s.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 797c61a482..8c4261f4ba 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -24611,6 +24611,7 @@ bool eval_has_provider(const char *feat)
&& !strequal(feat, "python_dynamic")
&& !strequal(feat, "python3_compiled")
&& !strequal(feat, "python3_dynamic")
+ && !strequal(feat, "perl")
&& !strequal(feat, "ruby")
&& !strequal(feat, "node")) {
// Avoid autoload for non-provider has() features.
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index de61ff9cc8..3ffc6137d6 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -768,7 +768,7 @@ function module.new_pipename()
end
function module.missing_provider(provider)
- if provider == 'ruby' or provider == 'node' then
+ if provider == 'ruby' or provider == 'node' or provider == 'perl' then
local prog = module.funcs['provider#' .. provider .. '#Detect']()
return prog == '' and (provider .. ' not detected') or false
elseif provider == 'python' or provider == 'python3' then
diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua
new file mode 100644
index 0000000000..7b446e4ab3
--- /dev/null
+++ b/test/functional/provider/perl_spec.lua
@@ -0,0 +1,80 @@
+local helpers = require('test.functional.helpers')(after_each)
+local eq, clear = helpers.eq, helpers.clear
+local missing_provider = helpers.missing_provider
+local command = helpers.command
+local write_file = helpers.write_file
+local eval = helpers.eval
+local retry = helpers.retry
+
+do
+ clear()
+ local reason = missing_provider('perl')
+ if reason then
+ pending(string.format("Missing perl host, or perl version is too old (%s)", reason), function() end)
+ return
+ end
+end
+
+before_each(function()
+ clear()
+end)
+
+describe('perl host', function()
+ if helpers.pending_win32(pending) then return end
+ teardown(function ()
+ os.remove('Xtest-perl-hello.pl')
+ os.remove('Xtest-perl-hello-plugin.pl')
+ end)
+
+ it('works', function()
+ local fname = 'Xtest-perl-hello.pl'
+ write_file(fname, [[
+ package main;
+ use strict;
+ use warnings;
+ use Neovim::Ext;
+ use Neovim::Ext::MsgPack::RPC;
+
+ my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM_LISTEN_ADDRESS});
+ my $nvim = Neovim::Ext::from_session($session);
+ $nvim->command('let g:job_out = "hello"');
+ 1;
+ ]])
+ command('let g:job_id = jobstart(["perl", "'..fname..'"])')
+ retry(nil, 3000, function() eq('hello', eval('g:job_out')) end)
+ end)
+
+ it('plugin works', function()
+ local fname = 'Xtest-perl-hello-plugin.pl'
+ write_file(fname, [[
+ package TestPlugin;
+ use strict;
+ use warnings;
+ use parent qw(Neovim::Ext::Plugin);
+
+ __PACKAGE__->register;
+
+ @{TestPlugin::commands} = ();
+ @{TestPlugin::specs} = ();
+ sub test_command :nvim_command('TestCommand')
+ {
+ my ($this) = @_;
+ $this->nvim->command('let g:job_out = "hello-plugin"');
+ }
+
+ package main;
+ use strict;
+ use warnings;
+ use Neovim::Ext;
+ use Neovim::Ext::MsgPack::RPC;
+
+ my $session = Neovim::Ext::MsgPack::RPC::socket_session($ENV{NVIM_LISTEN_ADDRESS});
+ my $nvim = Neovim::Ext::from_session($session);
+ my $plugin = TestPlugin->new($nvim);
+ $plugin->test_command();
+ 1;
+ ]])
+ command('let g:job_id = jobstart(["perl", "'..fname..'"])')
+ retry(nil, 3000, function() eq('hello-plugin', eval('g:job_out')) end)
+ end)
+end)