1

I want to write a plugin that will watch a buffer for changes and execute different functions depending on the change.

I know I can use nvim_buf_attach() to subscribe to buffer events, but they are sent to "the current channel". For a moment I thought perhaps calling vim.api.nvim_buf_attach(current_buffer, true, {}) might work in my plugin – maybe it would auto set some channel context but the call fails attempt to call field 'nvim_buf_attach' (a nil value) – it seems that the event api isn't exposed to the built in lua client?

The docs describe how to create a channel but none of them seem appropriate for a plugin, they're all for IPC.

I would like the plugin functions to run async, so I'm not against spawning a "event consumer" process that runs alongside the static plugin bits. I'm just not sure how to do that with neovims compiled-in lua client, i.e. without making some OS installed lua package an external dependency of the plugin.

  • This is currently an awkward limitation. We are working on exposing RPC events to VimL/Lua. – Justin M. Keyes Dec 18 '18 at 16:22
  • Looking forward to it! – purplelulu Jan 7 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.