feat(tui): builtin UI (TUI) sets client info #30397

Problem:
The default builtin UI client does not declare its client info. This
reduces discoverability and makes it difficult for plugins to identify
the UI.

Solution:
- Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`.
- Also set the "pid" field.
- Also change `ui_active()` to return a count. Not directly relevant to
  this commit, but will be useful later.
This commit is contained in:
Justin M. Keyes
2024-09-18 04:14:06 -07:00
committed by GitHub
parent 22553e1f38
commit ff85e54939
13 changed files with 163 additions and 43 deletions

View File

@@ -1586,6 +1586,7 @@ Array nvim_get_api_info(uint64_t channel_id, Arena *arena)
///
/// @param attributes Arbitrary string:string map of informal client properties.
/// Suggested keys:
/// - "pid": Process id.
/// - "website": Client homepage URL (e.g. GitHub repository)
/// - "license": License description ("Apache 2", "GPLv3", "MIT", …)
/// - "logo": URI or path to image, preferably small logo or icon.
@@ -1627,7 +1628,7 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
/// Gets information about a channel.
///
/// @param chan channel_id, or 0 for current channel
/// @returns Dictionary describing a channel, with these keys:
/// @returns Channel info dict with these keys:
/// - "id" Channel id.
/// - "argv" (optional) Job arguments list.
/// - "stream" Stream underlying the channel.
@@ -1639,14 +1640,12 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
/// - "bytes" Send and receive raw bytes.
/// - "terminal" |terminal| instance interprets ASCII sequences.
/// - "rpc" |RPC| communication on the channel is active.
/// - "pty" (optional) Name of pseudoterminal. On a POSIX system this
/// is a device path like "/dev/pts/1". If the name is unknown,
/// the key will still be present if a pty is used (e.g. for
/// conpty on Windows).
/// - "buffer" (optional) Buffer with connected |terminal| instance.
/// - "client" (optional) Info about the peer (client on the other end of
/// the RPC channel), if provided by it via
/// |nvim_set_client_info()|.
/// - "pty" (optional) Name of pseudoterminal. On a POSIX system this is a device path like
/// "/dev/pts/1". If unknown, the key will still be present if a pty is used (e.g.
/// for conpty on Windows).
/// - "buffer" (optional) Buffer connected to |terminal| instance.
/// - "client" (optional) Info about the peer (client on the other end of the RPC channel),
/// which it provided via |nvim_set_client_info()|.
///
Dictionary nvim_get_chan_info(uint64_t channel_id, Integer chan, Arena *arena, Error *err)
FUNC_API_SINCE(4)