diff options
author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2022-06-09 15:18:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 07:18:56 -0600 |
commit | 3da3cfc864e89a2dca6917183915683373c85af8 (patch) | |
tree | 8233b38ee94a3aa3c8cede35dabb9ee8c774993a /src/nvim/eval/typval.c | |
parent | c5720c72213810adb75d3277ac645eb6fc8dafa8 (diff) | |
download | rneovim-3da3cfc864e89a2dca6917183915683373c85af8.tar.gz rneovim-3da3cfc864e89a2dca6917183915683373c85af8.tar.bz2 rneovim-3da3cfc864e89a2dca6917183915683373c85af8.zip |
feat(autocmds): retrieve lua callback (#18642)
add a new `callback` field to `nvim_get_autocmds`
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 2c76741891..97726da5f4 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1205,6 +1205,30 @@ void callback_copy(Callback *dest, Callback *src) } } +/// Generate a string description of a callback +char *callback_to_string(Callback *cb) +{ + size_t msglen = 100; + char *msg = (char *)xmallocz(msglen); + + switch (cb->type) { + case kCallbackLua: + snprintf(msg, msglen, "<lua: %d>", cb->data.luaref); + break; + case kCallbackFuncref: + // TODO(tjdevries): Is this enough space for this? + snprintf(msg, msglen, "<vim function: %s>", cb->data.funcref); + break; + case kCallbackPartial: + snprintf(msg, msglen, "<vim partial: %s>", cb->data.partial->pt_name); + break; + default: + snprintf(msg, msglen, "%s", ""); + break; + } + return msg; +} + /// Remove watcher from a dictionary /// /// @param dict Dictionary to remove watcher from. |