diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-04-15 20:57:23 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-05-01 11:48:04 +0200 |
commit | 0865f1238f9d063b70d7e2391f671f5f1125821a (patch) | |
tree | 16a901e9f6d048eabac4aaee186699044b940b63 /src/nvim/api/buffer.c | |
parent | 59eae3b38fc98ba8c14e681b6d231e9821a11d52 (diff) | |
download | rneovim-0865f1238f9d063b70d7e2391f671f5f1125821a.tar.gz rneovim-0865f1238f9d063b70d7e2391f671f5f1125821a.tar.bz2 rneovim-0865f1238f9d063b70d7e2391f671f5f1125821a.zip |
decorations: right_align and win_col
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index e79a7a2de2..cc5a62a170 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1426,6 +1426,10 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, /// - "eol": right after eol character (default) /// - "overlay": display over the specified column, without /// shifting the underlying text. +/// - "right_align": display right aligned in the window. +/// - virt_text_win_col : position the virtual text at a fixed +/// window column (starting from the first +/// text column) /// - virt_text_hide : hide the virtual text when the background /// text is selected or hidden due to /// horizontal scroll 'nowrap' @@ -1574,11 +1578,22 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, decor.virt_text_pos = kVTEndOfLine; } else if (strequal("overlay", str.data)) { decor.virt_text_pos = kVTOverlay; + } else if (strequal("right_align", str.data)) { + decor.virt_text_pos = kVTRightAlign; } else { api_set_error(err, kErrorTypeValidation, "virt_text_pos: invalid value"); goto error; } + } else if (strequal("virt_text_win_col", k.data)) { + if (v->type != kObjectTypeInteger) { + api_set_error(err, kErrorTypeValidation, + "virt_text_win_col is not a Number of the correct size"); + goto error; + } + + decor.col = (int)v->data.integer; + decor.virt_text_pos = kVTWinCol; } else if (strequal("virt_text_hide", k.data)) { decor.virt_text_hide = api_object_to_bool(*v, "virt_text_hide", false, err); @@ -1673,6 +1688,14 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, col2 = 0; } + if (decor.virt_text_pos == kVTRightAlign) { + decor.col = 0; + for (size_t i = 0; i < kv_size(decor.virt_text); i++) { + decor.col += mb_string2cells((char_u *)kv_A(decor.virt_text, i).text); + } + } + + Decoration *d = NULL; if (ephemeral) { |