From 8b42249cddf6b257e2eee808a41f3d6dd5af6846 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 1 Dec 2018 16:44:36 +0100 Subject: RPC: turn errors from async calls into notifications Previously, nvim sent a response with invalid request id (UINT64_MAX). In functionaltests, catch unexpected error notifications in after_each(). --- runtime/doc/api.txt | 17 +++++++++++++++-- runtime/doc/develop.txt | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 66fb5bda82..0219488088 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -79,6 +79,19 @@ As Nvim evolves the API may change in compliance with this CONTRACT: - Existing items will not be removed (after release). - Deprecated functions will not be removed until Nvim version 2.0 +============================================================================== +Global events *api-global-events* + +When a client invokes an API request as an async notification, it is not +possible for Nvim to send an error response. Instead, in case of error, the +following notification will be sent to the client: + + *nvim_error_event* +nvim_error_event[{type}, {message}] + +{type} is a numeric id as defined by `api_info().error_types`, and {message} is +a string with the error message. + ============================================================================== Buffer update events *api-buffer-updates* @@ -206,7 +219,7 @@ Example using the Nvim python-client: buf.clear_highlight(src) < If the highlights don't need to be deleted or updated, just pass -1 as -src_id (this is the default in python). Use |nvim_buf_clear_highlight()| to +src_id (this is the default in python). Use |nvim_buf_clear_namespace()| to clear highlights from a specific source, in a specific line range or the entire buffer by passing in the line range 0, -1 (the latter is the default in python as used above). @@ -218,7 +231,7 @@ An example of calling the api from vimscript: > call nvim_buf_add_highlight(0, src, "Identifier", 0, 5, -1) " later - call nvim_buf_clear_highlight(0, src, 0, -1) + call nvim_buf_clear_namespace(0, src, 0, -1) > ============================================================================== Global Functions *api-global* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index bcf43142ad..2c919f9104 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -181,6 +181,8 @@ Standard Features ~ - Clients should call |nvim_set_client_info()| after connecting, so users and plugins can detect the client by handling the |ChanInfo| event. This avoids the need for special variables or other client hints. +- Clients should handle |nvim_error_event| notifications, which will be sent + if an async request to nvim was rejected or caused an error. Package Naming ~ -- cgit