diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-15 13:49:28 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-15 14:01:23 +0200 |
| commit | dca8f65a63c32644199fc95d5d8a4cb8f6b8dceb (patch) | |
| tree | 23d49d3a21fc231586bb6a6f3e14a1d74e4d9453 /py/utils.py | |
| parent | 4bb95955c5ee1e4d5f7aaeec549b4b865d356773 (diff) | |
| download | vim-ai-dca8f65a63c32644199fc95d5d8a4cb8f6b8dceb.tar.gz | |
using messages to show error/warning
Diffstat (limited to '')
| -rw-r--r-- | py/utils.py | 11 |
1 files changed, 9 insertions, 2 deletions
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 \<Esc>") + 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 |