diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2022-03-19 18:57:58 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-19 18:57:58 -0600 |
commit | be35d3c5ad501abb029279f8e1812d0e4525284f (patch) | |
tree | 22f0371d83adcf5f2a97809c8a573562bd7fd129 /src/nvim/eval.c | |
parent | 77eb6f9dc75ebe00aa835441ad623ba46d7108bb (diff) | |
download | rneovim-be35d3c5ad501abb029279f8e1812d0e4525284f.tar.gz rneovim-be35d3c5ad501abb029279f8e1812d0e4525284f.tar.bz2 rneovim-be35d3c5ad501abb029279f8e1812d0e4525284f.zip |
feat(api): remove Lua autocommand callbacks when they return true (#17784)
This copies the semantics of nvim_buf_attach callbacks, and is a
convenient way to create oneshot autocommands gated by some condition.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index af7c3d4985..33e8469768 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7730,6 +7730,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co partial_T *partial; char_u *name; Array args = ARRAY_DICT_INIT; + Object rv; switch (callback->type) { case kCallbackFuncref: name = callback->data.funcref; @@ -7742,10 +7743,13 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co break; case kCallbackLua: - nlua_call_ref(callback->data.luaref, NULL, args, false, NULL); - - return false; - break; + rv = nlua_call_ref(callback->data.luaref, NULL, args, true, NULL); + switch (rv.type) { + case kObjectTypeBoolean: + return rv.data.boolean; + default: + return false; + } case kCallbackNone: return false; |