mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
git: add diff-highlight diff pager option
This adds a new diff-highlight option to make use of the simple included git diff highlighter that comes with canonical git. For more info, see https://github.com/git/git/blob/master/contrib/diff-highlight/README
This commit is contained in:
parent
503af483e1
commit
43845d04f8
1 changed files with 37 additions and 3 deletions
|
@ -214,6 +214,24 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
diff-highlight = {
|
||||||
|
enable = mkEnableOption "" // {
|
||||||
|
description = ''
|
||||||
|
Enable the contrib {command}`diff-highlight` syntax highlighter.
|
||||||
|
See <https://github.com/git/git/blob/master/contrib/diff-highlight/README>,
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
pagerOpts = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
example = [ "--tabs=4" "-RFX" ];
|
||||||
|
description = ''
|
||||||
|
Arguments to be passed to {command}`less`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
difftastic = {
|
difftastic = {
|
||||||
enable = mkEnableOption "" // {
|
enable = mkEnableOption "" // {
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -360,11 +378,15 @@ in {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
assertions = [{
|
assertions = [{
|
||||||
assertion = let
|
assertion = let
|
||||||
enabled =
|
enabled = [
|
||||||
[ cfg.delta.enable cfg.diff-so-fancy.enable cfg.difftastic.enable ];
|
cfg.delta.enable
|
||||||
|
cfg.diff-so-fancy.enable
|
||||||
|
cfg.difftastic.enable
|
||||||
|
cfg.diff-highlight.enable
|
||||||
|
];
|
||||||
in count id enabled <= 1;
|
in count id enabled <= 1;
|
||||||
message =
|
message =
|
||||||
"Only one of 'programs.git.delta.enable' or 'programs.git.difftastic.enable' or 'programs.git.diff-so-fancy.enable' can be set to true at the same time.";
|
"Only one of 'programs.git.delta.enable' or 'programs.git.difftastic.enable' or 'programs.git.diff-so-fancy.enable' or 'programs.git.diff-highlight' can be set to true at the same time.";
|
||||||
}];
|
}];
|
||||||
|
|
||||||
programs.git.iniContent.user = {
|
programs.git.iniContent.user = {
|
||||||
|
@ -479,6 +501,18 @@ in {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.diff-highlight.enable {
|
||||||
|
programs.git.iniContent = let
|
||||||
|
dhCommand =
|
||||||
|
"${cfg.package}/share/git/contrib/diff-highlight/diff-highlight";
|
||||||
|
in {
|
||||||
|
core.pager = "${dhCommand} | ${getExe pkgs.less} ${
|
||||||
|
escapeShellArgs cfg.diff-highlight.pagerOpts
|
||||||
|
}";
|
||||||
|
interactive.diffFilter = dhCommand;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
(mkIf cfg.difftastic.enable {
|
(mkIf cfg.difftastic.enable {
|
||||||
home.packages = [ cfg.difftastic.package ];
|
home.packages = [ cfg.difftastic.package ];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue