aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/deprecated.c4
-rw-r--r--src/nvim/api/options.c8
-rw-r--r--src/nvim/option.c43
3 files changed, 28 insertions, 27 deletions
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index b09645a819..27f0589e53 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -514,11 +514,11 @@ static int64_t convert_index(int64_t index)
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option Information
-Dictionary nvim_get_option_info(String name, Error *err)
+Dictionary nvim_get_option_info(String name, Arena *arena, Error *err)
FUNC_API_SINCE(7)
FUNC_API_DEPRECATED_SINCE(11)
{
- return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, err);
+ return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, arena, err);
}
/// Sets the global value of an option.
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index fce4a85804..8128fdf67b 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -263,10 +263,10 @@ void nvim_set_option_value(uint64_t channel_id, String name, Object value, Dict(
/// @see |nvim_get_commands()|
///
/// @return dictionary of all options
-Dictionary nvim_get_all_options_info(Error *err)
+Dictionary nvim_get_all_options_info(Arena *arena, Error *err)
FUNC_API_SINCE(7)
{
- return get_all_vimoptions();
+ return get_all_vimoptions(arena);
}
/// Gets the option information for one option from arbitrary buffer or window
@@ -302,7 +302,7 @@ Dictionary nvim_get_all_options_info(Error *err)
/// Implies {scope} is "local".
/// @param[out] err Error details, if any
/// @return Option Information
-Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
+Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Arena *arena, Error *err)
FUNC_API_SINCE(11)
{
OptIndex opt_idx = 0;
@@ -317,5 +317,5 @@ Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
buf_T *buf = (req_scope == kOptReqBuf) ? (buf_T *)from : curbuf;
win_T *win = (req_scope == kOptReqWin) ? (win_T *)from : curwin;
- return get_vimoption(name, scope, buf, win, err);
+ return get_vimoption(name, scope, buf, win, arena, err);
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index db013b460e..cdb27fcd1c 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -6314,32 +6314,33 @@ int get_sidescrolloff_value(win_T *wp)
return (int)(wp->w_p_siso < 0 ? p_siso : wp->w_p_siso);
}
-Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Error *err)
+Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Arena *arena, Error *err)
{
OptIndex opt_idx = find_option_len(name.data, name.size);
VALIDATE_S(opt_idx != kOptInvalid, "option (not found)", name.data, {
return (Dictionary)ARRAY_DICT_INIT;
});
- return vimoption2dict(&options[opt_idx], scope, buf, win);
+ return vimoption2dict(&options[opt_idx], scope, buf, win, arena);
}
-Dictionary get_all_vimoptions(void)
+Dictionary get_all_vimoptions(Arena *arena)
{
- Dictionary retval = ARRAY_DICT_INIT;
+ Dictionary retval = arena_dict(arena, kOptIndexCount);
for (OptIndex opt_idx = 0; opt_idx < kOptIndexCount; opt_idx++) {
- Dictionary opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin);
- PUT(retval, options[opt_idx].fullname, DICTIONARY_OBJ(opt_dict));
+ Dictionary opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin, arena);
+ PUT_C(retval, options[opt_idx].fullname, DICTIONARY_OBJ(opt_dict));
}
return retval;
}
-static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win)
+static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win,
+ Arena *arena)
{
- Dictionary dict = ARRAY_DICT_INIT;
+ Dictionary dict = arena_dict(arena, 13);
- PUT(dict, "name", CSTR_TO_OBJ(opt->fullname));
- PUT(dict, "shortname", CSTR_TO_OBJ(opt->shortname));
+ PUT_C(dict, "name", CSTR_AS_OBJ(opt->fullname));
+ PUT_C(dict, "shortname", CSTR_AS_OBJ(opt->shortname));
const char *scope;
if (opt->indir & PV_BUF) {
@@ -6350,14 +6351,14 @@ static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, wi
scope = "global";
}
- PUT(dict, "scope", CSTR_TO_OBJ(scope));
+ PUT_C(dict, "scope", CSTR_AS_OBJ(scope));
// welcome to the jungle
- PUT(dict, "global_local", BOOLEAN_OBJ(opt->indir & PV_BOTH));
- PUT(dict, "commalist", BOOLEAN_OBJ(opt->flags & P_COMMA));
- PUT(dict, "flaglist", BOOLEAN_OBJ(opt->flags & P_FLAGLIST));
+ PUT_C(dict, "global_local", BOOLEAN_OBJ(opt->indir & PV_BOTH));
+ PUT_C(dict, "commalist", BOOLEAN_OBJ(opt->flags & P_COMMA));
+ PUT_C(dict, "flaglist", BOOLEAN_OBJ(opt->flags & P_FLAGLIST));
- PUT(dict, "was_set", BOOLEAN_OBJ(opt->flags & P_WAS_SET));
+ PUT_C(dict, "was_set", BOOLEAN_OBJ(opt->flags & P_WAS_SET));
LastSet last_set = { .channel_id = 0 };
if (req_scope == OPT_GLOBAL) {
@@ -6375,16 +6376,16 @@ static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, wi
}
}
- PUT(dict, "last_set_sid", INTEGER_OBJ(last_set.script_ctx.sc_sid));
- PUT(dict, "last_set_linenr", INTEGER_OBJ(last_set.script_ctx.sc_lnum));
- PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)last_set.channel_id));
+ PUT_C(dict, "last_set_sid", INTEGER_OBJ(last_set.script_ctx.sc_sid));
+ PUT_C(dict, "last_set_linenr", INTEGER_OBJ(last_set.script_ctx.sc_lnum));
+ PUT_C(dict, "last_set_chan", INTEGER_OBJ((int64_t)last_set.channel_id));
// TODO(bfredl): do you even nocp?
OptVal def = optval_from_varp(get_opt_idx(opt), &opt->def_val);
- PUT(dict, "type", CSTR_TO_OBJ(optval_type_get_name(def.type)));
- PUT(dict, "default", optval_as_object(optval_copy(def)));
- PUT(dict, "allows_duplicates", BOOLEAN_OBJ(!(opt->flags & P_NODUP)));
+ PUT_C(dict, "type", CSTR_AS_OBJ(optval_type_get_name(def.type)));
+ PUT_C(dict, "default", optval_as_object(def));
+ PUT_C(dict, "allows_duplicates", BOOLEAN_OBJ(!(opt->flags & P_NODUP)));
return dict;
}