From 0b615dae073c14078c0a92b8aaed1da24575afcf Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 21 Sep 2020 10:37:28 +0200 Subject: api: multiple decoration providers at once --- src/nvim/api/private/helpers.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/nvim/api/private/helpers.c') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index e0d5862e02..84517c99fc 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1619,14 +1619,28 @@ free_exit: return virt_text; } -bool api_is_truthy(Object obj, const char *what, Error *err) +bool api_is_truthy(Object obj, const char *what, bool nil_truthy, Error *err) { if (obj.type == kObjectTypeBoolean) { return obj.data.boolean; } else if (obj.type == kObjectTypeInteger) { - return obj.data.integer; // C semantics: non-zery int is true + return obj.data.integer; // C semantics: non-zero int is true + } else if (obj.type == kObjectTypeNil) { + return nil_truthy; // caller decides what NIL (missing retval in lua) means } else { api_set_error(err, kErrorTypeValidation, "%s is not an boolean", what); return false; } } + +const char *describe_ns(NS ns_id) +{ + String name; + handle_T id; + map_foreach(namespace_ids, name, id, { + if ((NS)id == ns_id && name.size) { + return name.data; + } + }) + return "(UNKNOWN PLUGIN)"; +} -- cgit