diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-03-19 13:48:03 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2022-03-20 18:02:41 +0100 |
commit | 6eca9b69c4a1f40f27a6b41961af787327259de8 (patch) | |
tree | 5991bdfd77a3ad463edb54e39e4ee2a7b4841d37 /src/nvim/api/extmark.c | |
parent | 463738938d2f3ec4cff6f016937c3c02daae1184 (diff) | |
download | rneovim-6eca9b69c4a1f40f27a6b41961af787327259de8.tar.gz rneovim-6eca9b69c4a1f40f27a6b41961af787327259de8.tar.bz2 rneovim-6eca9b69c4a1f40f27a6b41961af787327259de8.zip |
feat(ui): allow conceal to be defined in decorations
Unlike syntax conceal, change highlight of concealed char
Can be used in tree-sitter using "conceal" metadata.
Diffstat (limited to 'src/nvim/api/extmark.c')
-rw-r--r-- | src/nvim/api/extmark.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index c02688a815..797b64e2af 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -467,6 +467,11 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// as the mark and 'cursorline' is enabled. /// Note: ranges are unsupported and decorations are only /// applied to start_row +/// - conceal: string which should be either empty or a single +/// character. Enable concealing similar to |:syn-conceal|. +/// 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|. /// /// @param[out] err Error details, if any /// @return Id of the created/updated extmark @@ -563,6 +568,17 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } } + if (opts->conceal.type == kObjectTypeString) { + String c = opts->conceal.data.string; + decor.conceal = true; + if (c.size) { + decor.conceal_char = utf_ptr2char((const char_u *)c.data); + } + } else if (HAS_KEY(opts->conceal)) { + api_set_error(err, kErrorTypeValidation, "conceal is not a String"); + goto error; + } + if (opts->virt_text.type == kObjectTypeArray) { decor.virt_text = parse_virt_text(opts->virt_text.data.array, err, &decor.virt_text_width); |