Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/NvimClient.API/NvimAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@

namespace NvimClient.API
{
/// <summary>
/// Interface to the Neovim msgpack-rpc API.
/// </summary>
Comment thread
smolck marked this conversation as resolved.
public partial class NvimAPI
{
/// <summary>
/// Handler for requests from Neovim without a handler registered via <see cref="RegisterHandler"/>
/// </summary>
public event EventHandler<NvimUnhandledRequestEventArgs> OnUnhandledRequest;

/// <summary>
/// Handler for notifications from Neovim without a handler registered via <see cref="RegisterHandler"/>
/// </summary>
public event EventHandler<NvimUnhandledNotificationEventArgs>
OnUnhandledNotification;

Expand Down Expand Up @@ -130,12 +140,27 @@ public NvimAPI(Stream inputStream, Stream outputStream)
StartReceiveLoop();
}

/// <summary>
/// Register a handler for the <c>name</c> notification or request.
/// </summary>
/// <param name="name"></param>
/// <param name="handler"></param>
public void RegisterHandler(string name, Func<object[], object> handler) =>
RegisterHandler(name, (Delegate)handler);

/// <summary>
/// Register a handler for the <c>name</c> notification or request.
/// </summary>
/// <param name="name"></param>
/// <param name="handler"></param>
public void RegisterHandler(string name, Action<object[]> handler) =>
RegisterHandler(name, (Delegate)handler);

/// <summary>
/// Register a handler for the <c>name</c> notification or request.
/// </summary>
/// <param name="name"></param>
/// <param name="handler"></param>
public void RegisterHandler(string name,
Func<object[], Task<object>> handler) => RegisterHandler(name,
(requestId, args) =>
Expand Down Expand Up @@ -337,6 +362,9 @@ async void Receive()
}
}

/// <summary>
/// Block the current thread while waiting for Neovim to quit.
/// </summary>
public void WaitForDisconnect() => _waitEvent.WaitOne();

private class PendingRequest
Expand Down
Loading