In vim, we can implement a vim script, which monitors text changes in details, with listener_add(), listener_remove(), listener_flush(). In nvim, nvim_buf_attach() is available to attach a callback. And I thought I could detach it with nvim_buf_detach() but it looks like not implemented as Lua callback.

I am looking for how to detach/disable the callback in nvim.

:h nvim_buf_attach
• on_lines: Lua callback invoked on change. Return `true` to detach.
:h api-lua-detach
In-process Lua callbacks can detach by returning `true`. This will detach all callbacks attached with the same nvim_buf_attach() call.

So returning 'true' might be a solution but I am not sure how to implement it. Does anyone have a good idea?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.