Idea: Provide a diff mode
Closed this issue · 3 comments
infinisil commented
Idea from @Lucus16, to allow using nixfmt to diff Nix files semantically. This then doesn't really require optimising for normal git line diffs if it was persistently used.
infinisil commented
E.g. changing
{
inherit foo bar;
}
to
{
inherit foo bar baz;
}
gives the diff
{
inherit
foo
bar
+ baz
;
}
dasJ commented
Does this even have to be a nixfmt feature? This is achievable with a simple wrapper consisting of diff -u <(< default.nix) <(nixfmt < default.nix)
infinisil commented
That works in some cases, but a truly semantic diff is trickier. I was recently pointed to https://github.com/Wilfred/difftastic though, which I believe does this already. And it's based on treesitter, so Nix is supported already!
I guess there's no reason this needs to be part of nixfmt in any case, so let's just close.