From 718896032196b51684926039746f9288750e9585 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sat, 27 Aug 2022 20:52:08 -0600 Subject: feat(colorcolchar): add the option "colorcol" to the fillchars setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option will let neovim draw a character in the colorcolumn when there is no other character occupying that spot. For example, I'm someone who likes the elegance of seeing a 1px wide line at the 80 character mark, rather than a rectangle the width of a cell at that mark. To accomplish this, I run :set colorcol=80 :set fillchars=colorcol:│ of course ':' and '.' are good ASCII alteratives. --- runtime/doc/options.txt | 5 ++++- src/nvim/buffer_defs.h | 1 + src/nvim/drawline.c | 2 ++ src/nvim/screen.c | 1 + test/functional/ui/highlight_spec.lua | 7 ++++--- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 9e396dd3e8..15de976737 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1350,7 +1350,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'colorcolumn' 'cc' string (default "") local to window 'colorcolumn' is a comma-separated list of screen columns that are - highlighted with ColorColumn |hl-ColorColumn|. Useful to align + highlighted with ColorColumn |hl-ColorColumn| and drawn using the + colocol option from 'fillchars'. Useful to align text. Will make screen redrawing slower. The screen column can be an absolute number, or a number preceded with '+' or '-', which is added to or subtracted from 'textwidth'. > @@ -2478,6 +2479,7 @@ A jump table for the options with a short description can be found at |Q_op|. diff '-' deleted lines of the 'diff' option msgsep ' ' message separator 'display' eob '~' empty lines at the end of a buffer + colorcol:c ' ' character to display in the colorcolumn Any one that is omitted will fall back to the default. For "stl" and "stlnc" the space will be used when there is highlighting, '^' or '=' @@ -2515,6 +2517,7 @@ A jump table for the options with a short description can be found at |Q_op|. fold Folded |hl-Folded| diff DiffDelete |hl-DiffDelete| eob EndOfBuffer |hl-EndOfBuffer| + colorcol:c ColorColumn |hl-ColorColumn| *'fixendofline'* *'fixeol'* *'nofixendofline'* *'nofixeol'* 'fixendofline' 'fixeol' boolean (default on) diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 58bdd2c0a8..f276ac771d 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1219,6 +1219,7 @@ struct window_S { int diff; int msgsep; int eob; + int colorcol; } w_p_fcs_chars; /* diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 9132d6666e..b97d323ef2 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2334,6 +2334,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, col_attr = cuc_attr; } else if (draw_color_col && VCOL_HLC == *color_cols) { col_attr = mc_attr; + c = wp->w_p_fcs_chars.colorcol; + schar_from_char(linebuf_char[off], c); } col_attr = hl_combine_attr(col_attr, line_attr); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 9c1064d608..eb4eef6e31 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1328,6 +1328,7 @@ char *set_chars_option(win_T *wp, char_u **varp, bool apply) { &wp->w_p_fcs_chars.diff, "diff", '-' }, { &wp->w_p_fcs_chars.msgsep, "msgsep", ' ' }, { &wp->w_p_fcs_chars.eob, "eob", '~' }, + { &wp->w_p_fcs_chars.colorcol, "colorcol", ' ' }, }; struct chars_tab lcs_tab[] = { diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 4e3d62509c..b0b2920ae9 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -856,13 +856,14 @@ describe('CursorLine and CursorLineNr highlights', function() | ]]) + command('set fillchars=colorcol:|') command('set colorcolumn=3') feed('i ') screen:expect([[ - {1:{} {7: } | + {1:{} {7:|} | "{2:a}{7:"} : {3:abc} {3:// 10;} | - {1:}} {7: } | - {5: ^ }{7: }{5: }| + {1:}} {7:|} | + {5: ^ }{7:|}{5: }| | ]]) end) -- cgit From 33c115d92a47fb62b06d27074bd7270d30c1e637 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sun, 21 Aug 2022 12:02:45 -0600 Subject: feat(colorcolchar): fix typo for colorcolchar documentation --- runtime/doc/options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 15de976737..d41f1cf1cd 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1351,7 +1351,7 @@ A jump table for the options with a short description can be found at |Q_op|. local to window 'colorcolumn' is a comma-separated list of screen columns that are highlighted with ColorColumn |hl-ColorColumn| and drawn using the - colocol option from 'fillchars'. Useful to align + "colorcol" option from 'fillchars'. Useful to align text. Will make screen redrawing slower. The screen column can be an absolute number, or a number preceded with '+' or '-', which is added to or subtracted from 'textwidth'. > -- cgit From 2a1e15d2a76d1e0a0a177d87f233e7ceecb25ade Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sun, 21 Aug 2022 12:32:25 -0600 Subject: feat(colorcolchar): rename colorcol in fillchars to colorc Rename the colorcol option in fillchars to the more terse colorc. --- runtime/doc/options.txt | 8 ++++---- src/nvim/buffer_defs.h | 2 +- src/nvim/drawline.c | 2 +- src/nvim/screen.c | 2 +- test/functional/ui/highlight_spec.lua | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d41f1cf1cd..73ab36ba0e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1351,10 +1351,10 @@ A jump table for the options with a short description can be found at |Q_op|. local to window 'colorcolumn' is a comma-separated list of screen columns that are highlighted with ColorColumn |hl-ColorColumn| and drawn using the - "colorcol" option from 'fillchars'. Useful to align - text. Will make screen redrawing slower. - The screen column can be an absolute number, or a number preceded with - '+' or '-', which is added to or subtracted from 'textwidth'. > + "colorc" option from 'fillchars'. Useful to align text. Will make + screen redrawing slower. The screen column can be an absolute number, + or a number preceded with '+' or '-', which is added to or subtracted + from 'textwidth'. > :set cc=+1 " highlight column after 'textwidth' :set cc=+1,+2,+3 " highlight three columns after 'textwidth' diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index f276ac771d..7e47496291 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1219,7 +1219,7 @@ struct window_S { int diff; int msgsep; int eob; - int colorcol; + int colorc; } w_p_fcs_chars; /* diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index b97d323ef2..85ea033eb0 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2334,7 +2334,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, col_attr = cuc_attr; } else if (draw_color_col && VCOL_HLC == *color_cols) { col_attr = mc_attr; - c = wp->w_p_fcs_chars.colorcol; + c = wp->w_p_fcs_chars.colorc; schar_from_char(linebuf_char[off], c); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index eb4eef6e31..954068a388 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1328,7 +1328,7 @@ char *set_chars_option(win_T *wp, char_u **varp, bool apply) { &wp->w_p_fcs_chars.diff, "diff", '-' }, { &wp->w_p_fcs_chars.msgsep, "msgsep", ' ' }, { &wp->w_p_fcs_chars.eob, "eob", '~' }, - { &wp->w_p_fcs_chars.colorcol, "colorcol", ' ' }, + { &wp->w_p_fcs_chars.colorc, "colorc", ' ' }, }; struct chars_tab lcs_tab[] = { diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index b0b2920ae9..87c632c6e0 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -856,7 +856,7 @@ describe('CursorLine and CursorLineNr highlights', function() | ]]) - command('set fillchars=colorcol:|') + command('set fillchars=colorc:|') command('set colorcolumn=3') feed('i ') screen:expect([[ -- cgit From f8bddb98545c09a5b861e9d4e0f4edd1e920a4b3 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 24 Aug 2022 11:41:47 -0600 Subject: feat(colorcolchar): fix highlight_spec.lua Problem was interpreting a '|' as next command, causing vim to interpret set fillchars+=colorcol:| incorrectly --- test/functional/ui/highlight_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 87c632c6e0..1cfbd09852 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -856,14 +856,14 @@ describe('CursorLine and CursorLineNr highlights', function() | ]]) - command('set fillchars=colorc:|') + command('set fillchars=colorc:.') command('set colorcolumn=3') feed('i ') screen:expect([[ - {1:{} {7:|} | + {1:{} {7:.} | "{2:a}{7:"} : {3:abc} {3:// 10;} | - {1:}} {7:|} | - {5: ^ }{7:|}{5: }| + {1:}} {7:.} | + {5: ^ }{7:.}{5: }| | ]]) end) -- cgit From de6bcd7e7b3290b6d164293f414dcc13461abdd6 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 24 Aug 2022 11:45:07 -0600 Subject: feat(colorcolchar): revert "feat: rename colorcol in fillchars to colorc" This reverts commit 234959abbfcf075cb09304b00fc391780580056d and renames the option 'colorc' -> 'colorcol' again. --- runtime/doc/options.txt | 8 ++++---- src/nvim/buffer_defs.h | 2 +- src/nvim/drawline.c | 2 +- src/nvim/screen.c | 2 +- test/functional/ui/highlight_spec.lua | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 73ab36ba0e..d41f1cf1cd 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1351,10 +1351,10 @@ A jump table for the options with a short description can be found at |Q_op|. local to window 'colorcolumn' is a comma-separated list of screen columns that are highlighted with ColorColumn |hl-ColorColumn| and drawn using the - "colorc" option from 'fillchars'. Useful to align text. Will make - screen redrawing slower. The screen column can be an absolute number, - or a number preceded with '+' or '-', which is added to or subtracted - from 'textwidth'. > + "colorcol" option from 'fillchars'. Useful to align + text. Will make screen redrawing slower. + The screen column can be an absolute number, or a number preceded with + '+' or '-', which is added to or subtracted from 'textwidth'. > :set cc=+1 " highlight column after 'textwidth' :set cc=+1,+2,+3 " highlight three columns after 'textwidth' diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 7e47496291..f276ac771d 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1219,7 +1219,7 @@ struct window_S { int diff; int msgsep; int eob; - int colorc; + int colorcol; } w_p_fcs_chars; /* diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 85ea033eb0..b97d323ef2 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2334,7 +2334,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, col_attr = cuc_attr; } else if (draw_color_col && VCOL_HLC == *color_cols) { col_attr = mc_attr; - c = wp->w_p_fcs_chars.colorc; + c = wp->w_p_fcs_chars.colorcol; schar_from_char(linebuf_char[off], c); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 954068a388..eb4eef6e31 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1328,7 +1328,7 @@ char *set_chars_option(win_T *wp, char_u **varp, bool apply) { &wp->w_p_fcs_chars.diff, "diff", '-' }, { &wp->w_p_fcs_chars.msgsep, "msgsep", ' ' }, { &wp->w_p_fcs_chars.eob, "eob", '~' }, - { &wp->w_p_fcs_chars.colorc, "colorc", ' ' }, + { &wp->w_p_fcs_chars.colorcol, "colorcol", ' ' }, }; struct chars_tab lcs_tab[] = { diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 1cfbd09852..695cdf522a 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -856,7 +856,7 @@ describe('CursorLine and CursorLineNr highlights', function() | ]]) - command('set fillchars=colorc:.') + command('set fillchars=colorcol:.') command('set colorcolumn=3') feed('i ') screen:expect([[ -- cgit From 4066fa85abef16fa23c30e94dc4d2bfb3b9c4545 Mon Sep 17 00:00:00 2001 From: Joshua Rahm Date: Sun, 28 Aug 2022 17:11:44 -0600 Subject: feat(colorcolchar): update runtime/doc/options.txt Co-authored-by: zeertzjq --- runtime/doc/options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index d41f1cf1cd..6d7c034869 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2479,7 +2479,7 @@ A jump table for the options with a short description can be found at |Q_op|. diff '-' deleted lines of the 'diff' option msgsep ' ' message separator 'display' eob '~' empty lines at the end of a buffer - colorcol:c ' ' character to display in the colorcolumn + colorcol ' ' character to display in the colorcolumn Any one that is omitted will fall back to the default. For "stl" and "stlnc" the space will be used when there is highlighting, '^' or '=' -- cgit