aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-12-27 22:49:44 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-12-27 22:49:44 +0100
commitc1015121ec626cab6cb384f544bc0be1a1760c0e (patch)
tree6cc9a5d1899a4486a24c491e07d17a7dd01f9503 /runtime/autoload
parent4f030ec24e0e148bbb83aedaef7dd629e5fef130 (diff)
parente1876c7ad1b5e30c0a9919e2c4587d11550c8507 (diff)
downloadrneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.gz
rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.bz2
rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.zip
Merge 'upstream/master' into pr-win-erw7
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/health/provider.vim47
-rw-r--r--runtime/autoload/provider/clipboard.vim35
-rw-r--r--runtime/autoload/provider/node.vim2
-rw-r--r--runtime/autoload/provider/pythonx.vim65
-rw-r--r--runtime/autoload/provider/ruby.vim2
-rw-r--r--runtime/autoload/tar.vim34
6 files changed, 114 insertions, 71 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 9a04649bfa..9cd8b3801b 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -152,10 +152,10 @@ function! s:check_clipboard() abort
endif
endfunction
-" Get the latest Neovim Python client version from PyPI.
+" Get the latest Neovim Python client (pynvim) version from PyPI.
function! s:latest_pypi_version() abort
let pypi_version = 'unable to get pypi response'
- let pypi_response = s:download('https://pypi.python.org/pypi/neovim/json')
+ let pypi_response = s:download('https://pypi.python.org/pypi/pynvim/json')
if !empty(pypi_response)
try
let pypi_data = json_decode(pypi_response)
@@ -192,9 +192,9 @@ function! s:version_info(python) abort
let nvim_path = s:trim(s:system([
\ a:python, '-c',
\ 'import sys; sys.path.remove(""); ' .
- \ 'import neovim; print(neovim.__file__)']))
+ \ 'import pynvim; print(pynvim.__file__)']))
if s:shell_error || empty(nvim_path)
- return [python_version, 'unable to load neovim Python module', pypi_version,
+ return [python_version, 'unable to load pynvim Python module', pypi_version,
\ nvim_path]
endif
@@ -206,13 +206,13 @@ function! s:version_info(python) abort
return a == b ? 0 : a > b ? 1 : -1
endfunction
- " Try to get neovim.VERSION (added in 0.1.11dev).
+ " Try to get pynvim.VERSION (added in 0.1.11dev).
let nvim_version = s:system([a:python, '-c',
- \ 'from neovim import VERSION as v; '.
+ \ 'from pynvim import VERSION as v; '.
\ 'print("{}.{}.{}{}".format(v.major, v.minor, v.patch, v.prerelease))'],
\ '', 1, 1)
if empty(nvim_version)
- let nvim_version = 'unable to find neovim Python module version'
+ let nvim_version = 'unable to find pynvim Python module version'
let base = fnamemodify(nvim_path, ':h')
let metas = glob(base.'-*/METADATA', 1, 1)
\ + glob(base.'-*/PKG-INFO', 1, 1)
@@ -293,7 +293,7 @@ function! s:check_python(version) abort
let [pyname, pythonx_errs] = provider#pythonx#Detect(a:version)
if empty(pyname)
- call health#report_warn('No Python interpreter was found with the neovim '
+ call health#report_warn('No Python interpreter was found with the pynvim '
\ . 'module. Using the first available for diagnostics.')
elseif exists('g:'.host_prog_var)
let python_bin = pyname
@@ -352,7 +352,7 @@ function! s:check_python(version) abort
call health#report_warn('pyenv is not set up optimally.', [
\ printf('Create a virtualenv specifically '
\ . 'for Neovim using pyenv, and set `g:%s`. This will avoid '
- \ . 'the need to install the Neovim Python module in each '
+ \ . 'the need to install the pynvim module in each '
\ . 'version/virtualenv.', host_prog_var)
\ ])
elseif !empty(venv)
@@ -366,7 +366,7 @@ function! s:check_python(version) abort
call health#report_warn('Your virtualenv is not set up optimally.', [
\ printf('Create a virtualenv specifically '
\ . 'for Neovim and use `g:%s`. This will avoid '
- \ . 'the need to install Neovim''s Python module in each '
+ \ . 'the need to install the pynvim module in each '
\ . 'virtualenv.', host_prog_var)
\ ])
endif
@@ -400,6 +400,8 @@ function! s:check_python(version) abort
endfor
endif
+ let pip = 'pip' . (a:version == 2 ? '' : '3')
+
if !empty(python_bin)
let [pyversion, current, latest, status] = s:version_info(python_bin)
if a:version != str2nr(pyversion)
@@ -410,28 +412,35 @@ function! s:check_python(version) abort
call health#report_warn('Python 3.3+ is recommended.')
endif
- call health#report_info('Python'.a:version.' version: ' . pyversion)
+ call health#report_info('Python version: ' . pyversion)
if s:is_bad_response(status)
- call health#report_info(printf('%s-neovim version: %s (%s)', pyname, current, status))
+ call health#report_info(printf('pynvim version: %s (%s)', current, status))
else
- call health#report_info(printf('%s-neovim version: %s', pyname, current))
+ call health#report_info(printf('pynvim version: %s', current))
+ let [module_found, _msg] = provider#pythonx#CheckForModule(python_bin,
+ \ 'neovim', a:version)
+ if !module_found
+ call health#report_error('Importing "neovim" failed.',
+ \ "Reinstall \"pynvim\" and optionally \"neovim\" packages.\n" .
+ \ pip ." uninstall pynvim neovim\n" .
+ \ pip ." install pynvim\n" .
+ \ pip ." install neovim # only if needed by third-party software")
+ endif
endif
if s:is_bad_response(current)
call health#report_error(
- \ "Neovim Python client is not installed.\nError: ".current,
- \ ['Run in shell: pip' . a:version . ' install neovim'])
+ \ "pynvim is not installed.\nError: ".current,
+ \ ['Run in shell: '. pip .' install pynvim'])
endif
if s:is_bad_response(latest)
call health#report_warn('Could not contact PyPI to get latest version.')
call health#report_error('HTTP request failed: '.latest)
elseif s:is_bad_response(status)
- call health#report_warn(printf('Latest %s-neovim is NOT installed: %s',
- \ pyname, latest))
+ call health#report_warn(printf('Latest pynvim is NOT installed: %s', latest))
elseif !s:is_bad_response(current)
- call health#report_ok(printf('Latest %s-neovim is installed: %s',
- \ pyname, latest))
+ call health#report_ok(printf('Latest pynvim is installed.'))
endif
endif
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 87a0315073..fd32e03666 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -60,6 +60,7 @@ function! provider#clipboard#Executable() abort
let s:err = 'clipboard: invalid g:clipboard'
return ''
endif
+
let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null })
let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null })
let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0)
@@ -71,18 +72,24 @@ function! provider#clipboard#Executable() abort
let s:paste['*'] = s:paste['+']
let s:cache_enabled = 0
return 'pbcopy'
- elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b')
- let s:copy['+'] = 'xsel --nodetach -i -b'
- let s:paste['+'] = 'xsel -o -b'
- let s:copy['*'] = 'xsel --nodetach -i -p'
- let s:paste['*'] = 'xsel -o -p'
- return 'xsel'
+ elseif exists('$WAYLAND_DISPLAY') && executable('wl-copy') && executable('wl-paste')
+ let s:copy['+'] = 'wl-copy --foreground'
+ let s:paste['+'] = 'wl-paste --no-newline'
+ let s:copy['*'] = 'wl-copy --foreground --primary'
+ let s:paste['*'] = 'wl-paste --no-newline --primary'
+ return 'wl-copy'
elseif exists('$DISPLAY') && executable('xclip')
let s:copy['+'] = 'xclip -quiet -i -selection clipboard'
let s:paste['+'] = 'xclip -o -selection clipboard'
let s:copy['*'] = 'xclip -quiet -i -selection primary'
let s:paste['*'] = 'xclip -o -selection primary'
return 'xclip'
+ elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b')
+ let s:copy['+'] = 'xsel --nodetach -i -b'
+ let s:paste['+'] = 'xsel -o -b'
+ let s:copy['*'] = 'xsel --nodetach -i -p'
+ let s:paste['*'] = 'xsel -o -p'
+ return 'xsel'
elseif executable('lemonade')
let s:copy['+'] = 'lemonade copy'
let s:paste['+'] = 'lemonade paste'
@@ -95,9 +102,9 @@ function! provider#clipboard#Executable() abort
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
return 'doitclient'
- elseif executable('win32yank')
- let s:copy['+'] = 'win32yank -i --crlf'
- let s:paste['+'] = 'win32yank -o --lf'
+ elseif executable('win32yank.exe')
+ let s:copy['+'] = 'win32yank.exe -i --crlf'
+ let s:paste['+'] = 'win32yank.exe -o --lf'
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
return 'win32yank'
@@ -121,7 +128,9 @@ if empty(provider#clipboard#Executable())
endif
function! s:clipboard.get(reg) abort
- if s:selections[a:reg].owner > 0
+ if type(s:paste[a:reg]) == v:t_func
+ return s:paste[a:reg]()
+ elseif s:selections[a:reg].owner > 0
return s:selections[a:reg].data
end
return s:try_cmd(s:paste[a:reg])
@@ -135,6 +144,12 @@ function! s:clipboard.set(lines, regtype, reg) abort
end
return 0
end
+
+ if type(s:copy[a:reg]) == v:t_func
+ call s:copy[a:reg](a:lines, a:regtype)
+ return 0
+ end
+
if s:cache_enabled == 0
call s:try_cmd(s:copy[a:reg], a:lines)
return 0
diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim
index 48ea10aed6..35882849bd 100644
--- a/runtime/autoload/provider/node.vim
+++ b/runtime/autoload/provider/node.vim
@@ -49,7 +49,7 @@ endfunction
function! provider#node#Detect() abort
if exists('g:node_host_prog')
- return g:node_host_prog
+ return expand(g:node_host_prog)
endif
if !s:is_minimum_version(v:null, 6, 0)
return ''
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index b51c398410..b8e2ded00d 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -10,7 +10,7 @@ function! provider#pythonx#Require(host) abort
" Python host arguments
let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog())
- let args = [prog, '-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
+ let args = [prog, '-c', 'import sys; sys.path.remove(""); import pynvim; pynvim.start_host()']
" Collect registered Python plugins into args
let python_plugins = remote#host#PluginsForHost(a:host.name)
@@ -24,13 +24,13 @@ endfunction
function! provider#pythonx#Detect(major_ver) abort
if a:major_ver == 2
if exists('g:python_host_prog')
- return [g:python_host_prog, '']
+ return [expand(g:python_host_prog), '']
else
let progs = ['python2', 'python2.7', 'python2.6', 'python']
endif
else
if exists('g:python3_host_prog')
- return [g:python3_host_prog, '']
+ return [expand(g:python3_host_prog), '']
else
let progs = ['python3', 'python3.7', 'python3.6', 'python3.5',
\ 'python3.4', 'python3.3', 'python']
@@ -40,7 +40,7 @@ function! provider#pythonx#Detect(major_ver) abort
let errors = []
for prog in progs
- let [result, err] = s:check_interpreter(prog, a:major_ver)
+ let [result, err] = provider#pythonx#CheckForModule(prog, 'pynvim', a:major_ver)
if result
return [prog, err]
endif
@@ -54,46 +54,53 @@ function! provider#pythonx#Detect(major_ver) abort
\ . ":\n" . join(errors, "\n")]
endfunction
-function! s:check_interpreter(prog, major_ver) abort
+" Returns array: [prog_exitcode, prog_version]
+function! s:import_module(prog, module) abort
+ let prog_version = system([a:prog, '-c' , printf(
+ \ 'import sys; ' .
+ \ 'sys.path.remove(""); ' .
+ \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
+ \ 'import pkgutil; ' .
+ \ 'exit(2*int(pkgutil.get_loader("%s") is None))',
+ \ a:module)])
+ return [v:shell_error, prog_version]
+endfunction
+
+" Returns array: [was_success, error_message]
+function! provider#pythonx#CheckForModule(prog, module, major_version) abort
let prog_path = exepath(a:prog)
if prog_path ==# ''
return [0, a:prog . ' not found in search path or not executable.']
endif
- let min_version = (a:major_ver == 2) ? '2.6' : '3.3'
+ let min_version = (a:major_version == 2) ? '2.6' : '3.3'
- " Try to load neovim module, and output Python version.
- " Return codes:
- " 0 Neovim module can be loaded.
- " 2 Neovim module cannot be loaded.
+ " Try to load pynvim module, and output Python version.
+ " Exit codes:
+ " 0 pynvim module can be loaded.
+ " 2 pynvim module cannot be loaded.
" Otherwise something else went wrong (e.g. 1 or 127).
- let prog_ver = system([ a:prog , '-c' ,
- \ 'import sys; ' .
- \ 'sys.path.remove(""); ' .
- \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
- \ 'import pkgutil; ' .
- \ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
- \ ])
+ let [prog_exitcode, prog_version] = s:import_module(a:prog, 'pynvim')
- if v:shell_error == 2 || v:shell_error == 0
+ if prog_exitcode == 2 || prog_exitcode == 0
" Check version only for expected return codes.
- if prog_ver !~ '^' . a:major_ver
- return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
- \ . a:major_ver . '.']
- elseif prog_ver =~ '^' . a:major_ver && prog_ver < min_version
- return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python >= '
+ if prog_version !~ '^' . a:major_version
+ return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python '
+ \ . a:major_version . '.']
+ elseif prog_version =~ '^' . a:major_version && prog_version < min_version
+ return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python >= '
\ . min_version . '.']
endif
endif
- if v:shell_error == 2
- return [0, prog_path.' does not have the "neovim" module. :help provider-python']
- elseif v:shell_error == 127
+ if prog_exitcode == 2
+ return [0, prog_path.' does not have the "pynvim" module. :help provider-python']
+ elseif prog_exitcode == 127
" This can happen with pyenv's shims.
- return [0, prog_path . ' does not exist: ' . prog_ver]
- elseif v:shell_error
+ return [0, prog_path . ' does not exist: ' . prog_version]
+ elseif prog_exitcode
return [0, 'Checking ' . prog_path . ' caused an unknown error. '
- \ . '(' . v:shell_error . ', output: ' . prog_ver . ')'
+ \ . '(' . prog_exitcode . ', output: ' . prog_version . ')'
\ . ' Report this at https://github.com/neovim/neovim']
endif
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
index ed9436750b..3b4c6c4839 100644
--- a/runtime/autoload/provider/ruby.vim
+++ b/runtime/autoload/provider/ruby.vim
@@ -45,7 +45,7 @@ endfunction
function! s:detect()
if exists("g:ruby_host_prog")
- return g:ruby_host_prog
+ return expand(g:ruby_host_prog)
elseif has('win32')
return exepath('neovim-ruby-host.bat')
else
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index d92fe1b180..dc670dbd14 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -153,15 +153,14 @@ fun! tar#Browse(tarfile)
let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
endif
- let gzip_command = s:get_gzip_command(tarfile)
-
let curlast= line("$")
if tarfile =~# '\.\(gz\|tgz\)$'
+ let gzip_command = s:get_gzip_command(tarfile)
" call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.lrp'
" call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
- exe "sil! r! cat -- ".shellescape(tarfile,1)."|" . gzip_command . " -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
+ exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$'
" call Decho("3: exe silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
@@ -291,17 +290,16 @@ fun! tar#Read(fname,mode)
let tar_secure= " "
endif
- let gzip_command = s:get_gzip_command(tarfile)
-
if tarfile =~# '\.bz2$'
" call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
elseif tarfile =~# '\.\(gz\|tgz\)$'
+ let gzip_command = s:get_gzip_command(tarfile)
" call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1))
exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
elseif tarfile =~# '\.lrp$'
" call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
- exe "sil! r! cat -- ".shellescape(tarfile,1)." | " . gzip_command . " -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
+ exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
elseif tarfile =~# '\.lzma$'
" call Decho("7: exe silent r! lzma -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
@@ -589,8 +587,9 @@ fun! tar#Vimuntar(...)
" if necessary, decompress the tarball; then, extract it
if tartail =~ '\.tgz'
- if executable("bzip2")
- silent exe "!bzip2 -d ".shellescape(tartail)
+ let gzip_command = s:get_gzip_command(tarfile)
+ if executable(gzip_command)
+ silent exe "!" . gzip_command . " -d ".shellescape(tartail)
elseif executable("gunzip")
silent exe "!gunzip ".shellescape(tartail)
elseif executable("gzip")
@@ -630,11 +629,24 @@ fun! tar#Vimuntar(...)
endfun
func s:get_gzip_command(file)
- if a:file =~# 'z$' && executable('bzip2')
- " Some .tgz files are actually compressed with bzip2. Since bzip2 can
- " handle the format from gzip, use it if the command exists.
+ " Try using the "file" command to get the actual compression type, since
+ " there is no standard way for the naming: ".tgz", ".tbz", ".txz", etc.
+ " If the "file" command doesn't work fall back to just using the file name.
+ if a:file =~# 'z$'
+ let filetype = system('file ' . a:file)
+ if filetype =~ 'bzip2 compressed' && executable('bzip2')
+ return 'bzip2'
+ endif
+ if filetype =~ 'XZ compressed' && executable('xz')
+ return 'xz'
+ endif
+ endif
+ if a:file =~# 'bz2$'
return 'bzip2'
endif
+ if a:file =~# 'xz$'
+ return 'xz'
+ endif
return 'gzip'
endfunc