aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9834633813..6c793cbc54 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -10,6 +10,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/buffer.h"
#include "nvim/os/channel.h"
+#include "nvim/os/provider.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/window.h"
@@ -503,6 +504,22 @@ void vim_unsubscribe(uint64_t channel_id, String event)
channel_unsubscribe(channel_id, e);
}
+/// Registers the channel as the provider for `method`. This fails if
+/// a provider for `method` is already registered.
+///
+/// @param channel_id The channel id
+/// @param method The method name
+/// @param[out] err Details of an error that may have occurred
+void vim_register_provider(uint64_t channel_id, String method, Error *err)
+{
+ char buf[METHOD_MAXLEN];
+ xstrlcpy(buf, method.data, sizeof(buf));
+
+ if (!provider_register(buf, channel_id)) {
+ set_api_error("Provider already registered", err);
+ }
+}
+
/// Writes a message to vim output or error buffer. The string is split
/// and flushed after each newline. Incomplete lines are kept for writing
/// later.