mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
api: list information about all channels/jobs.
Fire autocmd when channel opens or its info changes. Add a way for API clients can describe themselves.
This commit is contained in:
@@ -61,6 +61,7 @@ void rpc_start(Channel *channel)
|
||||
rpc->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE);
|
||||
rpc->subscribed_events = pmap_new(cstr_t)();
|
||||
rpc->next_request_id = 1;
|
||||
rpc->info = (Dictionary)ARRAY_DICT_INIT;
|
||||
kv_init(rpc->call_stack);
|
||||
|
||||
if (channel->streamtype != kChannelStreamInternal) {
|
||||
@@ -553,6 +554,7 @@ void rpc_free(Channel *channel)
|
||||
|
||||
pmap_free(cstr_t)(channel->rpc.subscribed_events);
|
||||
kv_destroy(channel->rpc.call_stack);
|
||||
api_free_dictionary(channel->rpc.info);
|
||||
}
|
||||
|
||||
static bool is_rpc_response(msgpack_object *obj)
|
||||
@@ -642,6 +644,23 @@ static WBuffer *serialize_response(uint64_t channel_id,
|
||||
return rv;
|
||||
}
|
||||
|
||||
void rpc_set_client_info(uint64_t id, Dictionary info)
|
||||
{
|
||||
Channel *chan = find_rpc_channel(id);
|
||||
if (!chan) {
|
||||
abort();
|
||||
}
|
||||
|
||||
api_free_dictionary(chan->rpc.info);
|
||||
chan->rpc.info = info;
|
||||
channel_info_changed(chan, false);
|
||||
}
|
||||
|
||||
Dictionary rpc_client_info(Channel *chan)
|
||||
{
|
||||
return copy_dictionary(chan->rpc.info);
|
||||
}
|
||||
|
||||
#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL
|
||||
#define REQ "[request] "
|
||||
#define RES "[response] "
|
||||
|
@@ -31,6 +31,7 @@ typedef struct {
|
||||
msgpack_unpacker *unpacker;
|
||||
uint64_t next_request_id;
|
||||
kvec_t(ChannelCallFrame *) call_stack;
|
||||
Dictionary info;
|
||||
} RpcState;
|
||||
|
||||
#endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
|
||||
|
Reference in New Issue
Block a user