aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-09-10 10:11:45 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-09-12 13:25:29 -0300
commita1ce3a3acc9f5e617e9d7e9542d58953d2e9546f (patch)
tree75868da04d3253dac4e759f0cf0a480d63d25516 /src/nvim/api/vim.c
parent50609029301d0baac36d7500c2d80da9efb41861 (diff)
downloadrneovim-a1ce3a3acc9f5e617e9d7e9542d58953d2e9546f.tar.gz
rneovim-a1ce3a3acc9f5e617e9d7e9542d58953d2e9546f.tar.bz2
rneovim-a1ce3a3acc9f5e617e9d7e9542d58953d2e9546f.zip
provider: Major refactor
- Providers for features are now registered as a unit. For example, instead of calling `register_provider("clipboard_get")` and `register_provider("clipboard_set")`, clients call `register_provider("clipboard")` and nvim will assume it implements all methods of the "clipboard" feature - Bootstrapping code was removed. With the `api_spawn` function exposed to vimscript, it's no longer necessary and will be handled by plugins distributed with nvim. - Now the `has` function will return true if there's a live channel that has registered as a provider for the feature. - 'initpython'/'initclipboard' options were removed - A new API function was exposed: `vim_discover_features` which returns an object with information about pluggable features such as 'python' or 'clipboard'
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index b1d5a067b4..e14c427dc1 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -502,22 +502,28 @@ 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.
+/// Registers the channel as the provider for `feature`. This fails if
+/// a provider for `feature` is already provided by another channel.
///
/// @param channel_id The channel id
-/// @param method The method name
+/// @param feature The feature name
/// @param[out] err Details of an error that may have occurred
-void vim_register_provider(uint64_t channel_id, String method, Error *err)
+void vim_register_provider(uint64_t channel_id, String feature, Error *err)
{
char buf[METHOD_MAXLEN];
- xstrlcpy(buf, method.data, sizeof(buf));
+ xstrlcpy(buf, feature.data, sizeof(buf));
if (!provider_register(buf, channel_id)) {
- set_api_error("Provider already registered", err);
+ set_api_error("Feature doesn't exist", err);
}
}
+/// Returns a feature->method list dictionary for all pluggable features
+Dictionary vim_discover_features(void)
+{
+ return provider_get_all();
+}
+
/// 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.