diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-08-28 10:17:45 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-09-09 10:52:12 -0700 |
commit | e5d5fc0857935b4f67058a6a2dcfbc573331e3f6 (patch) | |
tree | 8240963c4734554117eb1392a3677368f0e31dd8 | |
parent | a3849abc31d1857c9b54c7425b6bc0a4b1a99ec1 (diff) | |
download | rneovim-e5d5fc0857935b4f67058a6a2dcfbc573331e3f6.tar.gz rneovim-e5d5fc0857935b4f67058a6a2dcfbc573331e3f6.tar.bz2 rneovim-e5d5fc0857935b4f67058a6a2dcfbc573331e3f6.zip |
doc/API/lua: detaching Lua buffer callbacks
-rw-r--r-- | runtime/doc/api.txt | 16 | ||||
-rw-r--r-- | src/nvim/api/buffer.c | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index bb4274a661..21cc114598 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -330,13 +330,14 @@ paste a block of 6 lines, emits: > User reloads the buffer with ":edit", emits: > nvim_buf_detach_event[{buf}] +< +LUA ~ *api-buffer-updates-lua* -In-process lua plugins can also receive buffer updates, in the form of lua -callbacks. These callbacks are called frequently in various contexts, buffer -contents or window layout should not be changed inside these |textlock|. -|vim.schedule| can be used to defer these operations to the main loop, where -they are allowed. +In-process Lua plugins can receive buffer updates in the form of Lua +callbacks. These callbacks are called frequently in various contexts; +|textlock| prevents changing buffer contents and window layout (use +|vim.schedule| to defer such operations to the main loop instead). |nvim_buf_attach| will take keyword args for the callbacks. "on_lines" will receive parameters ("lines", {buf}, {changedtick}, {firstline}, {lastline}, @@ -355,6 +356,9 @@ arguments {old_utf32_size} and {old_utf16_size}. "on_changedtick" is invoked when |b:changedtick| was incremented but no text was changed. The parameters recieved are ("changedtick", {buf}, {changedtick}). + *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. ============================================================================== @@ -1510,6 +1514,8 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* nvim_buf_detach({buffer}) *nvim_buf_detach()* Deactivates buffer-update events on the channel. + For Lua callbacks see |api-lua-detach|. + Parameters: ~ {buffer} Buffer handle, or 0 for current buffer diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 19ca25837a..3e1209d1b1 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -183,6 +183,8 @@ error: /// Deactivates buffer-update events on the channel. /// +/// For Lua callbacks see |api-lua-detach|. +/// /// @param channel_id /// @param buffer Buffer handle, or 0 for current buffer /// @param[out] err Error details, if any |