diff options
| author | Luuk van Baal <luukvbaal@gmail.com> | 2024-11-23 23:03:46 +0100 |
|---|---|---|
| committer | luukvbaal <luukvbaal@gmail.com> | 2025-02-25 13:09:01 +0100 |
| commit | f58e7d5fac1c4f63f0ba3e59134591239182910e (patch) | |
| tree | 1b180a27cb3c4f4f521188b8e6416d3adfc79206 /src/nvim/api | |
| parent | a31ccc3b1f65fd86780c03fec9c6e1bf56e30e35 (diff) | |
| download | rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.gz rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.tar.bz2 rneovim-f58e7d5fac1c4f63f0ba3e59134591239182910e.zip | |
feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
Diffstat (limited to 'src/nvim/api')
| -rw-r--r-- | src/nvim/api/extmark.c | 28 | ||||
| -rw-r--r-- | src/nvim/api/keysets_defs.h | 1 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index ef09dbb0aa..e4bb9d6953 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -492,6 +492,10 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// When a character is supplied it is used as |:syn-cchar|. /// "hl_group" is used as highlight for the cchar if provided, /// otherwise it defaults to |hl-Conceal|. +/// - conceal_lines: string which should be empty. When +/// provided, lines in the range are not drawn at all +/// (according to 'conceallevel'); the next unconcealed line +/// is drawn instead. /// - spell: boolean indicating that spell checking should be /// performed within this extmark /// - ui_watched: boolean that indicates the mark should be drawn @@ -607,14 +611,22 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer if (HAS_KEY(opts, set_extmark, conceal)) { hl.flags |= kSHConceal; has_hl = true; - String c = opts->conceal; - if (c.size > 0) { + if (opts->conceal.size > 0) { int ch; - hl.conceal_char = utfc_ptr2schar(c.data, &ch); - if (!hl.conceal_char || !vim_isprintc(ch)) { - api_set_error(err, kErrorTypeValidation, "conceal char has to be printable"); + hl.conceal_char = utfc_ptr2schar(opts->conceal.data, &ch); + VALIDATE(hl.conceal_char && vim_isprintc(ch), "%s", "conceal char has to be printable", { goto error; - } + }); + } + } + + if (HAS_KEY(opts, set_extmark, conceal_lines)) { + hl.flags |= kSHConcealLines; + has_hl = true; + if (opts->conceal_lines.size > 0) { + VALIDATE(*opts->conceal_lines.data == NUL, "%s", "conceal_lines has to be an empty string", { + goto error; + }); } } @@ -863,6 +875,10 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } } + if (hl.flags & kSHConcealLines) { + decor_flags |= MT_FLAG_DECOR_CONCEAL_LINES; + } + DecorInline decor = DECOR_INLINE_INIT; if (decor_alloc || decor_indexed != DECOR_ID_INVALID || url != NULL || schar_high(hl.conceal_char)) { diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h index b3015911f9..b9bd8ea286 100644 --- a/src/nvim/api/keysets_defs.h +++ b/src/nvim/api/keysets_defs.h @@ -53,6 +53,7 @@ typedef struct { HLGroupID line_hl_group; HLGroupID cursorline_hl_group; String conceal; + String conceal_lines; Boolean spell; Boolean ui_watched; Boolean undo_restore; |