mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
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'
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user