aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/extmark.c
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-01-17 20:14:26 +0800
committerglepnir <glephunter@gmail.com>2024-01-20 21:31:11 +0800
commit646fdf1073433e2bdeec3433f6cbdf8f4be37098 (patch)
treeabb6c88e011a52bc3900aee40fe0cab6ce77a95d /src/nvim/api/extmark.c
parentba9f86a9cee58dc32ab875da1fd7eac9bc9e88d7 (diff)
downloadrneovim-646fdf1073433e2bdeec3433f6cbdf8f4be37098.tar.gz
rneovim-646fdf1073433e2bdeec3433f6cbdf8f4be37098.tar.bz2
rneovim-646fdf1073433e2bdeec3433f6cbdf8f4be37098.zip
refactor(api): use hl id directly in nvim_buf_set_extmark
Diffstat (limited to 'src/nvim/api/extmark.c')
-rw-r--r--src/nvim/api/extmark.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index fd07ec96fe..4e4befee1d 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -14,6 +14,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/decoration.h"
+#include "nvim/decoration_defs.h"
#include "nvim/decoration_provider.h"
#include "nvim/drawscreen.h"
#include "nvim/extmark.h"
@@ -540,36 +541,15 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
col2 = (int)val;
}
- // uncrustify:off
+ hl.hl_id = (int)opts->hl_group;
+ has_hl = hl.hl_id > 0;
+ sign.hl_id = (int)opts->sign_hl_group;
+ sign.cursorline_hl_id = (int)opts->cursorline_hl_group;
+ sign.number_hl_id = (int)opts->number_hl_group;
+ sign.line_hl_id = (int)opts->line_hl_group;
- // TODO(bfredl): keyset type alias for hl_group? (nil|int|string)
- struct {
- const char *name;
- Object *opt;
- int *dest;
- } hls[] = {
- { "hl_group" , &opts->hl_group , &hl.hl_id },
- { "sign_hl_group" , &opts->sign_hl_group , &sign.hl_id },
- { "number_hl_group" , &opts->number_hl_group , &sign.number_hl_id },
- { "line_hl_group" , &opts->line_hl_group , &sign.line_hl_id },
- { "cursorline_hl_group", &opts->cursorline_hl_group, &sign.cursorline_hl_id },
- { NULL, NULL, NULL },
- };
-
- // uncrustify:on
-
- for (int j = 0; hls[j].name && hls[j].dest; j++) {
- if (hls[j].opt->type != kObjectTypeNil) {
- if (j > 0) {
- sign.flags |= kSHIsSign;
- } else {
- has_hl = true;
- }
- *hls[j].dest = object_to_hl_id(*hls[j].opt, hls[j].name, err);
- if (ERROR_SET(err)) {
- goto error;
- }
- }
+ if (sign.hl_id || sign.cursorline_hl_id || sign.number_hl_id || sign.line_hl_id) {
+ sign.flags |= kSHIsSign;
}
if (HAS_KEY(opts, set_extmark, conceal)) {