threads / discuss / 58139

vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449

Subject: vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449

## tl;dr

2 messages between Jul 12, 2022 and Jul 12, 2022.

replies: 1people: 2as markdown or json

Andrew Oates· Jul 12, 2022, 00:06 UTC · lore
Hi all,

I believe commit 0041797449da61f4131bb1673fa5d4c3af48240d ("vimdiff: new implementation with layout support") broke the ability to detect diff mode in a .vimrc, because it removed '-d' from the command line use to invoke vim ('&diff' evaluates to false, because diffmode isn't enabled until the commands are run, which happens _after_ vimrc is executed AFAICT). I check &diff in my vimrc to set various settings specifically when doing a diff/merge.

Just adding '-d' back breaks the layouts unfortunately. I can hack around this with a heuristic that looks for a mergetool-like invocation, but ideally there would be a way to set the canonical diff setting correctly. It may be as simple as adding some extra commands to close the extra windows opened by adding '-d'.

Thoughts?

Cheers, Andrew

Fernando Ramos· Jul 12, 2022, 05:56 UTC · re: Andrew Oates · lore

Re: vimdiff mergetool diff mode detection in vimrc broken by commit 0041797449

> I check &diff in my vimrc to set various settings specifically when doing a
> diff/merge.
Hi Andrew, could using an auto command on the "DiffUpdated" event work for you?
Example: add this to .vimrc:
    au DiffUpdated * if &diff | colorscheme darkblue | endif

This function will be executed every time "diff mode" is updated in any way and seems to work both when running vimdiff directly and when entering diff mode interactively (as it is the case now when running "git mergetool").

It has the added benefit that you can also use this same "trick" to toggle the settings off when *exiting* diff mode:

    au DiffUpdated * if !&diff | colorscheme desert | endif
Let me know if this is enough for your use case.
Thanks!

← back to recent threads