aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/syntax.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-02-05 10:18:47 +0100
committerGitHub <noreply@github.com>2022-02-05 10:18:47 +0100
commit806a7c976d78da2bf7a46499452b4a3e30fae798 (patch)
treea479ac073770dca0d965bdf1b8023b6e95daa119 /src/nvim/syntax.c
parent741b4d62623111a281790f1602f1c8be4113218e (diff)
parent0bafa44f8b9c4ad2a1cf5233bc207cba522a5dfe (diff)
downloadrneovim-806a7c976d78da2bf7a46499452b4a3e30fae798.tar.gz
rneovim-806a7c976d78da2bf7a46499452b4a3e30fae798.tar.bz2
rneovim-806a7c976d78da2bf7a46499452b4a3e30fae798.zip
Merge pull request #17275 from bfredl/keysethl
refactor(api): use a keyset for highlight dicts
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r--src/nvim/syntax.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index b383b290ba..3aef654a8e 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6714,7 +6714,7 @@ int lookup_color(const int idx, const bool foreground, TriState *const boldp)
return color;
}
-void set_hl_group(int id, HlAttrs attrs, HlAttrNames *names, int link_id)
+void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
{
int idx = id - 1; // Index is ID minus one.
@@ -6750,19 +6750,19 @@ void set_hl_group(int id, HlAttrs attrs, HlAttrNames *names, int link_id)
g->sg_rgb_sp = attrs.rgb_sp_color;
struct {
- char **dest; RgbValue val; char *name;
+ char **dest; RgbValue val; Object name;
} cattrs[] = {
- { &g->sg_rgb_fg_name, g->sg_rgb_fg, names->fg_name },
- { &g->sg_rgb_bg_name, g->sg_rgb_bg, names->bg_name },
- { &g->sg_rgb_sp_name, g->sg_rgb_sp, names->sp_name },
- { NULL, -1, NULL },
+ { &g->sg_rgb_fg_name, g->sg_rgb_fg, HAS_KEY(dict->fg) ? dict->fg : dict->foreground },
+ { &g->sg_rgb_bg_name, g->sg_rgb_bg, HAS_KEY(dict->bg) ? dict->bg : dict->background },
+ { &g->sg_rgb_sp_name, g->sg_rgb_sp, HAS_KEY(dict->sp) ? dict->sp : dict->special },
+ { NULL, -1, NIL },
};
for (int j = 0; cattrs[j].dest; j++) {
if (cattrs[j].val != -1) {
xfree(*cattrs[j].dest);
- if (cattrs[j].name) {
- *cattrs[j].dest = xstrdup(cattrs[j].name);
+ if (cattrs[j].name.type == kObjectTypeString && cattrs[j].name.data.string.size) {
+ *cattrs[j].dest = xstrdup(cattrs[j].name.data.string.data);
} else {
char hex_name[8];
snprintf(hex_name, sizeof(hex_name), "#%06x", cattrs[j].val);