Add support for difftastic?
difftastic is a diff tool which is aware of the semantics of the code depending on their programming language.
I was wondering if it is possible to integrate it into lazygit as a custom diff tool. I've tried adding it to lazygit config as a custom pager like this:
git:
paging:
colorArg: always
pager: difft
but I guess this is not the correct way of doing it since it prints its --help in diff section.
same issue, would love to see difftastic supported
It should be fairly easy to set up, though admittedly after a few minutes reading the docs I haven't been able to get it working. Not sure if we need a code change on the lazygit side or if it's just a matter of coming up with the right command template in the config
Not sure if we need a code change on the lazygit side or if it's just a matter of coming up with the right command template in the config
Is there a way to pass env. vars to lazygit? Does lazygit invoke git diff using some sort of os routine or does it directly use git libraries?
GIT_EXTERNAL_DIFF='difft --display inline' git diff uses difft (with paging) but GIT_EXTERNAL_DIFF='difft --display inline' lazygit does not.
btw, difft version 0.26 added a --display switch which accepts an inline value which may be more proper for lazygit since the side-by-side mode may not fit in the main pane.
Lazygit invokes git as a subprocess, and for the pager we use the GIT_PAGER env var e.g. GIT_PAGER=difft. So perhaps we could conditionally use GIT_EXTERNAL_DIFF instead of GIT_PAGER?
when I run GIT_EXTERNAL_DIFF=difft git diff in the CLI that works fine, but when I do cmd.Env = append(cmd.Env, "GIT_EXTERNAL_DIFF=difft") in pkg/gui/pty.go:53 (newPtyTask function) it appears like the regular diff mode
Any status on this?
So the difference to other tools is that difftastic is an alternative diff tool while e.g. diff-so-fancy is implemented as a pager?
Would be nice if git config --global diff.external difft would be sufficient to convince lazygit to pick it up. Might be that some heuristic or an additional switch is needed to support diff.external as well as core.pager.
It looks like lazygit currently prevents this by setting -no-ext-diff.
Any status update on this, pls?
@aruediger we can make that --no-ext-diff thing configurable. Would that suffice? Happy to accept a PR for this
@aruediger I tested your idea. Unfortunately, lazygit's hunk parsing algorithm is not compatible with difftastic's output format, even with inline display set. It results in something like this:
@PhotonQuantum Bummer. (Was just about going to look into it myself.)
@jesseduffield How hard would it be to teach lazygit to deal with difftastic's chunk format?
Fwiw: it would be great to interactively switch between various differs / pagers. Most of the time I prefer difftastic, but it would be nice to switch over to delta without leaving lazygit.
Fwiw: it would be great to interactively switch between various differs / pagers. Most of the time I prefer
difftastic, but it would be nice to switch over todeltawithout leaving lazygit.
Does that mean you have a working setup of lazygit using difftastic? Would you mind sharing your config?
People are Dming me to send them my config 😂 I was just pointing out that once we do figure out a way to integrate them, we shoud want to be able to switch on the fly. I use lazygit from neovim and the speed difference between being able to switch on the go, and closing lazygit, editing my config, and relaunching it (or potentially all of neovim) is like 1000x. So no, I do not have it working.
Here's a PR that adds support for difftastic: #2868. Testing and feedback welcome.
However, I have to say that I'm a little underwhelmed. There are a few cases occasionally where difftastic does a great job at rendering the diff; for example in go code when indentation changes, like here. However, in most cases like this I can get a very similar result from any other pager by simply hitting <c-w> to ignore whitespace. For the vast majority of my work, I still greatly prefer delta's output.
I suppose people working in other programming languages than I do might find it useful more often.
I agree with the comments above that suggest to add a keybinding to cycle through pagers. I don't want this badly enough myself to explore this any time soon, though.
Closing this as #2868 is on master now.
Do we know when this feature will be released? In other words, do we have an ETA on the next release?