Skip to content
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

Idea: Provide a diff mode #135

Closed
infinisil opened this issue Oct 10, 2023 · 3 comments
Closed

Idea: Provide a diff mode #135

infinisil opened this issue Oct 10, 2023 · 3 comments

Comments

@infinisil
Copy link
Member

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
Copy link
Member Author

E.g. changing

{
  inherit foo bar;
}

to

{
  inherit foo bar baz;
}

gives the diff

 {
   inherit
     foo
     bar
+    baz
   ;
 }

@dasJ
Copy link
Member

dasJ commented Apr 2, 2024

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
Copy link
Member Author

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.

@infinisil infinisil closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@github-project-automation github-project-automation bot moved this to (unused) in Nix formatting Apr 2, 2024
@infinisil infinisil moved this from Todo to Done in Nix formatting May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants