neovim / neovim-ruby

Ruby support for Neovim
MIT License
340 stars 17 forks source link

How to receive event? #102

Closed alopatindev closed 7 months ago

alopatindev commented 7 months ago
client = Neovim.attach_unix('nvim.sock')
client.subscribe('event')

In nvim I do :call rpcnotify(0, 'event')

How do I know that the event has happened?

I wish the API was something like client.subscribe('event', |args| print(args)).

I see no trace of anything similar to next_message() or run_loop(request_cb = None, notification_cb = lambda event, args: print(args)) in the public API docs.

Public method from_event_loop takes private type EventLoop as argument, which is constructed in the attach, but I see nothing like public API for EventLoop::read.

alexgenco commented 7 months ago

Can you use Session#next or Session#run ? The session is accessible as a reader on the client, i.e. client.session.

alopatindev commented 7 months ago

Works, thanks!

However Session is marked private. Will it become public at some point?

alexgenco commented 7 months ago

Will it become public at some point?

No plans at the moment. TBH I'm not really actively working on this library anymore, just bugfixes and stuff. So if this were to be made public (possibly on the Client class, with an interface like you suggested), it would have to come from outside contributors.