From d4785421106c9ac81adc9ddd5778446d80dbc4ba Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 18 Sep 2019 18:21:44 +0200 Subject: health#provider: fix duplicated output/stderr (#11048) Ref: https://github.com/neovim/neovim/pull/11047#issuecomment-532268826 --- runtime/autoload/health/provider.vim | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 87d82150b6..f1238edbde 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -38,9 +38,10 @@ endfunction " Handler for s:system() function. function! s:system_handler(jobid, data, event) dict abort if a:event ==# 'stderr' - let self.stderr .= join(a:data, '') - if !self.ignore_stderr + if self.add_stderr_to_output let self.output .= join(a:data, '') + else + let self.stderr .= join(a:data, '') endif elseif a:event ==# 'stdout' let self.output .= join(a:data, '') @@ -64,7 +65,7 @@ function! s:system(cmd, ...) abort let stdin = a:0 ? a:1 : '' let ignore_error = a:0 > 2 ? a:3 : 0 let opts = { - \ 'ignore_stderr': a:0 > 1 ? a:2 : 0, + \ 'add_stderr_to_output': a:0 > 1 ? a:2 : 0, \ 'output': '', \ 'stderr': '', \ 'on_stdout': function('s:system_handler'), @@ -89,8 +90,15 @@ function! s:system(cmd, ...) abort call health#report_error(printf('Command timed out: %s', s:shellify(a:cmd))) call jobstop(jobid) elseif s:shell_error != 0 && !ignore_error - call health#report_error(printf("Command error (job=%d, exit code %d): `%s` (in %s)\nOutput: %s\nStderr: %s", - \ jobid, s:shell_error, s:shellify(a:cmd), string(getcwd()), opts.output, opts.stderr)) + let emsg = printf("Command error (job=%d, exit code %d): `%s` (in %s)", + \ jobid, s:shell_error, s:shellify(a:cmd), string(getcwd())) + if !empty(opts.output) + let emsg .= "\noutput: " . opts.output + end + if !empty(opts.stderr) + let emsg .= "\nstderr: " . opts.stderr + end + call health#report_error(emsg) endif return opts.output -- cgit From 45447e3b647259d78434798ddd9c2ae245dcdbcc Mon Sep 17 00:00:00 2001 From: Yoshio S Date: Sun, 22 Sep 2019 08:17:22 +0900 Subject: checkhealth: skip python checks if intentionally disabled #11044 close #11040 --- runtime/autoload/health/provider.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index f1238edbde..f52c2c2cbf 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -276,7 +276,11 @@ function! s:check_python(version) abort let python_multiple = [] if exists(loaded_var) && !exists('*provider#'.pyname.'#Call') - call health#report_info('Disabled ('.loaded_var.'='.eval(loaded_var).'). This might be due to some previous error.') + let v = eval(loaded_var) + call health#report_info('Disabled ('.loaded_var.'='.v.').'.(0 is v ? '' : ' This might be due to some previous error.')) + if 0 is v + return + endif endif let [pyenv, pyenv_root] = s:check_for_pyenv() -- cgit From 179c46a016388c2acead17e56d5860e667748561 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 30 Sep 2019 12:52:04 +0200 Subject: provider#pythonx: resolve/expand exe from host var (#11047) This reverts part of ade88fe4c [1]. This is required for `let g:python3_host_prog = 'python'` etc, where it should get picked up from PATH. Without this it would show: ``` - INFO: pyenv: Path: /home/user/.pyenv/libexec/pyenv - INFO: pyenv: Root: /home/user/.pyenv - INFO: Using: g:python3_host_prog = "python" - ERROR: "python" was not found. - INFO: Executable: Not found - ERROR: Detected pip upgrade failure: Python executable can import "pynvim" but not "neovim": python - ADVICE: - Use that Python version to reinstall "pynvim" and optionally "neovim". pip3 uninstall pynvim neovim pip3 install pynvim pip3 install neovim # only if needed by third-party software ``` Note that it additionally causes a weird error ("Detected pip upgrade failure"), due to `s:check_bin` emptying `python_exe` (because the non-absolute file not being readable), and `provider#pythonx#DetectByModule('pynvim', a:version)` from 75593e6fce then just getting the value from the host var again (without actual checks). This is implicitly fixed via this patch now (because it is skipped), but could need some improvement in this regard probably. With this patch it resolves it (for a virtualenv where pynvim is not made available intentionally): ``` - INFO: pyenv: Path: /home/daniel/.pyenv/libexec/pyenv - INFO: pyenv: Root: /home/daniel/.pyenv - INFO: Using: g:python3_host_prog = "python" - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results. - ADVICE: - If you are using Zsh, see: http://vi.stackexchange.com/a/7654 - INFO: Executable: /home/daniel/.pyenv/shims/tmp-system-deoplete.nvim-f205aF/python - ERROR: Command error (job=11, exit code 1): `'/home/daniel/.pyenv/shims/tmp-system-deoplete.nvim-f205aF/python' -c 'import sys; sys.path.remove(""); import neovim; print(neovim.__file__)'` (in '/home/daniel/.dotfiles/vim/plugged/deoplete.nvim') Output: Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'neovim' Stderr: Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'neovim' - INFO: Python version: 3.7.4 - INFO: pynvim version: unable to load neovim Python module - ERROR: pynvim is not installed. Error: unable to load neovim Python module - ADVICE: - Run in shell: pip3 install pynvim ``` Note: this appears to display the error twice via "Output:" and "Stderr:". 1: https://github.com/neovim/neovim/pull/8784 --- runtime/autoload/health/provider.vim | 2 +- runtime/autoload/provider/pythonx.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index f52c2c2cbf..61858193c3 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -298,7 +298,7 @@ function! s:check_python(version) abort let python_exe = pyname endif - " No Python executable could `import neovim`. + " No Python executable could `import neovim`, or host_prog_var was used. if !empty(pythonx_errors) call health#report_error('Python provider error:', pythonx_errors) diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 59b1c27b72..6ce7165467 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -43,7 +43,7 @@ function! provider#pythonx#DetectByModule(module, major_version) abort let python_exe = s:get_python_executable_from_host_var(a:major_version) if !empty(python_exe) - return [python_exe, ''] + return [exepath(expand(python_exe)), ''] endif let candidates = s:get_python_candidates(a:major_version) -- cgit From 382391bb2de4698feb05e4c8e6c8286ccc4eaa8c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 4 Oct 2019 08:16:30 +0200 Subject: health: provider: skip checks with `g:loaded_X_provider = 0` (#11147) The Python provider was special (via [1]), and would continue to do checks with `0` being set explicitly even. This was fixed in #11044 (45447e3b6), ref: #11040. This extends it to use the same method with all providers. 1: https://github.com/neovim/neovim/pull/8047 --- runtime/autoload/health/provider.vim | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 61858193c3..c750a954fa 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -265,6 +265,22 @@ function! s:check_bin(bin) abort return 1 endfunction +" Check "loaded" var for given a:provider. +" Returns 1 if the caller should return (skip checks). +function! s:disabled_via_loaded_var(provider) abort + let loaded_var = 'g:loaded_'.a:provider.'_provider' + if exists(loaded_var) && !exists('*provider#'.a:provider.'#Call') + let v = eval(loaded_var) + if 0 is v + call health#report_info('Disabled ('.loaded_var.'='.v.').') + return 1 + else + call health#report_info('Disabled ('.loaded_var.'='.v.'). This might be due to some previous error.') + endif + endif + return 0 +endfunction + function! s:check_python(version) abort call health#report_start('Python ' . a:version . ' provider (optional)') @@ -272,15 +288,10 @@ function! s:check_python(version) abort let python_exe = '' let venv = exists('$VIRTUAL_ENV') ? resolve($VIRTUAL_ENV) : '' let host_prog_var = pyname.'_host_prog' - let loaded_var = 'g:loaded_'.pyname.'_provider' let python_multiple = [] - if exists(loaded_var) && !exists('*provider#'.pyname.'#Call') - let v = eval(loaded_var) - call health#report_info('Disabled ('.loaded_var.'='.v.').'.(0 is v ? '' : ' This might be due to some previous error.')) - if 0 is v - return - endif + if s:disabled_via_loaded_var(pyname) + return endif let [pyenv, pyenv_root] = s:check_for_pyenv() @@ -488,9 +499,7 @@ endfunction function! s:check_ruby() abort call health#report_start('Ruby provider (optional)') - let loaded_var = 'g:loaded_ruby_provider' - if exists(loaded_var) && !exists('*provider#ruby#Call') - call health#report_info('Disabled. '.loaded_var.'='.eval(loaded_var)) + if s:disabled_via_loaded_var('ruby') return endif @@ -544,9 +553,7 @@ endfunction function! s:check_node() abort call health#report_start('Node.js provider (optional)') - let loaded_var = 'g:loaded_node_provider' - if exists(loaded_var) && !exists('*provider#node#Call') - call health#report_info('Disabled. '.loaded_var.'='.eval(loaded_var)) + if s:disabled_via_loaded_var('node') return endif -- cgit From ed72d9597d61f4f32162b7810dc93469bcee1ce8 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 24 Oct 2019 20:25:58 +0100 Subject: man.vim: pull out s:get_paths() --- runtime/autoload/man.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 153f1afed8..ec48d96dd6 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -360,14 +360,18 @@ function! man#complete(arg_lead, cmd_line, cursor_pos) abort return s:complete(sect, sect, name) endfunction -function! s:complete(sect, psect, name) abort +function! s:get_paths(sect, name) abort try let mandirs = join(split(s:system(['man', s:find_arg]), ':\|\n'), ',') catch call s:error(v:exception) return endtry - let pages = globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) + return globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) +endfunction + +function! s:complete(sect, psect, name) abort + let pages = s:get_paths(a:sect, a:name) " We remove duplicates in case the same manpage in different languages was found. return uniq(sort(map(pages, 's:format_candidate(v:val, a:psect)'), 'i')) endfunction -- cgit From 63f0ca326322376271c68f51cf8908daad524339 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 22 Oct 2019 23:40:16 +0100 Subject: man.vim: use 'tagfunc' instead of remapping man#pop_tag() is also no longer used --- runtime/autoload/man.vim | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index ec48d96dd6..8825719ec7 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -264,14 +264,6 @@ function! s:push_tag() abort \ }] endfunction -function! man#pop_tag() abort - if !empty(s:tag_stack) - let tag = remove(s:tag_stack, -1) - execute 'silent' tag['buf'].'buffer' - call cursor(tag['lnum'], tag['col']) - endif -endfunction - " extracts the name and sect out of 'path/name.sect' function! s:extract_sect_and_name_path(path) abort let tail = fnamemodify(a:path, ':t') @@ -410,4 +402,19 @@ function! man#init_pager() abort endif endfunction +function! man#goto_tag(pattern, flags, info) abort + " currently no support for section completion + let sect = "" + + let candidates = s:get_paths(sect, a:pattern) + + return map(candidates, { + \ _, path -> { + \ 'name': s:extract_sect_and_name_path(path)[1], + \ 'filename': 'man://' . path, + \ 'cmd': '1' + \ } + \ }) +endfunction + call s:init() -- cgit From 2f0412e61d3c5113f9c121283a7e94a294706387 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 24 Oct 2019 20:48:18 +0100 Subject: man.vim: `:Man` preserves the tag stack --- runtime/autoload/man.vim | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 8825719ec7..9280474516 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -64,8 +64,9 @@ function! man#open_page(count, count1, mods, ...) abort return endtry - call s:push_tag() - let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')') + let fullname = name.(empty(sect)?'':'('.sect.')') + call s:push_tag(fullname) + let bufname = 'man://'.fullname try set eventignore+=BufReadCmd @@ -254,14 +255,30 @@ function! s:verify_exists(sect, name) abort return s:extract_sect_and_name_path(path) + [path] endfunction -let s:tag_stack = [] +function! s:push_tag(name) abort + " emulate vim's tag pushing for cases where we don't use 'tagfunc' + if !&tagstack + return + endif + + let winnr = winnr() + let stack = gettagstack(winnr) + + let curidx = stack.curidx + let items = stack.items + + let newstack = items[0 : curidx - 1] + let newstack += [{ + \ 'bufnr': bufnr('%'), + \ 'from': getpos('.'), + \ 'matchnr': 0, + \ 'tagname': a:name, + \ }] -function! s:push_tag() abort - let s:tag_stack += [{ - \ 'buf': bufnr('%'), - \ 'lnum': line('.'), - \ 'col': col('.'), - \ }] + call settagstack(winnr, { + \ 'length': len(newstack), + \ 'items': newstack, + \ }) endfunction " extracts the name and sect out of 'path/name.sect' -- cgit From 0173bdf98be6f867d1b316d4d2ac87f7a93d95e4 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 24 Oct 2019 21:15:08 +0100 Subject: man.vim: parse the section from the tag --- runtime/autoload/man.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 9280474516..08c6fc1eca 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -420,10 +420,9 @@ function! man#init_pager() abort endfunction function! man#goto_tag(pattern, flags, info) abort - " currently no support for section completion - let sect = "" + let [sect, name] = man#extract_sect_and_name_ref(a:pattern) - let candidates = s:get_paths(sect, a:pattern) + let candidates = s:get_paths(sect, name) return map(candidates, { \ _, path -> { -- cgit From 99aa166cb105cb33df7bb153e93f15b509fcbc8c Mon Sep 17 00:00:00 2001 From: Joshua Rubin Date: Fri, 25 Oct 2019 10:41:22 -0600 Subject: man.vim: never switch to non-man window #11286 In order to find if there was already an open man page, the :Man command would cycle through each window to see if &ft=='man'. This triggers autocmds, e.g. BufEnter, unnecessarily and can have unexpected side-effects. Change the logic to check each window's ft without switching to it unless it is actually a man window. Signed-off-by: Joshua Rubin --- runtime/autoload/man.vim | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 153f1afed8..a9256638e1 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -284,20 +284,16 @@ function! s:extract_sect_and_name_path(path) abort endfunction function! s:find_man() abort - if &filetype ==# 'man' - return 1 - elseif winnr('$') ==# 1 - return 0 - endif - let thiswin = winnr() - while 1 - wincmd w - if &filetype ==# 'man' + let l:win = 1 + while l:win <= winnr('$') + let l:buf = winbufnr(l:win) + if getbufvar(l:buf, '&filetype', '') ==# 'man' + execute l:win.'wincmd w' return 1 - elseif thiswin ==# winnr() - return 0 endif + let l:win += 1 endwhile + return 0 endfunction function! s:error(msg) abort -- cgit From 31536ae003c0bd0ee311fc97b26ded0db8b3fa34 Mon Sep 17 00:00:00 2001 From: supermomonga Date: Mon, 28 Oct 2019 06:27:22 +0900 Subject: provider/pythonx: don't assume CWD (empty string) is in path #11304 sys.path.remove("") raises ValueError if the item is missing. https://docs.python.org/3/library/functions.html#filter: > filter(function, iterable) is equivalent to the generator expression (item > for item in iterable if function(item)) fixes #11293 --- runtime/autoload/health/provider.vim | 3 ++- runtime/autoload/provider/pythonx.vim | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index c750a954fa..ad7a614ff5 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -202,7 +202,8 @@ function! s:version_info(python) abort let nvim_path = s:trim(s:system([ \ a:python, '-c', - \ 'import sys; sys.path.remove(""); ' . + \ 'import sys; ' . + \ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' . \ 'import neovim; print(neovim.__file__)'])) if s:shell_error || empty(nvim_path) return [python_version, 'unable to load neovim Python module', pypi_version, diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 6ce7165467..aec18c0508 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -10,7 +10,8 @@ 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 = list(filter(lambda x: x != "", sys.path)); import neovim; neovim.start_host()'] + " Collect registered Python plugins into args let python_plugins = remote#host#PluginsForHost(a:host.name) @@ -66,7 +67,7 @@ endfunction function! s:import_module(prog, module) abort let prog_version = system([a:prog, '-c' , printf( \ 'import sys; ' . - \ 'sys.path.remove(""); ' . + \ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' . \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' . \ 'import pkgutil; ' . \ 'exit(2*int(pkgutil.get_loader("%s") is None))', -- cgit From c6afad78d39aa77a4d372759336018ef6e101dab Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 29 Oct 2019 18:41:30 +0000 Subject: man.vim: remove push_tag and simplify man#open_page --- runtime/autoload/man.vim | 50 ++++++------------------------------------------ 1 file changed, 6 insertions(+), 44 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 08c6fc1eca..ecbe4bb374 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -64,34 +64,22 @@ function! man#open_page(count, count1, mods, ...) abort return endtry - let fullname = name.(empty(sect)?'':'('.sect.')') - call s:push_tag(fullname) - let bufname = 'man://'.fullname - + let [l:buf, l:save_tfu] = [bufnr(), &tagfunc] try set eventignore+=BufReadCmd + set tagfunc=man#goto_tag + let l:target = l:name . '(' . l:sect . ')' if a:mods !~# 'tab' && s:find_man() - execute 'silent keepalt edit' fnameescape(bufname) + execute 'silent keepalt tag' l:target else - execute 'silent keepalt' a:mods 'split' fnameescape(bufname) + execute 'silent keepalt' a:mods 'stag' l:target endif finally + call setbufvar(l:buf, '&tagfunc', l:save_tfu) set eventignore-=BufReadCmd endtry - try - let page = s:get_page(path) - catch - if a:mods =~# 'tab' || !s:find_man() - " a new window was opened - close - endif - call s:error(v:exception) - return - endtry - let b:man_sect = sect - call s:put_page(page) endfunction function! man#read_page(ref) abort @@ -255,32 +243,6 @@ function! s:verify_exists(sect, name) abort return s:extract_sect_and_name_path(path) + [path] endfunction -function! s:push_tag(name) abort - " emulate vim's tag pushing for cases where we don't use 'tagfunc' - if !&tagstack - return - endif - - let winnr = winnr() - let stack = gettagstack(winnr) - - let curidx = stack.curidx - let items = stack.items - - let newstack = items[0 : curidx - 1] - let newstack += [{ - \ 'bufnr': bufnr('%'), - \ 'from': getpos('.'), - \ 'matchnr': 0, - \ 'tagname': a:name, - \ }] - - call settagstack(winnr, { - \ 'length': len(newstack), - \ 'items': newstack, - \ }) -endfunction - " extracts the name and sect out of 'path/name.sect' function! s:extract_sect_and_name_path(path) abort let tail = fnamemodify(a:path, ':t') -- cgit From b9c9283f729c60d98634587190eb14c6bbf428e5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 10 Nov 2019 12:35:45 -0800 Subject: spellfile.vim: improve error message for missing spellfile Problem: If spellfile is missing, then "set spell" in modeline/sandbox fails with a non-obvious error. Solution: Check for sandbox early and give a meaningful error. Fixes #11359 Test case: # test.latex has `% vim: set spelllang=hu:` # no spell file for `hu` yet! nvim -u NORC --cmd 'autocmd FileType tex setlocal spell' --cmd 'set modeline' test.latex Before: No spell file for "hu" in utf-8 Download it? Downloading hu.utf-8.spl... Error detected while processing /usr/local/share/nvim/runtime/autoload/netrw.vim: line 583: E12: Command not allowed from exrc/vimrc in current dir or tag search: au WinEnter *^Iif &ft == "netrw"|call s:NetrwInsureWinVars()|endif Error detected while processing function spellfile#LoadFile[60]..spellfile#Nread[13]..netrw#NetRead[4]..67_NetrwOptionsSave: line 66: E171: Missing :endif Error detected while processing function spellfile#LoadFile[60]..spellfile#Nread: line 13: E171: Missing :endif Error detected while processing function spellfile#LoadFile: line 60: E171: Missing :endif Error detected while processing modelines: line 1: E12: Command not allowed from exrc/vimrc in current dir or tag search After: Error detected while processing function spellfile#LoadFile: line 5: E605: Exception not caught: Cannot download spellfile in sandbox/modeline. Try ":set spell" from the cmdline. Error detected while processing modelines: line 1: E12: Command not allowed from exrc/vimrc in current dir or tag search --- runtime/autoload/spellfile.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim index c0ef51cdfe..d098902305 100644 --- a/runtime/autoload/spellfile.vim +++ b/runtime/autoload/spellfile.vim @@ -13,6 +13,13 @@ let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset. " This function is used for the spellfile plugin. function! spellfile#LoadFile(lang) + " Check for sandbox/modeline. #11359 + try + :! + catch /\/ + throw 'Cannot download spellfile in sandbox/modeline. Try ":set spell" from the cmdline.' + endtry + " If the netrw plugin isn't loaded we silently skip everything. if !exists(":Nread") if &verbose -- cgit From 00dc12c5d8454a2d3c6806710f63bbb446076e96 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Wed, 13 Nov 2019 12:55:26 -0800 Subject: lua LSP client: initial implementation (#11336) Mainly configuration and RPC infrastructure can be considered "done". Specific requests and their callbacks will be improved later (and also served by plugins). There are also some TODO:s for the client itself, like incremental updates. Co-authored by at-tjdevries and at-h-michael, with many review/suggestion contributions. --- runtime/autoload/lsp.vim | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 runtime/autoload/lsp.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/lsp.vim b/runtime/autoload/lsp.vim new file mode 100644 index 0000000000..4c8f8b396a --- /dev/null +++ b/runtime/autoload/lsp.vim @@ -0,0 +1,45 @@ +function! lsp#add_filetype_config(config) abort + call luaeval('vim.lsp.add_filetype_config(_A)', a:config) +endfunction + +function! lsp#set_log_level(level) abort + call luaeval('vim.lsp.set_log_level(_A)', a:level) +endfunction + +function! lsp#get_log_path() abort + return luaeval('vim.lsp.get_log_path()') +endfunction + +function! lsp#omnifunc(findstart, base) abort + return luaeval("vim.lsp.omnifunc(_A[1], _A[2])", [a:findstart, a:base]) +endfunction + +function! lsp#text_document_hover() abort + lua vim.lsp.buf_request(nil, 'textDocument/hover', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction + +function! lsp#text_document_declaration() abort + lua vim.lsp.buf_request(nil, 'textDocument/declaration', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction + +function! lsp#text_document_definition() abort + lua vim.lsp.buf_request(nil, 'textDocument/definition', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction + +function! lsp#text_document_signature_help() abort + lua vim.lsp.buf_request(nil, 'textDocument/signatureHelp', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction + +function! lsp#text_document_type_definition() abort + lua vim.lsp.buf_request(nil, 'textDocument/typeDefinition', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction + +function! lsp#text_document_implementation() abort + lua vim.lsp.buf_request(nil, 'textDocument/implementation', vim.lsp.protocol.make_text_document_position_params()) + return '' +endfunction -- cgit From aeee41192b4b1e8733f1fa2ebdea32a5dd21dca5 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 13 Nov 2019 21:56:20 +0000 Subject: Remove eventignore - :Man now uses :tag to populate the page --- runtime/autoload/man.vim | 2 -- 1 file changed, 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index ecbe4bb374..f2d34ab82d 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -66,7 +66,6 @@ function! man#open_page(count, count1, mods, ...) abort let [l:buf, l:save_tfu] = [bufnr(), &tagfunc] try - set eventignore+=BufReadCmd set tagfunc=man#goto_tag let l:target = l:name . '(' . l:sect . ')' if a:mods !~# 'tab' && s:find_man() @@ -76,7 +75,6 @@ function! man#open_page(count, count1, mods, ...) abort endif finally call setbufvar(l:buf, '&tagfunc', l:save_tfu) - set eventignore-=BufReadCmd endtry let b:man_sect = sect -- cgit From 18c5f6ab9fa58a69d02a7993dd3ff6f0b9882f26 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 13 Nov 2019 21:57:17 +0000 Subject: Don't attempt swapfiles for man pages This is because we now use :tag to open a man page, which attempts to open a swap file for a path under man://... --- runtime/autoload/man.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index f2d34ab82d..078ccbb429 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -150,6 +150,7 @@ endfunction function! s:put_page(page) abort setlocal modifiable setlocal noreadonly + setlocal noswapfile silent keepjumps %delete _ silent put =a:page while getline(1) =~# '^\s*$' -- cgit From 807e4039cb209539dc71aacbd1718666c18d4552 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 13 Nov 2019 22:00:11 +0000 Subject: Sort man pages by relevance during goto_tag() --- runtime/autoload/man.vim | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 078ccbb429..6c74617aca 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -381,14 +381,23 @@ function! man#init_pager() abort endfunction function! man#goto_tag(pattern, flags, info) abort - let [sect, name] = man#extract_sect_and_name_ref(a:pattern) + let [l:sect, l:name] = man#extract_sect_and_name_ref(a:pattern) - let candidates = s:get_paths(sect, name) + let l:paths = s:get_paths(l:sect, l:name) + let l:structured = [] - return map(candidates, { - \ _, path -> { - \ 'name': s:extract_sect_and_name_path(path)[1], - \ 'filename': 'man://' . path, + for l:path in l:paths + let l:n = s:extract_sect_and_name_path(l:path)[1] + let l:structured += [{ 'name': l:n, 'path': l:path }] + endfor + + " sort by relevance - exact matches first, then the previous order + call sort(l:structured, { a, b -> a.name ==? l:name ? -1 : b.name ==? l:name ? 1 : 0 }) + + return map(l:structured, { + \ _, entry -> { + \ 'name': entry.name, + \ 'filename': 'man://' . entry.path, \ 'cmd': '1' \ } \ }) -- cgit From 97f1222005838912e127e4180d7b779c82e8356d Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Sun, 17 Nov 2019 14:23:17 +0100 Subject: provider/python: add python3.8 executable (#11402) Python 3.8 was released 2019-10-14: https://www.python.org/dev/peps/pep-0569 --- runtime/autoload/provider/pythonx.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index aec18c0508..23e7ff8f64 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -29,8 +29,8 @@ endfunction function! s:get_python_candidates(major_version) abort return { \ 2: ['python2', 'python2.7', 'python2.6', 'python'], - \ 3: ['python3', 'python3.7', 'python3.6', 'python3.5', 'python3.4', 'python3.3', - \ 'python'] + \ 3: ['python3', 'python3.8', 'python3.7', 'python3.6', 'python3.5', + \ 'python3.4', 'python3.3', 'python'] \ }[a:major_version] endfunction -- cgit From 2d580756ca707945c01703d404e10f4bf412a72c Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Wed, 20 Nov 2019 15:35:18 -0800 Subject: Add everything to lsp.buf and get rid of autoload. --- runtime/autoload/lsp.vim | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 runtime/autoload/lsp.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/lsp.vim b/runtime/autoload/lsp.vim deleted file mode 100644 index 4c8f8b396a..0000000000 --- a/runtime/autoload/lsp.vim +++ /dev/null @@ -1,45 +0,0 @@ -function! lsp#add_filetype_config(config) abort - call luaeval('vim.lsp.add_filetype_config(_A)', a:config) -endfunction - -function! lsp#set_log_level(level) abort - call luaeval('vim.lsp.set_log_level(_A)', a:level) -endfunction - -function! lsp#get_log_path() abort - return luaeval('vim.lsp.get_log_path()') -endfunction - -function! lsp#omnifunc(findstart, base) abort - return luaeval("vim.lsp.omnifunc(_A[1], _A[2])", [a:findstart, a:base]) -endfunction - -function! lsp#text_document_hover() abort - lua vim.lsp.buf_request(nil, 'textDocument/hover', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction - -function! lsp#text_document_declaration() abort - lua vim.lsp.buf_request(nil, 'textDocument/declaration', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction - -function! lsp#text_document_definition() abort - lua vim.lsp.buf_request(nil, 'textDocument/definition', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction - -function! lsp#text_document_signature_help() abort - lua vim.lsp.buf_request(nil, 'textDocument/signatureHelp', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction - -function! lsp#text_document_type_definition() abort - lua vim.lsp.buf_request(nil, 'textDocument/typeDefinition', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction - -function! lsp#text_document_implementation() abort - lua vim.lsp.buf_request(nil, 'textDocument/implementation', vim.lsp.protocol.make_text_document_position_params()) - return '' -endfunction -- cgit From 526798a941b4cf80fd1f128b40e51fb47c77b654 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 24 Nov 2019 20:30:04 -0500 Subject: man.vim: Ensure 'modifiable' in man#init_pager #11450 --- runtime/autoload/man.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 36f42c0003..c559ca9f27 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -1,4 +1,4 @@ -" Maintainer: Anmol Sethi +" Maintainer: Anmol Sethi if exists('s:loaded_man') finish @@ -357,6 +357,10 @@ function! s:format_candidate(path, psect) abort endfunction function! man#init_pager() abort + " https://github.com/neovim/neovim/issues/6828 + let og_modifiable = &modifiable + setlocal modifiable + if getline(1) =~# '^\s*$' silent keepjumps 1delete _ else @@ -374,6 +378,8 @@ function! man#init_pager() abort if -1 == match(bufname('%'), 'man:\/\/') " Avoid duplicate buffers, E95. execute 'silent file man://'.tolower(fnameescape(ref)) endif + + let &l:modifiable = og_modifiable endfunction function! man#goto_tag(pattern, flags, info) abort -- cgit From 4ce96e497909505b6253e987812e24e8fa08daec Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 24 Nov 2019 19:55:38 -0500 Subject: man.vim: Hard wrap by default Closes #11436 --- runtime/autoload/man.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 36f42c0003..0777d2202f 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -139,7 +139,7 @@ function! s:get_page(path) abort " Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065). " Soft-wrap: ftplugin/man.vim sets wrap/breakindent/…. " Hard-wrap: driven by `man`. - let manwidth = !get(g:,'man_hardwrap') ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) + let manwidth = !get(g:,'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. -- cgit From 33beeed4d9c2bda79d48a58ec10e8b05e7de5122 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 28 Nov 2019 05:01:04 +0000 Subject: man.vim: Improve ft=man 'iskeyword' #11457 This addresses a minor quality problem with the recent `'tagfunc'` changes for `man.vim` (see [link]). Currently, with the cursor on a parenthese, hitting `K` will jump us to the man page of the next mentioned entry, instead of the one to which the parenthese (or section number) belongs. ``` pcrepattern(3), terminfo(5), glob(7), regex(7). e.g. ^ e.g. ^ ``` Adding the parentheses to `'iskeyword'` means we correctly handle these cases too. [link]: https://github.com/neovim/neovim/pull/11280#discussion_r348342357 --- runtime/autoload/man.vim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 809e4a19d8..e4c0080ae9 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -151,6 +151,8 @@ function! s:put_page(page) abort setlocal modifiable setlocal noreadonly setlocal noswapfile + " git-ls-files(1) is all one keyword/tag-target + setlocal iskeyword+=(,) silent keepjumps %delete _ silent put =a:page while getline(1) =~# '^\s*$' -- cgit From 6c22c7ab97cca9f8dda6863ee7f1db1ce30a3451 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 10 Dec 2019 00:46:04 -0800 Subject: netrw.vim: do not save +/* registers netrw shouldn't be touching these in the first place. fix #11089 ref #6892 ref #6695 --- runtime/autoload/netrw.vim | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index a5b47e06d5..9b1266c4ca 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -688,10 +688,6 @@ fun! netrw#Explore(indx,dosplit,style,...) endif " save registers - if has("clipboard") - sil! let keepregstar = @* - sil! let keepregplus = @+ - endif sil! let keepregslash= @/ " if dosplit @@ -915,10 +911,6 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("")) if !exists("w:netrw_explore_list") " sanity check NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or improperly; see help for netrw-starstar",40) - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore") return @@ -940,10 +932,6 @@ fun! netrw#Explore(indx,dosplit,style,...) " call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("")) if !exists("w:netrw_explore_list") " sanity check NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or improperly; see help for netrw-starstar",41) - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore") return @@ -995,10 +983,6 @@ fun! netrw#Explore(indx,dosplit,style,...) catch /^Vim\%((\a\+)\)\=:E480/ keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore : no files matched pattern") return @@ -1031,10 +1015,6 @@ fun! netrw#Explore(indx,dosplit,style,...) if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42) - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore : no files matched") return @@ -1079,10 +1059,6 @@ fun! netrw#Explore(indx,dosplit,style,...) if !exists("g:netrw_quiet") keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) endif - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore : missing +path_extra") return @@ -1152,10 +1128,6 @@ fun! netrw#Explore(indx,dosplit,style,...) " there's no danger of a late FocusGained event on initialization. " Consequently, set s:netrw_events to 2. let s:netrw_events= 2 - if has("clipboard") - sil! let @* = keepregstar - sil! let @+ = keepregplus - endif sil! let @/ = keepregslash " call Dret("netrw#Explore : @/<".@/.">") endfun @@ -9559,10 +9531,6 @@ fun! s:NetrwWideListing() let newcolstart = w:netrw_bannercnt + fpc let newcolend = newcolstart + fpc - 1 " call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]",'~'.expand("")) - if has("clipboard") - sil! let keepregstar = @* - sil! let keepregplus = @+ - endif while line("$") >= newcolstart if newcolend > line("$") | let newcolend= line("$") | endif let newcolqty= newcolend - newcolstart @@ -9575,10 +9543,6 @@ fun! s:NetrwWideListing() exe "sil! NetrwKeepj ".newcolstart.','.newcolend.'d _' exe 'sil! NetrwKeepj '.w:netrw_bannercnt endwhile - if has("clipboard") - sil! let @*= keepregstar - sil! let @+= keepregplus - endif exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$s/\s\+$//e' NetrwKeepj call histdel("/",-1) exe 'nno w :call search(''^.\\|\s\s\zs\S'',''W'')'."\" -- cgit From b3686b1597ea202de464df72a88fb5c76fd1b814 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 24 Dec 2019 07:53:56 +0100 Subject: system(), jobstart(): raise error on non-executable #11234 * tv_to_argv: error when cmd is not executable Callers always assume that emsg was emitted: - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L12509 - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L17923 - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L18202 * test/functional/provider: display reason from missing_provider * provider#node#Detect: skip / handle non-existing node executable --- runtime/autoload/provider/node.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index b2a3b3ee08..c5d5e87729 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -51,6 +51,9 @@ function! provider#node#Detect() abort if exists('g:node_host_prog') return expand(g:node_host_prog) endif + if !executable('node') + return '' + endif if !s:is_minimum_version(v:null, 6, 0) return '' endif -- cgit From ddffd3173730e744b4c25094be45e3673f7a186d Mon Sep 17 00:00:00 2001 From: artem-nefedov Date: Sun, 29 Dec 2019 10:57:28 +0300 Subject: netrw.vim: do not save +/* registers p.2 #11625 remove last place where system clipboard was used by netrw (extends 6c22c7ab97cca9f8dda6863ee7f1db1ce30a3451) fix #11592 --- runtime/autoload/netrw.vim | 8 -------- 1 file changed, 8 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 9b1266c4ca..fa86223d53 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1648,10 +1648,6 @@ fun! s:NetrwOptionsSave(vt) if g:netrw_keepdir let {a:vt}netrw_dirkeep = getcwd() endif - if has("clipboard") - sil! let {a:vt}netrw_starkeep = @* - sil! let {a:vt}netrw_pluskeep = @+ - endif sil! let {a:vt}netrw_slashkeep= @/ " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("")) @@ -1800,10 +1796,6 @@ fun! s:NetrwOptionsRestore(vt) unlet {a:vt}netrw_dirkeep endif endif - if has("clipboard") - call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*") - call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+") - endif call s:NetrwRestoreSetting(a:vt."netrw_slashkeep","@/") " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("")) -- cgit From 67d7906652e8511f28882fb64b5b3317da93e29a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 2 Jan 2020 03:41:36 -0500 Subject: clipboard: close stdout when copying via xclip #11617 test_registers.vim can fail even if a clipboard manager is running. If a clipboard manager is not running, this test always fails with xclip. Use xsel as a workaround. https://github.com/astrand/xclip/issues/20 suggests closing stdout when sending input via stdin. Environment - Ubuntu Xenial - Vim 7.4 (any app with broken clipboard code will do) - Neovim nightly Steps to reproduce: 0. Start the clipboard manager. 1. Open a file in Vim on Linux. Vim should have +clipboard enabled. 'set clipboard=' 2. Yank some text to the clipboard register. 3. Quit Vim. 4. Run 'cd /path/to/neovim/repo/' 5. Run 'make oldtest'. Do not run any individual tests. They likely pass with or without this fix. Before fix: test_registers.vim can fail. After fix: test_registers.vim always passes. Close https://github.com/neovim/neovim/issues/7958 https://wiki.ubuntu.com/ClipboardPersistence#The_state_of_things --- runtime/autoload/provider/clipboard.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index e33dc31f6d..e54d6ad95c 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -172,6 +172,11 @@ function! s:clipboard.set(lines, regtype, reg) abort if jobid > 0 call jobsend(jobid, a:lines) call jobclose(jobid, 'stdin') + " xclip does not close stdout,stderr when receiving input via stdin + if argv[0] ==# 'xclip' + call jobclose(jobid, 'stdout') + call jobclose(jobid, 'stderr') + endif let selection.owner = jobid let ret = 1 else -- cgit From 6e3793bf116f46930b9fcc4eb248f4589029d5ce Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 2 Jan 2020 17:37:39 +0100 Subject: clipboard: do not close stderr together with stdout (fixup #11617) stderr is needed to get error messages in case of failure, and job handler expects it to be open. --- runtime/autoload/provider/clipboard.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index e54d6ad95c..c86f7d0c2f 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -172,10 +172,9 @@ function! s:clipboard.set(lines, regtype, reg) abort if jobid > 0 call jobsend(jobid, a:lines) call jobclose(jobid, 'stdin') - " xclip does not close stdout,stderr when receiving input via stdin + " xclip does not close stdout when receiving input via stdin if argv[0] ==# 'xclip' call jobclose(jobid, 'stdout') - call jobclose(jobid, 'stderr') endif let selection.owner = jobid let ret = 1 -- cgit From 4a7d84ae603f75f974ab9a9d2f4d1b4a06da79bf Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 7 Jan 2020 05:57:36 +0000 Subject: man.vim: workaround for 'cscopetag' #11679 The old `:Man` implementation would take either the word under the cursor, or the argument passed in, and load that as a man page. Since we now use 'tagfunc' and look for all relevant man-pages, if your system has several (i.e. same name, different sections), we return several, giving the user an option. This works for most tag commands except `:tjump`, which will fail if there's multiple tags to choose from. This just happens to be what the cscope code uses (it actually attempts to prompt the user, but this fails). --- runtime/autoload/man.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index e4c0080ae9..5feab0ce70 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -398,6 +398,11 @@ function! man#goto_tag(pattern, flags, info) abort " sort by relevance - exact matches first, then the previous order call sort(l:structured, { a, b -> a.name ==? l:name ? -1 : b.name ==? l:name ? 1 : 0 }) + if &cscopetag + " return only a single entry so we work well with :cstag (#11675) + let l:structured = l:structured[:0] + endif + return map(l:structured, { \ _, entry -> { \ 'name': entry.name, -- cgit From c25b5a1576eca912671d5f2fe47043055fbca2b0 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Mon, 4 Nov 2019 17:33:07 +0000 Subject: remote plugins: add support for perl hosts --- runtime/autoload/provider/perl.vim | 73 ++++++++++++++++++++++++++++++++++++++ runtime/autoload/remote/host.vim | 4 +++ 2 files changed, 77 insertions(+) create mode 100644 runtime/autoload/provider/perl.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/perl.vim b/runtime/autoload/provider/perl.vim new file mode 100644 index 0000000000..4546a85100 --- /dev/null +++ b/runtime/autoload/provider/perl.vim @@ -0,0 +1,73 @@ +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 = get(g:, 'perl_host_prog', executable('perl') ? 'perl' : '') + + " if perl is available, make sure the required module is available + if prog != '' + let job_id = jobstart(prog.' -MNeovim::Ext -e "exit 0"', {'stdout_buffered': v:true}) + let result = jobwait([job_id]) + if result[0] != 0 + let prog = '' + endif + endif + + return 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')) -- cgit From ef3e61013882ed92e0208b9d1ac3488494c7ac53 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 15 Jan 2020 21:12:36 -0500 Subject: provider/perl: simplify detection --- runtime/autoload/provider/perl.vim | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/perl.vim b/runtime/autoload/provider/perl.vim index 4546a85100..36ca2bbf14 100644 --- a/runtime/autoload/provider/perl.vim +++ b/runtime/autoload/provider/perl.vim @@ -6,18 +6,14 @@ 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 = get(g:, 'perl_host_prog', executable('perl') ? 'perl' : '') - - " if perl is available, make sure the required module is available - if prog != '' - let job_id = jobstart(prog.' -MNeovim::Ext -e "exit 0"', {'stdout_buffered': v:true}) - let result = jobwait([job_id]) - if result[0] != 0 - let prog = '' - endif + let prog = exepath(get(g:, 'perl_host_prog', 'perl')) + if empty(prog) + return '' endif - return prog + " 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 -- cgit From 2063af3c94834ed35155ae9cb3d7daa1564bb1a9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 15 Jan 2020 21:56:46 -0500 Subject: provider/perl: add health check --- runtime/autoload/health/provider.vim | 43 +++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index ad7a614ff5..29abf02760 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 @@ -623,10 +623,51 @@ 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 package.', + \ ['Run in shell: cpanm Neovim::Ext']) + return + endif + call health#report_info('Neovim perl host: '. host) + + let current_perl_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] + let current_perl = s:system(current_perl_cmd) + if s:shell_error + call health#report_error('Failed to run: '. string(current_perl_cmd), + \ ['Report this issue with the output of: ', string(current_perl_cmd)]) + return + endif + + call health#report_ok('"Neovim::Ext" cpan package is installed: '. current_perl) +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 -- cgit From 670a14a2a6a2c9abc97227f0a34712fa8e2e6465 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 18 Jan 2020 13:45:04 -0500 Subject: provider/perl: add latest version health check --- runtime/autoload/health/provider.vim | 43 ++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 29abf02760..cc7d86d0c1 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -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) @@ -646,21 +644,38 @@ function! s:check_perl() abort let host = provider#perl#Detect() if empty(host) - call health#report_warn('Missing "Neovim::Ext" cpan package.', + 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 current_perl_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] - let current_perl = s:system(current_perl_cmd) + 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_perl_cmd), - \ ['Report this issue with the output of: ', string(current_perl_cmd)]) + call health#report_error('Failed to run: '. string(current_cpan_cmd), + \ ['Report this issue with the output of: ', string(current_cpan_cmd)]) return endif - call health#report_ok('"Neovim::Ext" cpan package is installed: '. current_perl) + 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 -- cgit From bf85cc09098fcbe1209d0951262ef78ef08b9ac2 Mon Sep 17 00:00:00 2001 From: David Lukes Date: Mon, 27 Jan 2020 09:38:44 +0100 Subject: checkhealth: better $VIRTUAL_ENV validation #11781 fix #11753 close #11781 The virtualenv troubleshooting in the Python provider health checks is supposed to help the user determine whether running Python from Neovim (as in `system('python')` or `system(exepath('python'))`) will use the correct executable when a virtualenv is active. Currently however, it issues spurious warnings in legitimate setups, and conversely, fails to warn about potentially problematic ones. See https://github.com/neovim/neovim/issues/11753#issuecomment-578715584 for a more detailed analysis, but at a high level, this is due to two things: - the virtualenv check is part of the Python provider check defined in `s:check_python`, which uses a roundabout and sometimes erroneous way of determining the Python executable - more generally, it shouldn't be part of the provider check at all, because it's not really related to the Python *provider*, i.e. the Python executable which can communicate with Neovim via `pynvim`, but to the Python the user is editing source files for, which typically shouldn't even have `pynvim` installed This patch reimplements the virtualenv check and factors it out into its own separate function, which is however still kept in `health/provider.vim` alongside the rest of the Python troubleshooting, since troubleshooting all Python-related stuff in one place is probably a good idea in order to alleviate any potential confusion (e.g. users who run only provider checks might be left wondering whether their virtualenv Python was properly detected if the report only shows their global Python as the provider used by Neovim). --- runtime/autoload/health/provider.vim | 81 ++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 12 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index cc7d86d0c1..f602684fb5 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -392,18 +392,6 @@ function! s:check_python(version) abort let python_exe = '' endif - " Check if $VIRTUAL_ENV is valid. - if exists('$VIRTUAL_ENV') && !empty(python_exe) - if $VIRTUAL_ENV ==# matchstr(python_exe, '^\V'.$VIRTUAL_ENV) - call health#report_info('$VIRTUAL_ENV matches executable') - else - call health#report_warn( - \ '$VIRTUAL_ENV exists but appears to be inactive. ' - \ . 'This could lead to unexpected results.', - \ [ 'If you are using Zsh, see: http://vi.stackexchange.com/a/7654' ]) - endif - endif - " Diagnostic output call health#report_info('Executable: ' . (empty(python_exe) ? 'Not found' : python_exe)) if len(python_multiple) @@ -497,6 +485,72 @@ function! s:check_for_pyenv() abort return [pyenv_path, pyenv_root] endfunction +" Locate Python executable by running invocation and checking +" sys.executable. +function! s:locate_pythonx(invocation) abort + return s:normalize_path(system(a:invocation + \ . ' -c "from __future__ import print_function; import sys; print(sys.executable, end=\"\")"')) +endfunction + +" If $VIRTUAL_ENV is set, check whether its Python executables will be +" the first on the $PATH of both Neovim and subshells spawned from +" Neovim. +function! s:check_active_virtualenv() abort + call health#report_start('Python active virtualenv') + let errors = [] + " hints are kept as Dictionary keys in order to discard duplicates + let hints = {} + " the virtualenv should contain some Python executables, and those + " executables should be first both on Neovim's path and on the path of + " subshells launched from Neovim + let venv_pythonxs = glob($VIRTUAL_ENV . '/bin/python*', v:true, v:true) + if len(venv_pythonxs) + for venv_pythonx in venv_pythonxs + let venv_pythonx = s:normalize_path(venv_pythonx) + let pythonx_basename = fnamemodify(venv_pythonx, ':t') + let neovim_pythonx = s:locate_pythonx(exepath(pythonx_basename)) + let subshell_pythonx = s:locate_pythonx(pythonx_basename) + if venv_pythonx !=# neovim_pythonx + call add(errors, 'according to Neovim''s $PATH, the ' . pythonx_basename + \ . ' executable is found outside the virtualenv, here: ' . neovim_pythonx) + let hint = 'Problems with Neovim''s $PATH are caused by the virtualenv not being ' + \ . 'properly activated prior to launching Neovim. Close Neovim, activate the virtualenv ' + \ . 'properly, check that invoking Python from the command line launches the correct one, ' + \ . 'and relaunch Neovim.' + let hints[hint] = v:true + endif + if venv_pythonx !=# subshell_pythonx + call add(errors, 'according to the $PATH of subshells launched from Neovim, the ' + \ . pythonx_basename . ' executable is found outside the virtualenv, here: ' + \ . subshell_pythonx) + let hint = 'Problems with the $PATH of subshells launched from Neovim can be ' + \ . 'caused by your shell''s startup files overriding the $PATH previously set by the ' + \ . 'virtualenv. Either prevent them from doing so, or use ' + \ . 'https://vi.stackexchange.com/a/7654/18339 as a workaround.' + let hints[hint] = v:true + endif + endfor + else + call add(errors, 'no Python executables were found in the virtualenv''s bin directory.') + endif + + if len(errors) + call health#report_warn('$VIRTUAL_ENV is set to: ' . $VIRTUAL_ENV) + if len(venv_pythonxs) + call health#report_warn('And its bin directory contains the following executables: ' + \ . join(map(venv_pythonxs, "fnamemodify(v:val, ':t')"), ', ')) + endif + let conj = 'However, ' + for error in errors + call health#report_warn(conj . error) + let conj = 'And ' + endfor + call health#report_warn('So invoking Python may lead to unexpected results.', keys(hints)) + else + call health#report_ok('$VIRTUAL_ENV is active and invoking Python from within Neovim will honor it.') + endif +endfunction + function! s:check_ruby() abort call health#report_start('Ruby provider (optional)') @@ -682,6 +736,9 @@ function! health#provider#check() abort call s:check_clipboard() call s:check_python(2) call s:check_python(3) + if exists('$VIRTUAL_ENV') + call s:check_active_virtualenv() + endif call s:check_ruby() call s:check_node() call s:check_perl() -- cgit From 1b20014972bb24d60bc16f07e5c4066421bc7e0a Mon Sep 17 00:00:00 2001 From: David Lukes Date: Wed, 29 Jan 2020 13:31:37 +0100 Subject: checkhealth: print -> sys.stdout.write Co-Authored-By: Peter Lithammer --- runtime/autoload/health/provider.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index f602684fb5..246bfb5322 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -489,7 +489,7 @@ endfunction " sys.executable. function! s:locate_pythonx(invocation) abort return s:normalize_path(system(a:invocation - \ . ' -c "from __future__ import print_function; import sys; print(sys.executable, end=\"\")"')) + \ . ' -c "import sys; sys.stdout.write(sys.executable)"')) endfunction " If $VIRTUAL_ENV is set, check whether its Python executables will be -- cgit From 370a33a85dae069d2f8cf40472fed2cf9cee3ea6 Mon Sep 17 00:00:00 2001 From: David Lukes Date: Fri, 31 Jan 2020 11:09:06 +0100 Subject: checkhealth: bin directory is Scripts/ on Windows --- runtime/autoload/health/provider.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 246bfb5322..abc301c4c3 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -503,7 +503,8 @@ function! s:check_active_virtualenv() abort " the virtualenv should contain some Python executables, and those " executables should be first both on Neovim's path and on the path of " subshells launched from Neovim - let venv_pythonxs = glob($VIRTUAL_ENV . '/bin/python*', v:true, v:true) + let bin_dir = has('win32') ? '/Scripts' : '/bin' + let venv_pythonxs = glob($VIRTUAL_ENV . bin_dir . '/python*', v:true, v:true) if len(venv_pythonxs) for venv_pythonx in venv_pythonxs let venv_pythonx = s:normalize_path(venv_pythonx) @@ -531,13 +532,14 @@ function! s:check_active_virtualenv() abort endif endfor else - call add(errors, 'no Python executables were found in the virtualenv''s bin directory.') + call add(errors, 'no Python executables were found in the virtualenv''s ' + \ . bin_dir . ' directory.') endif if len(errors) call health#report_warn('$VIRTUAL_ENV is set to: ' . $VIRTUAL_ENV) if len(venv_pythonxs) - call health#report_warn('And its bin directory contains the following executables: ' + call health#report_warn('And its ' . bin_dir . ' directory contains the following executables: ' \ . join(map(venv_pythonxs, "fnamemodify(v:val, ':t')"), ', ')) endif let conj = 'However, ' -- cgit From 3cd5a8d149e74255f89a8424b20622c9dc79daca Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Feb 2020 16:19:32 -0800 Subject: checkhealth: cleanup, brevity --- runtime/autoload/health/provider.vim | 124 +++++++++++++++++------------------ 1 file changed, 61 insertions(+), 63 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index abc301c4c3..1dd7f57f5f 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -163,7 +163,7 @@ function! s:check_clipboard() abort endif endfunction -" Get the latest Neovim Python client (pynvim) version from PyPI. +" Get the latest Nvim 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/pynvim/json') @@ -180,7 +180,7 @@ endfunction " Get version information using the specified interpreter. The interpreter is " used directly in case breaking changes were introduced since the last time -" Neovim's Python client was updated. +" Nvim's Python client was updated. " " Returns: [ " {python executable version}, @@ -224,7 +224,7 @@ function! s:version_info(python) abort \ '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 module version' let base = fnamemodify(nvim_path, ':h') let metas = glob(base.'-*/METADATA', 1, 1) \ + glob(base.'-*/PKG-INFO', 1, 1) @@ -363,7 +363,7 @@ function! s:check_python(version) abort \ && !empty(pyenv_root) && resolve(python_exe) !~# '^'.pyenv_root.'/' 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 ' + \ . 'for Nvim using pyenv, and set `g:%s`. This will avoid ' \ . 'the need to install the pynvim module in each ' \ . 'version/virtualenv.', host_prog_var) \ ]) @@ -377,7 +377,7 @@ function! s:check_python(version) abort if resolve(python_exe) !~# '^'.venv_root.'/' 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 ' + \ . 'for Nvim and use `g:%s`. This will avoid ' \ . 'the need to install the pynvim module in each ' \ . 'virtualenv.', host_prog_var) \ ]) @@ -485,71 +485,71 @@ function! s:check_for_pyenv() abort return [pyenv_path, pyenv_root] endfunction -" Locate Python executable by running invocation and checking -" sys.executable. -function! s:locate_pythonx(invocation) abort +" Resolves Python executable path by invoking and checking `sys.executable`. +function! s:python_exepath(invocation) abort return s:normalize_path(system(a:invocation \ . ' -c "import sys; sys.stdout.write(sys.executable)"')) endfunction -" If $VIRTUAL_ENV is set, check whether its Python executables will be -" the first on the $PATH of both Neovim and subshells spawned from -" Neovim. -function! s:check_active_virtualenv() abort - call health#report_start('Python active virtualenv') +" Checks that $VIRTUAL_ENV Python executables are found at front of $PATH in +" Nvim and subshells. +function! s:check_virtualenv() abort + call health#report_start('Python virtualenv') + if !exists('$VIRTUAL_ENV') + call health#report_ok('no $VIRTUAL_ENV') + return + endif let errors = [] - " hints are kept as Dictionary keys in order to discard duplicates + " Keep hints as dict keys in order to discard duplicates. let hints = {} - " the virtualenv should contain some Python executables, and those - " executables should be first both on Neovim's path and on the path of - " subshells launched from Neovim + " The virtualenv should contain some Python executables, and those + " executables should be first both on Nvim's $PATH and the $PATH of + " subshells launched from Nvim. let bin_dir = has('win32') ? '/Scripts' : '/bin' - let venv_pythonxs = glob($VIRTUAL_ENV . bin_dir . '/python*', v:true, v:true) - if len(venv_pythonxs) - for venv_pythonx in venv_pythonxs - let venv_pythonx = s:normalize_path(venv_pythonx) - let pythonx_basename = fnamemodify(venv_pythonx, ':t') - let neovim_pythonx = s:locate_pythonx(exepath(pythonx_basename)) - let subshell_pythonx = s:locate_pythonx(pythonx_basename) - if venv_pythonx !=# neovim_pythonx - call add(errors, 'according to Neovim''s $PATH, the ' . pythonx_basename - \ . ' executable is found outside the virtualenv, here: ' . neovim_pythonx) - let hint = 'Problems with Neovim''s $PATH are caused by the virtualenv not being ' - \ . 'properly activated prior to launching Neovim. Close Neovim, activate the virtualenv ' - \ . 'properly, check that invoking Python from the command line launches the correct one, ' - \ . 'and relaunch Neovim.' + let venv_bins = glob($VIRTUAL_ENV . bin_dir . '/python*', v:true, v:true) + if len(venv_bins) + for venv_bin in venv_bins + let venv_bin = s:normalize_path(venv_bin) + let py_bin_basename = fnamemodify(venv_bin, ':t') + let nvim_py_bin = s:python_exepath(exepath(py_bin_basename)) + let subshell_py_bin = s:python_exepath(py_bin_basename) + if venv_bin !=# nvim_py_bin + call add(errors, '$PATH yields this '.py_bin_basename.' executable: '.nvim_py_bin) + let hint = '$PATH ambiguities arise if the virtualenv is not ' + \.'properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, ' + \.'check that invoking Python from the command line launches the correct one, ' + \.'then relaunch Nvim.' let hints[hint] = v:true endif - if venv_pythonx !=# subshell_pythonx - call add(errors, 'according to the $PATH of subshells launched from Neovim, the ' - \ . pythonx_basename . ' executable is found outside the virtualenv, here: ' - \ . subshell_pythonx) - let hint = 'Problems with the $PATH of subshells launched from Neovim can be ' - \ . 'caused by your shell''s startup files overriding the $PATH previously set by the ' - \ . 'virtualenv. Either prevent them from doing so, or use ' - \ . 'https://vi.stackexchange.com/a/7654/18339 as a workaround.' + if venv_bin !=# subshell_py_bin + call add(errors, '$PATH in subshells yields this ' + \.py_bin_basename . ' executable: '.subshell_py_bin) + let hint = '$PATH ambiguities in subshells typically are ' + \.'caused by your shell config overriding the $PATH previously set by the ' + \.'virtualenv. Either prevent them from doing so, or use this workaround: ' + \.'https://vi.stackexchange.com/a/7654' let hints[hint] = v:true endif endfor else - call add(errors, 'no Python executables were found in the virtualenv''s ' - \ . bin_dir . ' directory.') + call add(errors, 'no Python executables found in the virtualenv '.bin_dir.' directory.') endif if len(errors) - call health#report_warn('$VIRTUAL_ENV is set to: ' . $VIRTUAL_ENV) - if len(venv_pythonxs) - call health#report_warn('And its ' . bin_dir . ' directory contains the following executables: ' - \ . join(map(venv_pythonxs, "fnamemodify(v:val, ':t')"), ', ')) + let msg = '$VIRTUAL_ENV is set to: '.$VIRTUAL_ENV + if len(venv_bins) + let msg .= "\nAnd its ".bin_dir.' directory contains: ' + \.join(map(venv_bins, "fnamemodify(v:val, ':t')"), ', ') endif - let conj = 'However, ' + let conj = "\nBut " for error in errors - call health#report_warn(conj . error) - let conj = 'And ' + let msg .= conj.error + let conj = "\nAnd " endfor - call health#report_warn('So invoking Python may lead to unexpected results.', keys(hints)) + let msg .= "\nSo invoking Python may lead to unexpected results." + call health#report_warn(msg, keys(hints)) else - call health#report_ok('$VIRTUAL_ENV is active and invoking Python from within Neovim will honor it.') + call health#report_ok('$VIRTUAL_ENV provides :python, :python3, et al.') endif endfunction @@ -623,7 +623,7 @@ function! s:check_node() abort 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 - call health#report_warn('Neovim node.js host does not support '.node_v) + call health#report_warn('Nvim node.js host does not support '.node_v) " Skip further checks, they are nonsense if nodejs is too old. return endif @@ -638,7 +638,7 @@ function! s:check_node() abort \ 'Run in shell (if you use yarn): yarn global add neovim']) return endif - call health#report_info('Neovim node.js host: '. host) + call health#report_info('Nvim node.js host: '. host) let manager = executable('npm') ? 'npm' : 'yarn' let latest_npm_cmd = has('win32') ? @@ -693,7 +693,7 @@ function! s:check_perl() abort 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) + call health#report_warn('Nvim perl host does not support '.perl_v) " Skip further checks, they are nonsense if perl is too old. return endif @@ -704,7 +704,7 @@ function! s:check_perl() abort \ ['Run in shell: cpanm Neovim::Ext']) return endif - call health#report_info('Neovim perl host: '. host) + call health#report_info('Nvim perl host: '. host) let latest_cpan_cmd = 'cpanm --info Neovim::Ext' let latest_cpan = s:system(latest_cpan_cmd) @@ -735,13 +735,11 @@ function! s:check_perl() abort endfunction function! health#provider#check() abort - call s:check_clipboard() - call s:check_python(2) - call s:check_python(3) - if exists('$VIRTUAL_ENV') - call s:check_active_virtualenv() - endif - call s:check_ruby() - call s:check_node() - call s:check_perl() + " call s:check_clipboard() + " call s:check_python(2) + " call s:check_python(3) + call s:check_virtualenv() + " call s:check_ruby() + " call s:check_node() + " call s:check_perl() endfunction -- cgit From c8abe931db4264e4805cdd9e6564df5d3057ccea Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Feb 2020 18:19:42 -0800 Subject: checkhealth: avoid irrelevant virtualenv executables --- runtime/autoload/health/provider.vim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 1dd7f57f5f..c0faf2e9e4 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -507,6 +507,8 @@ function! s:check_virtualenv() abort " subshells launched from Nvim. let bin_dir = has('win32') ? '/Scripts' : '/bin' let venv_bins = glob($VIRTUAL_ENV . bin_dir . '/python*', v:true, v:true) + " XXX: Remove irrelevant executables found in bin/. + let venv_bins = filter(venv_bins, 'v:val !~# "python-config"') if len(venv_bins) for venv_bin in venv_bins let venv_bin = s:normalize_path(venv_bin) -- cgit From 983086f42e5841b84d5b24623a51ffc8c725e78f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Feb 2020 18:33:47 -0800 Subject: checkhealth: fix accidental change [ci skip] --- runtime/autoload/health/provider.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index c0faf2e9e4..1d720b5876 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -737,11 +737,11 @@ function! s:check_perl() abort endfunction function! health#provider#check() abort - " call s:check_clipboard() - " call s:check_python(2) - " call s:check_python(3) + call s:check_clipboard() + call s:check_python(2) + call s:check_python(3) call s:check_virtualenv() - " call s:check_ruby() - " call s:check_node() - " call s:check_perl() + call s:check_ruby() + call s:check_node() + call s:check_perl() endfunction -- cgit From 1b200d99360c1a4737f1d36206f3385a77d7d93e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 14 Feb 2020 03:43:28 -0500 Subject: checkhealth: ignore cpamn "!" output #11869 cpanm outputs a warning that suggest to use 'sudo' or use local::lib. cpanm exits with 0 so nvim thinks that the command worked. cpanm output that starts with "!" is likely an error. Close #11858 --- runtime/autoload/health/provider.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 1d720b5876..601a8f83ef 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -708,9 +708,9 @@ function! s:check_perl() abort endif call health#report_info('Nvim perl host: '. host) - let latest_cpan_cmd = 'cpanm --info Neovim::Ext' + let latest_cpan_cmd = 'cpanm --info -q Neovim::Ext' let latest_cpan = s:system(latest_cpan_cmd) - if s:shell_error || empty(latest_cpan) + if s:shell_error || empty(latest_cpan) || latest_cpan[0] ==# '!' 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?']) -- cgit From a1d6c2f5c9e7834ec6eb087b72354a1257582f3d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 15 Feb 2020 19:02:52 -0500 Subject: checkhealth: allow 'sudo install' of 'Neovim::Ext' #11874 cpanm cannot look for Perl modules from root directories without sudo so it creates '~/perl5/' and look for Perl modules in there. Whether this directory existed before running cpanm or not, cpanm returns a warning to advice the user to setup local::lib in order to use modules in '~/perl5/' and exits with error code 0. Each line in the warning always starts with '!'. Display this warning to the user. Continue parsing the version number if the warning can be ignored because lines that are not prefixed with '!' are valid output. Fix #11858 --- runtime/autoload/health/provider.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 601a8f83ef..86f9f060ff 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -710,13 +710,27 @@ function! s:check_perl() abort let latest_cpan_cmd = 'cpanm --info -q Neovim::Ext' let latest_cpan = s:system(latest_cpan_cmd) - if s:shell_error || empty(latest_cpan) || latest_cpan[0] ==# '!' + 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 + elseif latest_cpan[0] ==# '!' + let cpanm_errs = split(latest_cpan, '!') + if cpanm_errs[0] =~# "Can't write to " + call health#report_warn(cpanm_errs[0], cpanm_errs[1:-2]) + " Last line is the package info + let latest_cpan = cpanm_errs[-1] + else + call health#report_error('Unknown warning from command: ' . latest_cpan_cmd, cpanm_errs) + return + endif endif let latest_cpan = matchstr(latest_cpan, '\(\.\?\d\)\+') + if empty(latest_cpan) + call health#report_error('Cannot parse version number from cpanm output: ' . latest_cpan) + return + endif let current_cpan_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] let current_cpan = s:system(current_cpan_cmd) -- cgit From 5e0c435ca1b711e80f78429431b4d400d789c618 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 20 Feb 2020 20:19:49 +0000 Subject: man.vim: Handle `man` errors when looking for man-paths Fallback to simply globbing the tag we're given. This matches the original behaviour of `man.vim`, prior to c6afad78d39aa. fixes #11794 closes #11918 --- runtime/autoload/man.vim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 5feab0ce70..122ae357bc 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -328,18 +328,24 @@ function! man#complete(arg_lead, cmd_line, cursor_pos) abort return s:complete(sect, sect, name) endfunction -function! s:get_paths(sect, name) abort +function! s:get_paths(sect, name, do_fallback) abort + " callers must try-catch this, as some `man` implementations don't support `s:find_arg` try let mandirs = join(split(s:system(['man', s:find_arg]), ':\|\n'), ',') + return globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) catch - call s:error(v:exception) - return + if !a:do_fallback + throw v:exception + endif + + " fallback to a single path, with the page we're trying to find + let [l:sect, l:name, l:path] = s:verify_exists(a:sect, a:name) + return [l:path] endtry - return globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) endfunction function! s:complete(sect, psect, name) abort - let pages = s:get_paths(a:sect, a:name) + let pages = s:get_paths(a:sect, a:name, v:false) " We remove duplicates in case the same manpage in different languages was found. return uniq(sort(map(pages, 's:format_candidate(v:val, a:psect)'), 'i')) endfunction @@ -387,7 +393,7 @@ endfunction function! man#goto_tag(pattern, flags, info) abort let [l:sect, l:name] = man#extract_sect_and_name_ref(a:pattern) - let l:paths = s:get_paths(l:sect, l:name) + let l:paths = s:get_paths(l:sect, l:name, v:true) let l:structured = [] for l:path in l:paths -- cgit From 1f56f9a4b32c7d7aebafea226c148e9ed8bbabdb Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Wed, 8 Apr 2020 10:57:32 -0500 Subject: netrw.vim: gx should ignore terminal buffers #12091 netrw thinks it's a remote file due the name of a terminal buffer (term://), but a terminal buffer isn't a file. Fixes https://github.com/neovim/neovim/issues/4612#issuecomment-600321171 --- runtime/autoload/netrw.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index fa86223d53..b69ad7187a 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -5460,6 +5460,11 @@ fun! netrw#CheckIfRemote(...) else let curfile= expand("%") endif + + " Ignore terminal buffers + if &buftype ==# 'terminal' + return 0 + endif " call Decho("curfile<".curfile.">") if curfile =~ '^\a\{3,}://' " call Dret("netrw#CheckIfRemote 1") -- cgit From e8269a3ab5f4505f27997b46b0eaf9464d186cf9 Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 15 Apr 2020 21:54:23 +0900 Subject: win,runtime: Fix problem when win32yank was a symbolic link in WSL [skip ci] (#12124) On some versions of Windows, WSL is unable to execute symbolic links to Windows executables (microsoft/WSL#3999). As a workaround for that problem this changes to use resolve() on WSL if win32yank was a symbolic link. fixes #12113. --- runtime/autoload/provider/clipboard.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index c86f7d0c2f..a96a0a61b7 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -113,8 +113,13 @@ function! provider#clipboard#Executable() abort let s:paste['*'] = s:paste['+'] return 'doitclient' elseif executable('win32yank.exe') - let s:copy['+'] = 'win32yank.exe -i --crlf' - let s:paste['+'] = 'win32yank.exe -o --lf' + if has('wsl') && getftype(exepath('win32yank.exe')) == 'link' + let win32yank = resolve(exepath('win32yank.exe')) + else + let win32yank = 'win32yank.exe' + endif + let s:copy['+'] = win32yank.' -i --crlf' + let s:paste['+'] = win32yank.' -o --lf' let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'win32yank' -- cgit From ebee77e73c2977e8b13e0b8c98ad65840bfa2eb3 Mon Sep 17 00:00:00 2001 From: Booome <604772159@qq.com> Date: Tue, 5 May 2020 10:58:45 +0800 Subject: checkhealth/ruby: fix off-by-one error #12245 Co-authored-by: BodongLiKolmostar --- runtime/autoload/health/provider.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 86f9f060ff..6d481e9f49 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -589,7 +589,7 @@ function! s:check_ruby() abort \ 'Are you behind a firewall or proxy?']) return endif - let latest_gem = get(split(latest_gem, 'neovim (\|, \|)$' ), 1, 'not found') + let latest_gem = get(split(latest_gem, 'neovim (\|, \|)$' ), 0, 'not found') let current_gem_cmd = host .' --version' let current_gem = s:system(current_gem_cmd) -- cgit From 7116105d661011cc4bdd5e01e1321d1e500b6b5b Mon Sep 17 00:00:00 2001 From: Faris A Chugthai <20028782+farisachugthai@users.noreply.github.com> Date: Wed, 20 May 2020 07:57:46 -0400 Subject: provider: Add python3.9 to autoload/provider/pythonx.vim (#12344) 3.9's scheduled for beta release today. https://www.python.org/dev/peps/pep-0596/ --- runtime/autoload/provider/pythonx.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 23e7ff8f64..ffb9bf3021 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -29,7 +29,7 @@ endfunction function! s:get_python_candidates(major_version) abort return { \ 2: ['python2', 'python2.7', 'python2.6', 'python'], - \ 3: ['python3', 'python3.8', 'python3.7', 'python3.6', 'python3.5', + \ 3: ['python3', 'python3.9', 'python3.8', 'python3.7', 'python3.6', 'python3.5', \ 'python3.4', 'python3.3', 'python'] \ }[a:major_version] endfunction -- cgit From 7d8dc4c331fee2527dfe499066035fa7470ad5b3 Mon Sep 17 00:00:00 2001 From: BusyBruce <4861164+BusyBruce@users.noreply.github.com> Date: Sat, 30 May 2020 20:29:24 +0800 Subject: provider: Fix ruby checkhealth error for Windows (#12400) Plaform: Windows 10 run `cmd /c gem list -ra ^^neovim$` *** REMOTE GEMS *** minitest-neovim (0.1.0) neovim (0.7.1, 0.7.0, 0.6.2, 0.6.1, 0.6.0, 0.5.1, 0.5.0, 0.4.0, 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.0, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1) run `cmd /c gem list -ra "^^neovim$"` *** REMOTE GEMS *** neovim (0.7.1, 0.7.0, 0.6.2, 0.6.1, 0.6.0, 0.5.1, 0.5.0, 0.4.0, 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.0, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1) --- runtime/autoload/health/provider.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 6d481e9f49..4975dc66b8 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -581,7 +581,7 @@ function! s:check_ruby() abort endif call health#report_info('Host: '. host) - let latest_gem_cmd = has('win32') ? 'cmd /c gem list -ra ^^neovim$' : 'gem list -ra ^neovim$' + let latest_gem_cmd = has('win32') ? 'cmd /c gem list -ra "^^neovim$"' : 'gem list -ra ^neovim$' let latest_gem = s:system(split(latest_gem_cmd)) if s:shell_error || empty(latest_gem) call health#report_error('Failed to run: '. latest_gem_cmd, -- cgit From 7124c0e5acde38957af7621afd1d92fb2b6d1d58 Mon Sep 17 00:00:00 2001 From: kuuote Date: Sun, 31 May 2020 20:21:58 +0900 Subject: runtime: fix remote plugin command fails at some case fixes #12410 --- runtime/autoload/remote/define.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/remote/define.vim b/runtime/autoload/remote/define.vim index 2688a62a82..2aec96e365 100644 --- a/runtime/autoload/remote/define.vim +++ b/runtime/autoload/remote/define.vim @@ -24,7 +24,7 @@ function! remote#define#CommandOnHost(host, method, sync, name, opts) endif if has_key(a:opts, 'nargs') - call add(forward_args, ' ') + call add(forward_args, ' " . . "') endif exe s:GetCommandPrefix(a:name, a:opts) -- cgit From d17e38e48209c19b63d809c5b807613f15aa03c8 Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 5 Feb 2020 16:04:45 +0900 Subject: Add overlapped option to jobstart When UV_OVERLAPPED_PIPE was used for the pipe passed to the child process, a problem occurred with the standard input of the .Net Framework application (#11809). Therefore, add the overlapped option to jobstart() and change it so that it is set only when necessary --- runtime/autoload/provider.vim | 5 ++++- runtime/autoload/provider/pythonx.vim | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider.vim b/runtime/autoload/provider.vim index dc24e801d0..803c1a0b1c 100644 --- a/runtime/autoload/provider.vim +++ b/runtime/autoload/provider.vim @@ -3,8 +3,11 @@ " Start the provider and perform a 'poll' request " " Returns a valid channel on success -function! provider#Poll(argv, orig_name, log_env) abort +function! provider#Poll(argv, orig_name, log_env, ...) abort let job = {'rpc': v:true, 'stderr_buffered': v:true} + if a:0 + let job = extend(job, a:1) + endif try let channel_id = jobstart(a:argv, job) if channel_id > 0 && rpcrequest(channel_id, 'poll') ==# 'ok' diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index ffb9bf3021..e89d519790 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -19,7 +19,7 @@ function! provider#pythonx#Require(host) abort call add(args, plugin.path) endfor - return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE') + return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE', {'overlapped': v:true}) endfunction function! s:get_python_executable_from_host_var(major_version) abort -- cgit From 4aaffc5f339c248c12d2b9d87880bb73c714f369 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 12 Jun 2020 23:22:59 -0400 Subject: man.vim: Refactor verify_exists to unset $MANSECT as needed Also cleaned it up a little and made it faster. Closes #9159 and #9271 Also changes man#extract_sect_and_name_ref to only return a single section at a time. This fixes a bug in its usage in man#goto_tag where get_paths would be called with multiple sections and it does not support that. I noticed that our tagfunc doesn't obey b:man_default_sects and I'll fix that next. --- runtime/autoload/man.vim | 69 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 15 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 122ae357bc..215df9484a 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -58,7 +58,8 @@ function! man#open_page(count, count1, mods, ...) abort " 1, also a valid section. If they are equal, count explicitly set. let sect = string(a:count) endif - let [sect, name, path] = s:verify_exists(sect, name) + let path = s:verify_exists(sect, name) + let [sect, name] = s:extract_sect_and_name_path(path) catch call s:error(v:exception) return @@ -83,7 +84,8 @@ endfunction function! man#read_page(ref) abort try let [sect, name] = man#extract_sect_and_name_ref(a:ref) - let [sect, name, path] = s:verify_exists(sect, name) + let path = s:verify_exists(sect, name) + let [sect, name] = s:extract_sect_and_name_path(path) let page = s:get_page(path) catch call s:error(v:exception) @@ -204,7 +206,7 @@ function! man#extract_sect_and_name_ref(ref) abort if empty(name) throw 'manpage reference cannot contain only parentheses' endif - return [get(b:, 'man_default_sects', ''), name] + return ['', name] endif let left = split(ref, '(') " see ':Man 3X curses' on why tolower. @@ -227,24 +229,62 @@ function! s:get_path(sect, name) abort return substitute(get(split(s:system(['man', s:find_arg, s:section_arg, a:sect, a:name])), 0, ''), '\n\+$', '', '') endfunction +" s:verify_exists attempts to find the path to a manpage +" based on the passed section and name. +" +" 1. If the passed section is empty, b:man_default_sects is used. +" 2. If manpage could not be found with the given sect and name, +" then another attempt is made with b:man_default_sects. +" 3. If it still could not be found, then we try again without a section. +" 4. If still not found but $MANSECT is set, then we try again with $MANSECT +" unset. +" +" This function is careful to avoid duplicating a search if a previous +" step has already done it. i.e if we use b:man_default_sects in step 1, +" then we don't do it again in step 2. function! s:verify_exists(sect, name) abort + let sect = a:sect + if empty(sect) + let sect = get(b:, 'man_default_sects', '') + endif + try - let path = s:get_path(a:sect, a:name) + return s:get_path(sect, a:name) catch /^command error (/ + endtry + + if !empty(get(b:, 'man_default_sects', '')) && sect !=# b:man_default_sects try - let path = s:get_path(get(b:, 'man_default_sects', ''), a:name) + return s:get_path(b:man_default_sects, a:name) catch /^command error (/ - let path = s:get_path('', a:name) endtry - endtry - " Extract the section from the path, because sometimes the actual section is - " more specific than what we provided to `man` (try `:Man 3 App::CLI`). - " Also on linux, name seems to be case-insensitive. So for `:Man PRIntf`, we - " still want the name of the buffer to be 'printf'. - return s:extract_sect_and_name_path(path) + [path] + endif + + if !empty(sect) + try + return s:get_path('', a:name) + catch /^command error (/ + endtry + endif + + if !empty($MANSECT) + try + let MANSECT = $MANSECT + unset $MANSECT + return s:get_path('', a:name) + catch /^command error (/ + finally + let $MANSECT = MANSECT + endtry + endif + + throw 'no manual entry for ' . a:name endfunction -" extracts the name and sect out of 'path/name.sect' +" Extracts the name/section from the 'path/name.sect', because sometimes the actual section is +" more specific than what we provided to `man` (try `:Man 3 App::CLI`). +" Also on linux, name seems to be case-insensitive. So for `:Man PRIntf`, we +" still want the name of the buffer to be 'printf'. function! s:extract_sect_and_name_path(path) abort let tail = fnamemodify(a:path, ':t') if a:path =~# '\.\%([glx]z\|bz2\|lzma\|Z\)$' " valid extensions @@ -339,8 +379,7 @@ function! s:get_paths(sect, name, do_fallback) abort endif " fallback to a single path, with the page we're trying to find - let [l:sect, l:name, l:path] = s:verify_exists(a:sect, a:name) - return [l:path] + return [s:verify_exists(a:sect, a:name)] endtry endfunction -- cgit From adc3425a3777c55080b7b5cdd37b02e858c5807c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 12 Jun 2020 23:43:53 -0400 Subject: man.vim: Fix tagfunc to respect b:man_default_sects Also, kudos to @zsugabubus for fixing a related issue in #12417 This also prevents any sorting of the paths from man. We need to respect the order we get from it otherwise you end up loading /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man/man1/ls.1 on MacOS instead of /usr/share/man/man1/ls.1 --- runtime/autoload/man.vim | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 215df9484a..930db3ceb7 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -52,7 +52,7 @@ function! man#open_page(count, count1, mods, ...) abort let ref = a:2.'('.a:1.')' endif try - let [sect, name] = man#extract_sect_and_name_ref(ref) + let [sect, name] = s:extract_sect_and_name_ref(ref) if a:count ==# a:count1 " v:count defaults to 0 which is a valid section, and v:count1 defaults to " 1, also a valid section. If they are equal, count explicitly set. @@ -83,7 +83,7 @@ endfunction function! man#read_page(ref) abort try - let [sect, name] = man#extract_sect_and_name_ref(a:ref) + let [sect, name] = s:extract_sect_and_name_ref(a:ref) let path = s:verify_exists(sect, name) let [sect, name] = s:extract_sect_and_name_path(path) let page = s:get_page(path) @@ -196,7 +196,7 @@ endfunction " attempt to extract the name and sect out of 'name(sect)' " otherwise just return the largest string of valid characters in ref -function! man#extract_sect_and_name_ref(ref) abort +function! s:extract_sect_and_name_ref(ref) abort if a:ref[0] ==# '-' " try ':Man -pandoc' with this disabled. throw 'manpage name cannot start with ''-''' endif @@ -315,7 +315,7 @@ function! s:error(msg) abort echohl None endfunction -" see man#extract_sect_and_name_ref on why tolower(sect) +" see s:extract_sect_and_name_ref on why tolower(sect) function! man#complete(arg_lead, cmd_line, cursor_pos) abort let args = split(a:cmd_line) let cmd_offset = index(args, 'Man') @@ -372,14 +372,26 @@ function! s:get_paths(sect, name, do_fallback) abort " callers must try-catch this, as some `man` implementations don't support `s:find_arg` try let mandirs = join(split(s:system(['man', s:find_arg]), ':\|\n'), ',') - return globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) + let paths = globpath(mandirs, 'man?/'.a:name.'*.'.a:sect.'*', 0, 1) + try + " Prioritize the result from verify_exists as it obeys b:man_default_sects. + let first = s:verify_exists(a:sect, a:name) + let paths = filter(paths, 'v:val !=# first') + let paths = [first] + paths + catch + endtry + return paths catch if !a:do_fallback throw v:exception endif - " fallback to a single path, with the page we're trying to find - return [s:verify_exists(a:sect, a:name)] + " Fallback to a single path, with the page we're trying to find. + try + return [s:verify_exists(a:sect, a:name)] + catch + return [] + endtry endtry endfunction @@ -418,7 +430,7 @@ function! man#init_pager() abort " know the correct casing, cf. `man glDrawArraysInstanced`). let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') try - let b:man_sect = man#extract_sect_and_name_ref(ref)[0] + let b:man_sect = s:extract_sect_and_name_ref(ref)[0] catch let b:man_sect = '' endtry @@ -430,7 +442,7 @@ function! man#init_pager() abort endfunction function! man#goto_tag(pattern, flags, info) abort - let [l:sect, l:name] = man#extract_sect_and_name_ref(a:pattern) + let [l:sect, l:name] = s:extract_sect_and_name_ref(a:pattern) let l:paths = s:get_paths(l:sect, l:name, v:true) let l:structured = [] @@ -440,9 +452,6 @@ function! man#goto_tag(pattern, flags, info) abort let l:structured += [{ 'name': l:n, 'path': l:path }] endfor - " sort by relevance - exact matches first, then the previous order - call sort(l:structured, { a, b -> a.name ==? l:name ? -1 : b.name ==? l:name ? 1 : 0 }) - if &cscopetag " return only a single entry so we work well with :cstag (#11675) let l:structured = l:structured[:0] -- cgit From 22828f59bbbee29f1a8b645a62ecfe2edb71c1ef Mon Sep 17 00:00:00 2001 From: BK1603 Date: Thu, 25 Jun 2020 03:54:17 +0530 Subject: Added healt check for tmux focus events --- runtime/autoload/health/nvim.vim | 60 ++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index c25f5ee64f..f18801ea69 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -129,6 +129,25 @@ function! s:check_performance() abort endif endfunction +function! s:get_tmux_option(option) abort + let cmd = 'tmux show-option -qvg '.a:option " try global scope + let out = system(cmd) + let val = substitute(out, '\v(\s|\r|\n)', '', 'g') + if v:shell_error + call health#report_error('command failed: '.cmd."\n".out) + return 'error' + elseif empty(val) + let cmd = 'tmux show-option -qvgs '.a:option " try session scope + let out = system(cmd) + let val = substitute(out, '\v(\s|\r|\n)', '', 'g') + if v:shell_error + call health#report_error('command failed: '.cmd."\n".out) + return 'error' + endif + endif + return val +endfunction + function! s:check_tmux() abort if empty($TMUX) || !executable('tmux') return @@ -136,20 +155,31 @@ function! s:check_tmux() abort call health#report_start('tmux') " check escape-time - let suggestions = ["Set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10", + let suggestions = ["set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10", \ s:suggest_faq] - let cmd = 'tmux show-option -qvgs escape-time' - let out = system(cmd) - let tmux_esc_time = substitute(out, '\v(\s|\r|\n)', '', 'g') - if v:shell_error - call health#report_error('command failed: '.cmd."\n".out) - elseif empty(tmux_esc_time) - call health#report_error('escape-time is not set', suggestions) - elseif tmux_esc_time > 300 - call health#report_error( - \ 'escape-time ('.tmux_esc_time.') is higher than 300ms', suggestions) - else - call health#report_ok('escape-time: '.tmux_esc_time.'ms') + let tmux_esc_time = s:get_tmux_option('escape-time') + if tmux_esc_time !=# 'error' + if empty(tmux_esc_time) + call health#report_error('`escape-time` is not set', suggestions) + elseif tmux_esc_time > 300 + call health#report_error( + \ '`escape-time` ('.tmux_esc_time.') is higher than 300ms', suggestions) + else + call health#report_ok('escape-time: '.tmux_esc_time) + endif + endif + + " check focus-events + let suggestions = ["(tmux 1.9+ only) Set `focus-events` in ~/.tmux.conf:\nset-option -g focus-events on"] + let tmux_focus_events = s:get_tmux_option('focus-events') + call health#report_info('Checking stuff') + if tmux_focus_events !=# 'error' + if empty(tmux_focus_events) || tmux_focus_events !=# 'on' + call health#report_warn( + \ "`focus-events` is not enabled. |'autoread'| may not work.", suggestions) + else + call health#report_ok('focus-events: '.tmux_focus_events) + endif endif " check default-terminal and $TERM @@ -203,9 +233,9 @@ function! s:check_terminal() abort call health#report_error('command failed: '.cmd."\n".out) else call health#report_info('key_backspace (kbs) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kbs_entry)) + \ .(empty(kbs_entry) ? '? (not found)' : kbs_entry)) call health#report_info('key_dc (kdch1) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) + \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) endif for env_var in ['XTERM_VERSION', 'VTE_VERSION', 'TERM_PROGRAM', 'COLORTERM', 'SSH_TTY'] if exists('$'.env_var) -- cgit From 33837745bb581384a9a64db2f2d30b12c345bd42 Mon Sep 17 00:00:00 2001 From: David Lukes Date: Sun, 19 Jul 2020 22:37:50 +0200 Subject: Fix / improve report messages (#12396) --- runtime/autoload/health/provider.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 4975dc66b8..0482cb7f3c 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -537,8 +537,8 @@ function! s:check_virtualenv() abort call add(errors, 'no Python executables found in the virtualenv '.bin_dir.' directory.') endif + let msg = '$VIRTUAL_ENV is set to: '.$VIRTUAL_ENV if len(errors) - let msg = '$VIRTUAL_ENV is set to: '.$VIRTUAL_ENV if len(venv_bins) let msg .= "\nAnd its ".bin_dir.' directory contains: ' \.join(map(venv_bins, "fnamemodify(v:val, ':t')"), ', ') @@ -551,7 +551,10 @@ function! s:check_virtualenv() abort let msg .= "\nSo invoking Python may lead to unexpected results." call health#report_warn(msg, keys(hints)) else - call health#report_ok('$VIRTUAL_ENV provides :python, :python3, et al.') + call health#report_info(msg) + call health#report_info('Python version: ' + \.system('python -c "import platform, sys; sys.stdout.write(platform.python_version())"')) + call health#report_ok('$VIRTUAL_ENV provides :!python.') endif endfunction -- cgit From a6917f840d8609ca5dd0d52977b0e9c5d2a07a68 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 21 Jul 2020 11:46:42 -0400 Subject: man.vim: Simplify man#init to reduce load time (#12482) I removed the SunOS stuff since no one uses SunOS and I've never tested it on there. I removed the section_flag init as we can just use -S instead of -s and -S is used by every implementation as far as I know. This brings man#init's time from 50-70ms to 15-20ms for me. Closes #12318 Related #6766 Related #6815 --- runtime/autoload/man.vim | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 930db3ceb7..dab88fde23 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -7,22 +7,10 @@ let s:loaded_man = 1 let s:find_arg = '-w' let s:localfile_arg = v:true " Always use -l if possible. #6683 -let s:section_arg = '-s' +let s:section_arg = '-S' -function! s:init_section_flag() - call system(['env', 'MANPAGER=cat', 'man', s:section_arg, '1', 'man']) - if v:shell_error - let s:section_arg = '-S' - endif -endfunction - -function! s:init() abort - call s:init_section_flag() - " TODO(nhooyr): Does `man -l` on SunOS list searched directories? +function! man#init() abort try - if !has('win32') && $OSTYPE !~? 'cygwin\|linux' && system('uname -s') =~? 'SunOS' && system('uname -r') =~# '^5' - let s:find_arg = '-l' - endif " Check for -l support. call s:get_page(s:get_path('', 'man')) catch /E145:/ @@ -141,7 +129,7 @@ function! s:get_page(path) abort " Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065). " Soft-wrap: ftplugin/man.vim sets wrap/breakindent/…. " Hard-wrap: driven by `man`. - let manwidth = !get(g:,'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) + let manwidth = !get(g:, 'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. @@ -466,4 +454,4 @@ function! man#goto_tag(pattern, flags, info) abort \ }) endfunction -call s:init() +call man#init() -- cgit