aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/extmark.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-02-20 21:47:12 +0800
committerGitHub <noreply@github.com>2025-02-20 21:47:12 +0800
commit51cf84daf9612574978731e66db45a52136b8899 (patch)
tree5ac6f72c40e5219356ac198e1c20ca4df55354cf /src/nvim/api/extmark.c
parent574ea6a1911b740bb611f0b658a83f606b6837bc (diff)
downloadrneovim-51cf84daf9612574978731e66db45a52136b8899.tar.gz
rneovim-51cf84daf9612574978731e66db45a52136b8899.tar.bz2
rneovim-51cf84daf9612574978731e66db45a52136b8899.zip
feat(marks): virtual lines support horizontal scrolling (#32497)
Add a new field `virt_lines_overflow` that enables horizontal scrolling for virtual lines when set to "scroll".
Diffstat (limited to 'src/nvim/api/extmark.c')
-rw-r--r--src/nvim/api/extmark.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 2cf9221e52..ef09dbb0aa 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -448,7 +448,11 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// - virt_lines_leftcol: Place virtual lines in the leftmost
/// column of the window, bypassing
/// sign and number columns.
-///
+/// - virt_lines_overflow: controls how to handle virtual lines wider
+/// than the window. Currently takes the one of the following values:
+/// - "trunc": truncate virtual lines on the right (default).
+/// - "scroll": virtual lines can scroll horizontally with 'nowrap',
+/// otherwise the same as "trunc".
/// - ephemeral : for use with |nvim_set_decoration_provider()|
/// callbacks. The mark will only be used for the current
/// redraw cycle, and not be permantently stored in the
@@ -669,7 +673,17 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
}
}
- bool virt_lines_leftcol = opts->virt_lines_leftcol;
+ int virt_lines_flags = opts->virt_lines_leftcol ? kVLLeftcol : 0;
+ if (HAS_KEY(opts, set_extmark, virt_lines_overflow)) {
+ String str = opts->virt_lines_overflow;
+ if (strequal("scroll", str.data)) {
+ virt_lines_flags |= kVLScroll;
+ } else if (!strequal("trunc", str.data)) {
+ VALIDATE_S(false, "virt_lines_overflow", str.data, {
+ goto error;
+ });
+ }
+ }
if (HAS_KEY(opts, set_extmark, virt_lines)) {
Array a = opts->virt_lines;
@@ -679,7 +693,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
});
int dummig;
VirtText jtem = parse_virt_text(a.items[j].data.array, err, &dummig);
- kv_push(virt_lines.data.virt_lines, ((struct virt_line){ jtem, virt_lines_leftcol }));
+ kv_push(virt_lines.data.virt_lines, ((struct virt_line){ jtem, virt_lines_flags }));
if (ERROR_SET(err)) {
goto error;
}