[vim/vim] runtime(diff): Update default links (PR #13776)

87 views
Skip to first unread message

Evgeni Chasnovski

unread,
Dec 26, 2023, 4:02:13 AM12/26/23
to vim/vim, Subscribed

Problem: Current default links for diffAdded, diffChanged, and
diffRemoved do not address the diff nature of the filetype.

Solution: Use DiffAdd, DiffChange, and DiffDelete.


Resolves #13759. I also updated default link for diffChanged, as there is also a good DiffChange alternative.


You can view, comment on, or merge this pull request online at:

Ā Ā https://github.com/vim/vim/pull/13776

Commit Summary

  • e65c756 runtime(diff): Update default links

File Changes

(1Ā file)

Patch Links:

—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776@github.com>

Christian Brabandt

unread,
Dec 27, 2023, 12:50:56 PM12/27/23
to vim/vim, Subscribed

thanks!

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1870510377@github.com>

Christian Brabandt

unread,
Dec 27, 2023, 12:52:27 PM12/27/23
to vim/vim, Subscribed

Merged #13776 into master.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/issue_event/11346460073@github.com>

ä¾äŗ‘

unread,
Jan 2, 2024, 8:59:23 PM1/2/24
to vim/vim, Subscribed

Diff* groups are documented as diff mode things. Perhaps the documentation should be updated?

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1874764735@github.com>

Evgeni Chasnovski

unread,
Jan 3, 2024, 4:29:23 AM1/3/24
to vim/vim, Subscribed

Diff* groups are still used as diff mode things. Now they are also used as default links for diff* groups. There is no reason to document it; same as with other default links. For example, it would be strange to also document that Constant is used to display diffCommon by default.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1875069070@github.com>

ä¾äŗ‘

unread,
Jan 3, 2024, 4:49:20 AM1/3/24
to vim/vim, Subscribed

DiffAdd		Diff mode: Added line. |diff.txt|

This sounds like it's only used in diff mode (and it was). I have a colorscheme which made this assumption and broke diff filetype highlighting.

On the other hand, Constant isn't tagged. It's below "group-name" rather than "hl-XXX". If you compare the two parts of the documentation, it's clear that "hl-XXX" part intends for Vim's interface, while the "group-name" one intends for filetype syntax definition.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1875095689@github.com>

Christian Brabandt

unread,
Jan 3, 2024, 10:11:18 AM1/3/24
to vim/vim, Subscribed

DiffAdd Diff mode: Added line. |diff.txt|

So DiffAdd is now used for Diff mode as well as for diff filetypes to mark lines that will be added. Similar for DiffDelete and Diffchanged. It seems similar enough, that I did not think documentation should be necessary. So how about the following then:

diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 040780b35..b96978a3c 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5383,11 +5383,11 @@ CursorLine      Screen line that the cursor is in when 'cursorline' is set.
                                                        *hl-Directory*
 Directory      Directory names (and other special names in listings).
                                                        *hl-DiffAdd*
-DiffAdd                Diff mode: Added line. |diff.txt|
+DiffAdd                Diff mode and diff filetype: Added line. |diff.txt|
                                                        *hl-DiffChange*
-DiffChange     Diff mode: Changed line. |diff.txt|
+DiffChange     Diff mode and diff filetype: Changed line. |diff.txt|
                                                        *hl-DiffDelete*
-DiffDelete     Diff mode: Deleted line. |diff.txt|
+DiffDelete     Diff mode and diff filetype: Deleted line. |diff.txt|
                                                        *hl-DiffText*
 DiffText       Diff mode: Changed text within a changed line. |diff.txt|
                                                        *hl-EndOfBuffer*

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1875524862@github.com>

Evgeni Chasnovski

unread,
Jan 3, 2024, 10:25:45 AM1/3/24
to vim/vim, Subscribed

@chrisbra, adding information about default links is a bit misleading. The groups in 'diff' filetype are diffAdded, diffRemoved, and diffChanged; these are actually used and not DiffAdd, DiffDelete, DiffChange.

It might be better to document diff* groups directly. For example, by adding *ft-diff-syntax* in 'doc/syntax.txt', similar to *ft-tex-syntax*.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1875546033@github.com>

Christian Brabandt

unread,
Jan 3, 2024, 10:34:41 AM1/3/24
to vim/vim, Subscribed

I see. I'll add something later

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1875559052@github.com>

Yee Cheng Chin

unread,
Jan 3, 2024, 8:32:20 PM1/3/24
to vim/vim, Subscribed

This sounds like it's only used in diff mode (and it was). I have a colorscheme which made this assumption and broke diff filetype highlighting.

Just out of curiosity why would this change break diff filetype highlighting? Just the colors chosen doesn't match?

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1876188862@github.com>

ä¾äŗ‘

unread,
Jan 3, 2024, 8:36:35 PM1/3/24
to vim/vim, Subscribed

Just out of curiosity why would this change break diff filetype highlighting? Just the colors chosen don't match?

In diff mode, DiffRemoved never has useful text (they are all ----) so I made a dimmed color that was very similar to the background.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1876191186@github.com>

Romain Lafourcade

unread,
Jan 4, 2024, 11:27:00 AM1/4/24
to vim/vim, Subscribed

This is a mistake.

DiffAdd and friends are use in diff "mode".

DiffAdded and friends are used in buffers with the diff filetype (patches, etc) and git commits when you set up Git to show diffs in that context.

Those are two different usages that require different stylings.

Here is a file with the diff filetype before this change:

Capture.d.ecran.2024-01-04.a.16.41.25.png (view on web)

where everything is smooth and readable.

Here is the same file, after this change:

Capture.d.ecran.2024-01-04.a.16.42.27.png (view on web)

where everything is noisy.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877390894@github.com>

D. Ben Knoble

unread,
Jan 4, 2024, 11:38:13 AM1/4/24
to vim/vim, Subscribed

Possible problems were mentioned: #13759 (comment)

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877411793@github.com>

Christian Clason

unread,
Jan 4, 2024, 11:59:45 AM1/4/24
to vim/vim, Subscribed

This is just about the default link; colorschemes can (and should) still style these however they wish.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877448318@github.com>

Evgeni Chasnovski

unread,
Jan 4, 2024, 12:19:03 PM1/4/24
to vim/vim, Subscribed

Those are two different usages that require different stylings.

Nobody argues against that. The question is about default links for diff* highlight groups which would with higher probability result into what is usually considered "diff colors": green for diffAdded, red for diffRemoved, not green and not red for DiffChanged.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877479526@github.com>

Christian Brabandt

unread,
Jan 4, 2024, 3:26:19 PM1/4/24
to vim/vim, Subscribed

It's true, the new default looks noisy. Not sure if we should make all color scheme authors additional work to fix this issue on their side.
Can we find a better default? that also fixes #13759 ? I am open to suggestions.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877715680@github.com>

Christian Clason

unread,
Jan 4, 2024, 3:31:15 PM1/4/24
to vim/vim, Subscribed

Note that not having these links added more work for other colorscheme authors. No matter what you pick, it will be bad for some and better for others. If you want to be objective, you would need to count how many colorschemes (that do not set these directly -- which professional colorschemes should) profit from each default.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877721070@github.com>

Christian Brabandt

unread,
Jan 4, 2024, 3:55:01 PM1/4/24
to vim/vim, Subscribed

Yeah also true. Whatever you do, you will choice wrong šŸ™ˆ

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1877747161@github.com>

Shane-XB-Qian

unread,
Jan 4, 2024, 10:35:42 PM1/4/24
to vim/vim, Subscribed

really? if you are willing to listen, the solution had emphasis many times: Not `fixing something while break something`, bram chose compatible more than feature, and was Not so easy to break the used `default`, but you chose the work style like neovim.

--
shane.xb.qian

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878077285@github.com>

zeertzjq

unread,
Jan 4, 2024, 10:47:19 PM1/4/24
to vim/vim, Subscribed

Hmm, maybe it's better to just set these to green and red directly instead of linking them to some other groups? That may achieve the intended purpose for this PR better.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878083135@github.com>

Maxim Kim

unread,
Jan 4, 2024, 11:01:12 PM1/4/24
to vim/vim, Subscribed

Hmm, maybe it's better to just set these to green and red directly instead of linking them to some other groups? That may achieve the intended purpose for this PR better than relying on assumptions about colorschemes.

FWIW, we can update bundled colorschemes and set greenish/reddish colors to diffAdded/diffRemoved.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878090268@github.com>

Romain Lafourcade

unread,
Jan 5, 2024, 2:33:53 AM1/5/24
to vim/vim, Subscribed

OK, let's rewind a little to the initial issue.

This is how the diff syntax looks in the following environment, which has been more or less the baseline for decades: 16 colors $TERM, default xterm palette, default colorscheme.

Capture.d.ecran.2024-01-04.a.19.22.53.png (view on web)

That is rather obviously bad, if only because diffRemoved and diffChanged have the same color. Can we do better?

Yes we can, and it is easy to do it without breaking anything: specify diffAdded, diffChanged, and diffRemoved explicitly in $VIMRUNTIME/syntax/syncolor.vim:

Capture.d.ecran.2024-01-05.a.08.24.35.png (view on web)
  • The highlight groups in diff files have a nice semantically correct default in default,
  • colorscheme authors and users can override them how they want,
  • no one's setup is broken.

Now that we have seen the screenshot above, does the crap below still looks like a solution to anyone?

Capture.d.ecran.2024-01-04.a.19.25.14.png (view on web)

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878248082@github.com>

Christian Brabandt

unread,
Jan 5, 2024, 2:39:41 AM1/5/24
to vim/vim, Subscribed

really? if you are willing to listen, the solution had emphasis many times: Not fixing something while break something, bram chose compatible more than feature, and was Not so easy to break the used default, but you chose the work style like neovim.

Wow, thank you for this constructive feedback

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878252864@github.com>

Christian Brabandt

unread,
Jan 5, 2024, 2:41:18 AM1/5/24
to vim/vim, Subscribed

Yes we can, and it is easy to do it without breaking anything: specify diffAdded, diffChanged, and diffRemoved explicitly in $VIMRUNTIME/syntax/syncolor.vim

So can you prepare a PR for this then?

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878254214@github.com>

Romain Lafourcade

unread,
Jan 5, 2024, 2:53:12 AM1/5/24
to vim/vim, Subscribed

Yes, I can do it tonight (Europe/Paris time).

red for diffRemoved and darkgreen for diffAdded are a no-brainer, but feel free to suggest alternatives to blue for diffChanged in the mean time.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878264244@github.com>

Shane-XB-Qian

unread,
Jan 5, 2024, 2:54:49 AM1/5/24
to vim/vim, Subscribed

thanks, since you are saying you are `open to suggestions`, and I think most people do not like his/her/their (a people) `default` or used setup was becoming sick at next day wake up, so sorry my/this crap again. no offensive.

--
shane.xb.qian

—
Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1878265687@github.com>

Gary Johnson

unread,
Jan 6, 2024, 4:55:06 AM1/6/24
to reply+ACY5DGAEAP6SJX52SL...@reply.github.com, vim...@googlegroups.com
On 2024-01-04, Christian Brabandt wrote:
> Yeah also true. Whatever you do, you will choice wrong šŸ™ˆ

I hadn't followed this discussion until just now when I did a git
commit and looked at the diff section. It is butt ugly and
unreadable.

I use Vim to look at diffs daily, mostly in diff mode but often to
look at patches. I have never run into any problems with the
previous defaults.

If some new application needs some new diff color thingy then add
something, but retain the existing defaults and don't make drastic
changes to defaults that had been working fine.

Regards,
Gary

vim-dev ML

unread,
Jan 6, 2024, 4:55:27 AM1/6/24
to vim/vim, vim-dev ML, Your activity

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13776/c1879620106@github.com>

Christian Brabandt

unread,
Jan 6, 2024, 5:04:54 AM1/6/24
to vim/vim, vim-dev ML, Comment

Yeah, I'll try to be more careful next time. Sorry for this. Hopefully we can improve this again.

—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879622990@github.com>

Evgeni Chasnovski

unread,
Jan 6, 2024, 6:07:17 AM1/6/24
to vim/vim, vim-dev ML, Comment

I have never run into any problems with the
previous defaults.

... but retain the existing defaults and don't make drastic


changes to defaults that had been working fine.

Having working fine for you doesn't necessarily mean that it is a proper choice of default links. Having default highlighting with quite low probability of being green-ish and red-ish is a bit odd based on establied UI colors.

If some new application needs some new diff color thingy then add

something...

Same goes for users which care about their diff colors.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879638685@github.com>

Shane-XB-Qian

unread,
Jan 6, 2024, 7:09:20 AM1/6/24
to vim/vim, vim-dev ML, Comment

I have never run into any problems with the
previous defaults.
... but retain the existing defaults and don't make drastic
changes to defaults that had been working fine.

Having working fine for you doesn't necessarily mean that it is a proper choice of default links.

crap? it had been proper 20 years (#13700 (comment)), now you are saying it's not proper? where were those tens of thousands of Vimer in that 20 years hiding, no one complain? // since IF the work looked like was basing on 'complain'.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879659257@github.com>

Christian Clason

unread,
Jan 6, 2024, 7:13:28 AM1/6/24
to vim/vim, vim-dev ML, Comment

You are welcome to disagree, but please stay civil.

where were those tens of thousands of Vimer in that 20 years hiding

Probably just setting these groups explicitly in their (personal and plugin) colorschemes.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879660158@github.com>

Shane-XB-Qian

unread,
Jan 6, 2024, 7:17:29 AM1/6/24
to vim/vim, vim-dev ML, Comment

what is 'misleading'? that is the misleading.
if you thought it's not proper, should complain it at the beginning (like me "complain" vim9 script #13769) or when it still had chance, though i know it is still difficult, but later 20 years and after 3 major (v7/v8/v9) release, you want to break whole/most Vimer used way?

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879660915@github.com>

Christian Clason

unread,
Jan 6, 2024, 7:18:26 AM1/6/24
to vim/vim, vim-dev ML, Comment

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879661482@github.com>

Shane-XB-Qian

unread,
Jan 6, 2024, 7:39:57 AM1/6/24
to vim/vim, vim-dev ML, Comment

please help official vim keep consistent, thanks.
// as for this ticket itself, #13776 (comment) had answer it.
// please revert this change, or @romainl #13776 (comment)

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879669659@github.com>

Christian Brabandt

unread,
Jan 6, 2024, 8:04:20 AM1/6/24
to vim/vim, vim-dev ML, Comment

@Shane-XB-Qian can you please calm down a bit?

Please let's all stay civil, it doesn't help anybody to heat up this dicussion further. Let's see if we can fix this problem. I see @romainl already working on a fix. So let's be nice, test the suggested changes (once they are ready) give feedback and if it's fine, I'll merge it.

Hope this is plan.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879676544@github.com>

Romain Lafourcade

unread,
Jan 6, 2024, 8:07:49 AM1/6/24
to vim/vim, vim-dev ML, Comment

@chrisbra I just submitted my idea of a fix for a) the original issue, and b) its original fix.

—
Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879677576@github.com>

Shane-XB-Qian

unread,
Jan 6, 2024, 8:11:56 AM1/6/24
to vim/vim, vim-dev ML, Comment

@chrisbra i am cool (tempeture 7ā„ƒ) , just worried you were mislead-ed.
@romainl thanks.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/13776/c1879683062@github.com>

Reply all
Reply to author
Forward
0 new messages