aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Rodas <marsam@users.noreply.github.com>2020-04-26 04:20:00 -0500
committerRobert Helgesson <robert@rycee.net>2020-05-05 00:12:58 +0200
commitcba7b6ee6e056421f862b008b45f1ff9cc2e7252 (patch)
treec7b7817d7e600f806874bd03e856d88e0707f999
parent03b4f81679456dc565722b38b18c27911b135d66 (diff)
git: add basic support for delta
PR #1198
-rw-r--r--modules/misc/news.nix10
-rw-r--r--modules/programs/git.nix29
-rw-r--r--tests/modules/programs/git/git-expected.conf6
-rw-r--r--tests/modules/programs/git/git.nix6
4 files changed, 51 insertions, 0 deletions
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 9cfdb572eaf..539c5affe00 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1503,6 +1503,16 @@ in
A new module is available: 'programs.aria2'
'';
}
+
+ {
+ time = "2020-05-04T21:19:43+00:00";
+ condition = config.programs.git.enable;
+ message = ''
+ The Git module now supports the 'delta' syntax highlighter.
+
+ It can be enabled through the option 'programs.git.delta.enable'.
+ '';
+ }
];
};
}
diff --git a/modules/programs/git.nix b/modules/programs/git.nix
index 28f977894fc..ec2402f11f8 100644
--- a/modules/programs/git.nix
+++ b/modules/programs/git.nix
@@ -215,6 +215,24 @@ in {
'';
};
};
+
+ delta = {
+ enable = mkEnableOption "" // {
+ description = ''
+ Whether to enable the <command>delta</command> syntax highlighter.
+ See <link xlink:href="https://github.com/dandavison/delta" />.
+ '';
+ };
+
+ options = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "--dark" ];
+ description = ''
+ Extra command line options given to delta.
+ '';
+ };
+ };
};
};
@@ -309,5 +327,16 @@ in {
([ "git-lfs" "smudge" ] ++ skipArg ++ [ "--" "%f" ]);
};
})
+
+ (mkIf cfg.delta.enable {
+ programs.git.iniContent = let
+ deltaArgs = [ "${pkgs.gitAndTools.delta}/bin/delta" ]
+ ++ cfg.delta.options;
+ in {
+ core.pager = concatStringsSep " " deltaArgs;
+ interactive.diffFilter =
+ concatStringsSep " " (deltaArgs ++ [ "--color-only" ]);
+ };
+ })
]);
}
diff --git a/tests/modules/programs/git/git-expected.conf b/tests/modules/programs/git/git-expected.conf
index 45ba08db371..a4457adfabb 100644
--- a/tests/modules/programs/git/git-expected.conf
+++ b/tests/modules/programs/git/git-expected.conf
@@ -6,6 +6,9 @@
[commit]
gpgSign = true
+[core]
+ pager = "@deltaCommand@ --dark"
+
[extra]
boolean = true
integer = 38
@@ -28,6 +31,9 @@
[gpg]
program = "path-to-gpg"
+[interactive]
+ diffFilter = "@deltaCommand@ --dark --color-only"
+
[user]
email = "user@example.org"
name = "John Doe"
diff --git a/tests/modules/programs/git/git.nix b/tests/modules/programs/git/git.nix
index d3c586fec58..54e3c79b43d 100644
--- a/tests/modules/programs/git/git.nix
+++ b/tests/modules/programs/git/git.nix
@@ -15,6 +15,8 @@ let
pkgs.substituteAll {
src = path;
+ deltaCommand = "${pkgs.gitAndTools.delta}/bin/delta";
+
git_include_path = pkgs.writeText "contents"
(builtins.readFile ./git-expected-include.conf);
};
@@ -56,6 +58,10 @@ in {
userEmail = "user@example.org";
userName = "John Doe";
lfs.enable = true;
+ delta = {
+ enable = true;
+ options = [ "--dark" ];
+ };
}
{