aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/highlight.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2023-05-23 14:25:10 +0600
committerFamiu Haque <famiuhaque@proton.me>2023-05-23 15:20:41 +0600
commitcfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f (patch)
tree9cae576fc90b55c9586286706a9d1754762bea8b /src/nvim/highlight.c
parent62a80c36c158ecf4ffc8c93d8891aeb2f0d2f287 (diff)
downloadrneovim-cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f.tar.gz
rneovim-cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f.tar.bz2
rneovim-cfd4fdfea4d0e68ea50ad412b88b5289ded6fd6f.zip
refactor(api): new helper macros
Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner.
Diffstat (limited to 'src/nvim/highlight.c')
-rw-r--r--src/nvim/highlight.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index a53da95fba..fad113adc5 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -207,7 +207,7 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
if (!valid_item && p->hl_def != LUA_NOREF && !recursive) {
MAXSIZE_TEMP_ARRAY(args, 3);
ADD_C(args, INTEGER_OBJ((Integer)ns_id));
- ADD_C(args, STRING_OBJ(cstr_to_string(syn_id2name(hl_id))));
+ ADD_C(args, CSTR_TO_OBJ(syn_id2name(hl_id)));
ADD_C(args, BOOLEAN_OBJ(link));
// TODO(bfredl): preload the "global" attr dict?
@@ -1141,21 +1141,21 @@ static void hl_inspect_impl(Array *arr, int attr)
HlEntry e = kv_A(attr_entries, attr);
switch (e.kind) {
case kHlSyntax:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax")));
+ PUT(item, "kind", CSTR_TO_OBJ("syntax"));
PUT(item, "hi_name",
- STRING_OBJ(cstr_to_string(syn_id2name(e.id1))));
+ CSTR_TO_OBJ(syn_id2name(e.id1)));
break;
case kHlUI:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("ui")));
+ PUT(item, "kind", CSTR_TO_OBJ("ui"));
const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
- PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name)));
+ PUT(item, "ui_name", CSTR_TO_OBJ(ui_name));
PUT(item, "hi_name",
- STRING_OBJ(cstr_to_string(syn_id2name(e.id2))));
+ CSTR_TO_OBJ(syn_id2name(e.id2)));
break;
case kHlTerminal:
- PUT(item, "kind", STRING_OBJ(cstr_to_string("term")));
+ PUT(item, "kind", CSTR_TO_OBJ("term"));
break;
case kHlCombine: