From 925b87230541b4d13734712599289f9d89214f5b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 19 Mar 2021 23:17:49 +0000 Subject: [PATCH] home: git: switch to 'delta' Now that my issue with it has been resolved [1], let's switch to the more mature tool. This also solves a small issue that I had with `diff-highlight` which is that non-highlighted text should not be boldened. [1]: https://github.com/dandavison/delta/issues/544 --- home/git/default.nix | 45 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/home/git/default.nix b/home/git/default.nix index 432bf60..8603022 100644 --- a/home/git/default.nix +++ b/home/git/default.nix @@ -3,7 +3,6 @@ let cfg = config.my.home.git; inherit (lib.my) mkMailAddress; - diff-highlight = "${pkgs.gitAndTools.gitFull}/share/git/contrib/diff-highlight/diff-highlight"; in { options.my.home.git = with lib.my; { @@ -40,6 +39,33 @@ in lfs.enable = true; + delta = { + enable = true; + + options = { + features = "diff-highlight decorations"; + + # Less jarring style for `diff-highlight` emulation + diff-highlight = { + minus-style = "red"; + minus-non-emph-style = "red"; + minus-emph-style = "bold red 52"; + + plus-style = "green"; + plus-non-emph-style = "green"; + plus-emph-style = "bold green 22"; + + whitespace-error-style = "reverse red"; + }; + + # Personal preference for easier reading + decorations = { + keep-plus-minus-markers = true; + paging = "always"; + }; + }; + }; + # There's more extraConfig = { # Makes it a bit more readable @@ -73,13 +99,6 @@ in whitespace = "red reverse"; }; - "color.diff-highlight" = { - oldNormal = "red bold"; - oldHighlight = "red bold 52"; - newNormal = "green bold"; - newHighlight = "green bold 22"; - }; - commit = { # Show my changes when writing the message verbose = true; @@ -100,16 +119,6 @@ in defaultBranch = "main"; }; - interactive = { - diffFilter = "${diff-highlight}"; - }; - - pager = { - diff = "${diff-highlight} | less"; - log = "${diff-highlight} | less"; - show = "${diff-highlight} | less"; - }; - pull = { # Avoid useless merge commits rebase = true;