diff options
-rw-r--r-- | runtime/autoload/health/provider.vim | 70 | ||||
-rw-r--r-- | src/nvim/main.c | 5 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 2 | ||||
-rw-r--r-- | src/nvim/ui_bridge.c (renamed from src/nvim/tui/ui_bridge.c) | 7 | ||||
-rw-r--r-- | src/nvim/ui_bridge.h (renamed from src/nvim/tui/ui_bridge.h) | 11 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 2 |
6 files changed, 42 insertions, 55 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index b1cfa8bf2b..d4b2f07a17 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -1,13 +1,5 @@ -let s:bad_responses = [ - \ 'unable to parse python response', - \ 'unable to parse', - \ 'unable to get pypi response', - \ 'unable to get neovim executable', - \ 'unable to find neovim version' - \ ] - function! s:is_bad_response(s) abort - return index(s:bad_responses, a:s) >= 0 + return a:s =~? '\v(^unable)|(^error)' endfunction function! s:trim(s) abort @@ -32,44 +24,41 @@ endfunction " Fetch the contents of a URL. function! s:download(url) abort - let content = '' if executable('curl') - let content = system(['curl', '-sL', "'", a:url, "'"]) - endif - - if empty(content) && executable('python') + let rv = system(['curl', '-sL', a:url]) + return v:shell_error ? 'curl error: '.v:shell_error : rv + elseif executable('python') let script = " \try:\n \ from urllib.request import urlopen\n \except ImportError:\n \ from urllib2 import urlopen\n \\n - \try:\n - \ response = urlopen('".a:url."')\n - \ print(response.read().decode('utf8'))\n - \except Exception:\n - \ pass\n + \response = urlopen('".a:url."')\n + \print(response.read().decode('utf8'))\n \" - let content = system(['python', '-c', "'", script, "'", '2>/dev/null']) + let rv = system(['python', '-c', script]) + return empty(rv) && v:shell_error + \ ? 'python urllib.request error: '.v:shell_error + \ : rv endif - - return content + return 'missing `curl` and `python`, cannot make pypi request' endfunction -" Get the latest Neovim Python client version from PyPI. Result is cached. +" Get the latest Neovim Python client version from PyPI. function! s:latest_pypi_version() abort - if exists('s:pypi_version') - return s:pypi_version - endif - - let s:pypi_version = 'unable to get pypi response' - let pypi_info = s:download('https://pypi.python.org/pypi/neovim/json') - if !empty(pypi_info) - let pypi_data = json_decode(pypi_info) - let s:pypi_version = get(get(pypi_data, 'info', {}), 'version', 'unable to parse') - return s:pypi_version + let pypi_version = 'unable to get pypi response' + let pypi_response = s:download('https://pypi.python.org/pypi/neovim/json') + if !empty(pypi_response) + try + let pypi_data = json_decode(pypi_response) + catch /E474/ + return 'error: '.pypi_response + endtry + let pypi_version = get(get(pypi_data, 'info', {}), 'version', 'unable to parse') endif + return pypi_version endfunction " Get version information using the specified interpreter. The interpreter is @@ -97,11 +86,11 @@ function! s:version_info(python) abort let nvim_path = s:trim(system([ \ a:python, \ '-c', - \ 'import neovim; print(neovim.__file__)', - \ '2>/dev/null'])) + \ 'import neovim; print(neovim.__file__)'])) + let nvim_path = v:shell_error ? '' : nvim_path if empty(nvim_path) - return [python_version, 'unable to find neovim executable', pypi_version, 'unable to get neovim executable'] + return [python_version, 'unable to find nvim executable', pypi_version, 'unable to get nvim executable'] endif " Assuming that multiple versions of a package are installed, sort them @@ -112,7 +101,7 @@ function! s:version_info(python) abort return a == b ? 0 : a > b ? 1 : -1 endfunction - let nvim_version = 'unable to find neovim version' + let nvim_version = 'unable to find nvim version' let base = fnamemodify(nvim_path, ':h') let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1) let metas = sort(metas, 's:compare') @@ -334,12 +323,13 @@ function! s:check_python(version) abort endif if s:is_bad_response(latest) - call health#report_warn('Unable to fetch latest Neovim Python client version.') + call health#report_warn('Unable to contact PyPI.') + call health#report_error('HTTP request failed: '.latest) endif if s:is_bad_response(status) - call health#report_warn('Latest Neovim Python client versions: ('.latest.')') - else + call health#report_warn('Latest Neovim Python client version: ('.latest.')') + elseif !s:is_bad_response(latest) call health#report_ok('Latest Neovim Python client is installed: ('.status.')') endif endif diff --git a/src/nvim/main.c b/src/nvim/main.c index 793babd4e5..eb67483d08 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -270,11 +270,6 @@ int main(int argc, char **argv) setbuf(stdout, NULL); - /* This message comes before term inits, but after setting "silent_mode" - * when the input is not a tty. */ - if (GARGCOUNT > 1 && !silent_mode) - printf(_("%d files to edit\n"), GARGCOUNT); - full_screen = true; check_tty(¶ms); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index f03d8b87fa..f252b00be2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -22,10 +22,10 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/strings.h" +#include "nvim/ui_bridge.h" #include "nvim/ugrid.h" #include "nvim/tui/input.h" #include "nvim/tui/tui.h" -#include "nvim/tui/ui_bridge.h" // Space reserved in the output buffer to restore the cursor to normal when // flushing. No existing terminal will require 32 bytes to do that. diff --git a/src/nvim/tui/ui_bridge.c b/src/nvim/ui_bridge.c index 48f4b1bda6..cc27c734e0 100644 --- a/src/nvim/tui/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -1,4 +1,5 @@ -// UI wrapper for the built-in TUI. Sends UI requests to the TUI thread. +// UI wrapper that sends UI requests to the UI thread. +// Used by the built-in TUI and external libnvim-based UIs. #include <assert.h> #include <stdbool.h> @@ -9,11 +10,11 @@ #include "nvim/vim.h" #include "nvim/ui.h" #include "nvim/memory.h" +#include "nvim/ui_bridge.h" #include "nvim/ugrid.h" -#include "nvim/tui/ui_bridge.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "tui/ui_bridge.c.generated.h" +# include "ui_bridge.c.generated.h" #endif #define UI(b) (((UIBridgeData *)b)->ui) diff --git a/src/nvim/tui/ui_bridge.h b/src/nvim/ui_bridge.h index 003ed3c2c1..9e4bf9f2a7 100644 --- a/src/nvim/tui/ui_bridge.h +++ b/src/nvim/ui_bridge.h @@ -1,6 +1,7 @@ -// Bridge used for communication between a builtin UI thread and nvim core -#ifndef NVIM_TUI_UI_BRIDGE_H -#define NVIM_TUI_UI_BRIDGE_H +// Bridge for communication between a UI thread and nvim core. +// Used by the built-in TUI and external libnvim-based UIs. +#ifndef NVIM_UI_BRIDGE_H +#define NVIM_UI_BRIDGE_H #include <uv.h> @@ -39,6 +40,6 @@ struct ui_bridge_data { #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "tui/ui_bridge.h.generated.h" +# include "ui_bridge.h.generated.h" #endif -#endif // NVIM_TUI_UI_BRIDGE_H +#endif // NVIM_UI_BRIDGE_H diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 27f00e8550..60f989d701 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -313,7 +313,7 @@ describe("tui 't_Co' (terminal colors)", function() -- This is ugly because :term/termopen() forces TERM=xterm-256color. -- TODO: Revisit this after jobstart/termopen accept `env` dict. screen = thelpers.screen_setup(0, string.format( - [=[['sh', '-c', 'TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=], + [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=], term, (colorterm ~= nil and "COLORTERM="..colorterm or ""), helpers.nvim_prog)) |