-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional ability to (optionally) decorate the Colorcolumn with a character and/or custom highlighting groups #11860
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11860 +/- ##
==========================================
- Coverage 81.89% 81.87% -0.02%
==========================================
Files 164 164
Lines 193211 193169 -42
Branches 43781 43794 +13
==========================================
- Hits 158231 158162 -69
- Misses 22175 22182 +7
- Partials 12805 12825 +20
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Several months ago I created
[this](neovim/neovim#19869) pull request for
Neovim to add a new fillchar, colorcol. They recommended I create a
pull request upstream to see if there was any interest. So after a few
months, I finally got up the energy to give it a shot.
I use Vim's colorcolumn often, however, I prefer the look and feel of
more recent editors where the "color column" is just a thin line.
Highlighting a full block just feels ... inelegant. My solution to add
this to vim, is to add a new fillchar, colorcol. This char is
displayed in the colorcolumn using the colorcol highlighting. So ,for
me, where I prefer the thin line, I set colorcol to `│`, but others
may decide to set it to `┆`, `~`, or `.`, or `☃`, though I imagine
most would probably set it to some flavor of the vertical box-drawing
characters.
[...]
Using 'fillchars' for this character has one important limitation: you
can specify only one character. I wonder if that is OK or too limited.
I imagine 'colorcolumn' entries can be used for at least two purposes:
marking columns in the text (e.g. at column 10 and 40) to align things,
and for marking the right margin. Suppose someone only wants to use the
character for the right margin, since it's where text normally doesn't
show, while using a character in the middle of the text can be annoying.
We only have one highlight group: ColorColumn. That's limited as well.
Thus perhaps limiting the character is OK? On the other hand, if we
would be able to define the character for each column, then being able
to define the highlighting for each column is probably needed as well.
If no character is defined the highlight would use the background, while
with a character it would use the foreground color.
The character and the highlighting could be included in the
'colorcolumn' option value:
set colorcolumn=10//LeftCol,40//MiddleCol,75/|/RightCol
…--
A day without sunshine is like, well, night.
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
I like this idea. I thought it might be cool to have multiple colorcolumns with different highlights. One for maybe a "soft" textwidth recommendation and one for a "hard" textwidth (for example). I suspect it wont be too much trouble to implement. (Famous last words, amirite) So I'm willing to give it a shot. I assume the syntax will be something like
ofc if someone is so possessed as to use a forward-slash for the character, it would need to be escaped. I like this idea. |
I understand the concern, and I appreciate you bringing it up, a couple of things:
I'm happy to answer any more questions |
…lumn. This commit add support for a new fillchar called 'colorcol'. When colorcol is set, the colorcolumn will display that character in the colorcolumn. The default value is ' ', which results in original behavior. Likely colorcol, if set to anything at all, will be set to something like '│' or '┆' to provide a nice, thin line, but it is certainly not limited to just those. Good ascii alternatives could be ':', '.' or '~' (to match NonText). In the case of multiple colorcolumn's the character is displayed in them all. If a typed character is in the colorcolumn, then the typed character gets precedence over the colorcol char.
Color column arguments can now be configured as: <number>[/<char>[/<hlgroup>[/<flags>]]] where * <number> defines the color column as originally defined * <char> defines the character with which to fill the colorcolumn (defaults to ' ' to preserve semantics) * <hlgroup> defines the highlight group to use for that column (defaults to ColorColumn to preseve semantics) * <flags> defines additional flags for displaying the colorcolumn - has just 'b' defined, which displays the colorcolumn behind any text that goes over it. - no flags preserves semantics.
I have my doubts about trying to put all of this into one option value. It can work for maybe up to three items, but above that it quickly gets messy. And if we get more requests later it's going to be hard to extend. We could keep 'colorcolumn' simple and add a function to set more complicated configurations. Then a dictionary can be used that's easy to extend with more entries later. When using a script to set this a function will be easier to use as well. |
Hi all,
Several months ago I created this pull request for Neovim to add a new fillchar, colorcol. They recommended I create a pull request upstream to see if there was any interest. So after a few months, I finally got up the energy to give it a shot.
I use Vim's colorcolumn often, however, I prefer the look and feel of more recent editors where the "color column" is just a thin line. Highlighting a full block just feels ... inelegant. My solution to add this to vim, is to add a new fillchar, colorcol. This char is displayed in the colorcolumn using the colorcol highlighting. So ,for me, where I prefer the thin line, I set colorcol to
│
, but others may decide to set it to┆
,~
, or.
, or☃
, though I imagine most would probably set it to some flavor of the vertical box-drawing characters.Here is an exmaple of how it works with basic configuration in what I imagine will be the typical usage:
And if one is so possessed to use multiple colorcolumns with this option:
Let me know what else might me needed. I tried to add a test and follow existing conventions, but may have overlooked something. Thanks!