aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-12-03 20:59:36 -0500
committerBjörn Linse <bjorn.linse@gmail.com>2020-12-04 13:29:44 +0100
commitced951c2aacd175c21c68a5bbf7fdf459954d0ab (patch)
tree98ef9f3e7fb6072d94b8424ba77de80ba8d35892 /src/nvim/option.c
parent3b3c006ae34256637f101ea85a84998377f56e40 (diff)
downloadrneovim-ced951c2aacd175c21c68a5bbf7fdf459954d0ab.tar.gz
rneovim-ced951c2aacd175c21c68a5bbf7fdf459954d0ab.tar.bz2
rneovim-ced951c2aacd175c21c68a5bbf7fdf459954d0ab.zip
api/options: fixup
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 12468adbe8..85f38b02ae 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -7180,7 +7180,7 @@ Dictionary get_vimoption(String name, Error *err)
{
int opt_idx = findoption_len((const char *)name.data, name.size);
if (opt_idx < 0) {
- api_set_error(err, kErrorTypeValidation, "no such option %s", name.data);
+ api_set_error(err, kErrorTypeValidation, "no such option: '%s'", name.data);
return (Dictionary)ARRAY_DICT_INIT;
}
return vimoption2dict(&options[opt_idx]);
@@ -7202,27 +7202,30 @@ static Dictionary vimoption2dict(vimoption_T *opt)
PUT(dict, "name", STRING_OBJ(cstr_to_string(opt->fullname)));
PUT(dict, "shortname", STRING_OBJ(cstr_to_string(opt->shortname)));
-#define PUT_IF(dict, name, condition) do if (condition) \
- { PUT(dict, name, BOOLEAN_OBJ(true)); } while (0)
- PUT_IF(dict, "win", opt->indir & PV_WIN);
- PUT_IF(dict, "buf", opt->indir & PV_BUF);
+
+#define PUT_BOOL(dict, name, condition) \
+ PUT(dict, name, BOOLEAN_OBJ(condition));
+
+ PUT_BOOL(dict, "win", opt->indir & PV_WIN);
+ PUT_BOOL(dict, "buf", opt->indir & PV_BUF);
+
// welcome to the jungle
- PUT_IF(dict, "global_local", opt->indir & PV_BOTH);
- PUT_IF(dict, "commalist", opt->flags & P_COMMA);
- PUT_IF(dict, "flaglist", opt->flags & P_FLAGLIST);
+ PUT_BOOL(dict, "global_local", opt->indir & PV_BOTH);
+ PUT_BOOL(dict, "commalist", opt->flags & P_COMMA);
+ PUT_BOOL(dict, "flaglist", opt->flags & P_FLAGLIST);
- PUT_IF(dict, "was_set", opt->flags & P_WAS_SET);
+ PUT_BOOL(dict, "was_set", opt->flags & P_WAS_SET);
+#undef PUT_BOOL
- PUT(dict, "flag", INTEGER_OBJ(opt->flags)); // TODO(bfredl): lol tj
PUT(dict, "last_set_sid", INTEGER_OBJ(opt->last_set.script_ctx.sc_sid));
- if (opt->last_set.script_ctx.sc_lnum > 0) {
- PUT(dict, "last_set_linenr",
- INTEGER_OBJ(opt->last_set.script_ctx.sc_lnum));
- }
- if (opt->last_set.channel_id > 0) {
- PUT(dict, "last_set_lchan",
- INTEGER_OBJ((int64_t)opt->last_set.channel_id));
- }
+ PUT(dict, "last_set_linenr",
+ opt->last_set.script_ctx.sc_lnum > 0
+ ? INTEGER_OBJ(opt->last_set.script_ctx.sc_lnum)
+ : INTEGER_OBJ(-1));
+ PUT(dict, "last_set_lchan",
+ opt->last_set.channel_id > 0
+ ? INTEGER_OBJ((int64_t)opt->last_set.channel_id)
+ : INTEGER_OBJ(-1));
const char *type;
Object def;