From d9c904f85a23a496df4eb6be42aa43f007b22d50 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 2 Feb 2023 17:47:11 +0000 Subject: feat(colorcolchar): implement 'foreground' flag This flag, denoted by an 'f', will force the character over the colorcolumn to take on the colorcolumn's highlight, discarding any highlight the character would have had otherwise. This is the inverse of the 'background' flag, where the colorcolumn will take the highlight of the character discarding any highlight it otherwise would have had. --- src/nvim/buffer_defs.h | 3 ++- src/nvim/drawline.c | 5 ++++- src/nvim/window.c | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index dfcbb28c69..5ae6f55ad8 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -94,7 +94,8 @@ typedef uint64_t disptick_T; // display tick type #include "nvim/terminal.h" typedef enum { - kColorcolBehind = 1 + kColorcolBehind = 1, + kColorcolForeground = 2, } colorcol_flags_T; // Structure to define data associated with a colorcolumn. diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index ee6af01942..031ad39f75 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2610,7 +2610,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, char_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUC), char_attr); } else if (draw_color_col && VCOL_HLC == color_cols->col) { vcol_save_attr = char_attr; - if (!(color_cols->flags & kColorcolBehind)) { + + if (color_cols->flags & kColorcolForeground) { + char_attr = hl_combine_attr(char_attr, color_cols->syn_attr); + } else if (!(color_cols->flags & kColorcolBehind)) { char_attr = hl_combine_attr(color_cols->syn_attr, char_attr); } } diff --git a/src/nvim/window.c b/src/nvim/window.c index 5e99cec015..16405f87b6 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -7498,6 +7498,10 @@ char *check_colorcolumn(win_T *wp) flags |= kColorcolBehind; break; + case 'f': + flags |= kColorcolForeground; + break; + default: return e_invarg; } -- cgit