git: add basic support for delta

PR #1198
This commit is contained in:
Mario Rodas 2020-04-26 04:20:00 -05:00 committed by Robert Helgesson
parent 03b4f81679
commit cba7b6ee6e
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 51 additions and 0 deletions

View file

@ -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" ]);
};
})
]);
}