diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-22 20:39:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 20:39:35 +0800 |
commit | f0884f21fa0cccc576f00bc18895cc80ba906031 (patch) | |
tree | c7dba1000447063288add565c94ac786aef6b274 /src | |
parent | 134b9ec483616e20d96c26fdb7ef3f3e912108a8 (diff) | |
download | rneovim-f0884f21fa0cccc576f00bc18895cc80ba906031.tar.gz rneovim-f0884f21fa0cccc576f00bc18895cc80ba906031.tar.bz2 rneovim-f0884f21fa0cccc576f00bc18895cc80ba906031.zip |
feat(extmarks): support hl_mode "combine" for inline virt_text (#24099)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/extmark.c | 13 | ||||
-rw-r--r-- | src/nvim/drawline.c | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index d79cbf7508..a101e1bbf1 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -478,7 +478,7 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// shifting the underlying text. /// - "right_align": display right aligned in the window. /// - "inline": display at the specified column, and -/// shift the buffer text to the right as needed +/// shift the buffer text to the right as needed /// - virt_text_win_col : position the virtual text at a fixed /// window column (starting from the first /// text column) @@ -490,10 +490,10 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// highlights of the text. Currently only affects /// virt_text highlights, but might affect `hl_group` /// in later versions. -/// - "replace": only show the virt_text color. This is the -/// default -/// - "combine": combine with background text color +/// - "replace": only show the virt_text color. This is the default. +/// - "combine": combine with background text color. /// - "blend": blend with background text color. +/// Not supported for "inline" virt_text. /// /// - virt_lines : virtual lines to add next to this mark /// This should be an array over lines, where each line in @@ -730,6 +730,11 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } else if (strequal("combine", str.data)) { decor.hl_mode = kHlModeCombine; } else if (strequal("blend", str.data)) { + if (decor.virt_text_pos == kVTInline) { + VALIDATE(false, "%s", "cannot use 'blend' hl_mode with inline virtual text", { + goto error; + }); + } decor.hl_mode = kHlModeBlend; } else { VALIDATE_S(false, "hl_mode", str.data, { diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 34d15d85c3..9728804ed7 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -128,6 +128,7 @@ typedef struct { VirtText virt_inline; size_t virt_inline_i; + HlMode virt_inline_hl_mode; bool reset_extra_attr; @@ -886,6 +887,7 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t } if (item->draw_col >= -1 && item->start_col == v) { wlv->virt_inline = item->decor.virt_text; + wlv->virt_inline_hl_mode = item->decor.hl_mode; item->draw_col = INT_MIN; break; } @@ -1798,7 +1800,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl if (!has_fold) { handle_inline_virtual_text(wp, &wlv, v); - if (wlv.n_extra > 0) { + if (wlv.n_extra > 0 && wlv.virt_inline_hl_mode <= kHlModeReplace) { // restore search_attr and area_attr when n_extra is down to zero // TODO(bfredl): this is ugly as fuck. look if we can do this some other way. saved_search_attr = search_attr; |