From dca8f65a63c32644199fc95d5d8a4cb8f6b8dceb Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Sat, 15 Apr 2023 13:49:28 +0200 Subject: using messages to show error/warning --- py/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'py') diff --git a/py/utils.py b/py/utils.py index 2e0fc2d..79ff378 100644 --- a/py/utils.py +++ b/py/utils.py @@ -126,11 +126,18 @@ def openai_request(url, data, options): openai_obj = json.loads(line_data) yield openai_obj +def print_info_message(msg): + vim.command("redraw") + vim.command(f"normal \") + vim.command("echohl ErrorMsg") + vim.command(f"echomsg '{msg}'") + vim.command("echohl None") + def handle_completion_error(error): if isinstance(error, KeyboardInterrupt): - vim.command("normal! a Ctrl-C...") + print_info_message("Completion cancelled...") if isinstance(error, URLError): if isinstance(error.reason, socket.timeout): - vim.command("normal! aRequest timeout...") + print_info_message("Request timeout...") else: raise error -- cgit v1.2.3