mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
refactor(api)!: rename Dictionary => Dict
In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
This commit is contained in:
@@ -1629,7 +1629,7 @@ static void highlight_list_one(const int id)
|
||||
}
|
||||
}
|
||||
|
||||
static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
static bool hlgroup2dict(Dict *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
{
|
||||
HlGroup *sgp = &hl_table[hl_id - 1];
|
||||
int link = ns_id == 0 ? sgp->sg_link : ns_get_hl(&ns_id, hl_id, true, sgp->sg_set);
|
||||
@@ -1650,16 +1650,16 @@ static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
assert(1 <= link && link <= highlight_ga.ga_len);
|
||||
PUT_C(*hl, "link", CSTR_AS_OBJ(hl_table[link - 1].sg_name));
|
||||
}
|
||||
Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
Dict hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
hlattrs2dict(hl, NULL, attr, true, true);
|
||||
hlattrs2dict(hl, &hl_cterm, attr, false, true);
|
||||
if (kv_size(hl_cterm)) {
|
||||
PUT_C(*hl, "cterm", DICTIONARY_OBJ(hl_cterm));
|
||||
PUT_C(*hl, "cterm", DICT_OBJ(hl_cterm));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
Dict ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
{
|
||||
Boolean link = GET_BOOL_OR_TRUE(opts, get_highlight, link);
|
||||
int id = -1;
|
||||
@@ -1668,7 +1668,7 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
id = create ? syn_check_group(opts->name.data, opts->name.size)
|
||||
: syn_name2id_len(opts->name.data, opts->name.size);
|
||||
if (id == 0 && !create) {
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
return attrs;
|
||||
}
|
||||
} else if (HAS_KEY(opts, get_highlight, id)) {
|
||||
@@ -1679,7 +1679,7 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
VALIDATE(1 <= id && id <= highlight_ga.ga_len, "%s", "Highlight id out of bounds", {
|
||||
goto cleanup;
|
||||
});
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
hlgroup2dict(&attrs, ns_id, link ? id : syn_get_final_id(id), arena);
|
||||
return attrs;
|
||||
}
|
||||
@@ -1687,19 +1687,19 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Dictionary rv = arena_dict(arena, (size_t)highlight_ga.ga_len);
|
||||
Dict rv = arena_dict(arena, (size_t)highlight_ga.ga_len);
|
||||
for (int i = 1; i <= highlight_ga.ga_len; i++) {
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
if (!hlgroup2dict(&attrs, ns_id, i, arena)) {
|
||||
continue;
|
||||
}
|
||||
PUT_C(rv, hl_table[(link ? i : syn_get_final_id(i)) - 1].sg_name, DICTIONARY_OBJ(attrs));
|
||||
PUT_C(rv, hl_table[(link ? i : syn_get_final_id(i)) - 1].sg_name, DICT_OBJ(attrs));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
cleanup:
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
/// Outputs a highlight when doing ":hi MyHighlight"
|
||||
|
Reference in New Issue
Block a user