plugins/undotree: switch to mkPlugin

This commit is contained in:
Gaetan Lepage 2024-01-08 14:42:01 +01:00 committed by Gaétan Lepage
parent a82b8188fd
commit 9eea1486bc

View file

@ -1,137 +1,129 @@
{ {
lib, lib,
helpers,
config,
pkgs, pkgs,
... ...
}: } @ args:
with lib; let with lib;
cfg = config.plugins.undotree; with import ../helpers.nix {inherit lib;};
in { mkPlugin args {
options = { name = "undotree";
plugins.undotree = { package = pkgs.vimPlugins.undotree;
enable = mkEnableOption "undotree"; globalPrefix = "undotree_";
package = helpers.mkPackageOption "undotree" pkgs.vimPlugins.undotree; options = {
windowLayout = mkDefaultOpt {
windowLayout = mkOption { type = types.int;
type = types.nullOr types.int; description = ''
default = null; Window layout for undotree.
description = "Window layout for undotree. Check https://github.com/mbbill/undotree/blob/master/plugin/undotree.vim#L29 for reference"; Check https://github.com/mbbill/undotree/blob/master/plugin/undotree.vim#L29 for reference
'';
}; };
shortIndicators = mkOption { shortIndicators = mkDefaultOpt {
type = types.bool; type = types.bool;
default = false; description = ''
description = "E.g. use 'd' instead of 'days'"; E.g. use 'd' instead of 'days'
Default: `false`
'';
}; };
windowWidth = mkOption { windowWidth = mkDefaultOpt {
type = types.nullOr types.int; type = types.int;
default = null;
description = "Undotree window width"; description = "Undotree window width";
}; };
diffHeight = mkOption { diffHeight = mkDefaultOpt {
type = types.nullOr types.int; type = types.int;
default = null;
description = "Undotree diff panel height"; description = "Undotree diff panel height";
}; };
autoOpenDiff = mkOption { autoOpenDiff = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Auto open diff window"; Auto open diff window
Default: `true`
'';
}; };
focusOnToggle = mkOption { focusOnToggle = mkDefaultOpt {
type = types.bool; type = types.bool;
default = false; description = ''
description = "Focus undotree after being opened"; Focus undotree after being opened
Default: `false`
'';
}; };
treeNodeShape = mkOption { treeNodeShape = mkDefaultOpt {
type = types.nullOr types.str; type = types.str;
default = null;
description = "Tree node shape"; description = "Tree node shape";
}; };
diffCommand = mkOption { diffCommand = mkDefaultOpt {
type = types.nullOr types.str; type = types.str;
default = null;
description = "Diff command"; description = "Diff command";
}; };
relativeTimestamp = mkOption { relativeTimestamp = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Use a relative timestamp"; Use a relative timestamp.
Default: `true`
'';
}; };
highlightChangedText = mkOption { highlightChangedText = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Highlight changed text"; Highlight changed text
Default: `true`
'';
}; };
highlightChangesWithSign = mkOption { highlightChangesWithSign = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Highlight changes with a sign in the gutter"; Highlight changes with a sign in the gutter
Default: `true`
'';
}; };
highlightSyntaxAdd = mkOption { highlightSyntaxAdd = mkDefaultOpt {
type = types.nullOr types.str; type = types.str;
default = null;
description = "Added lines highlight group"; description = "Added lines highlight group";
}; };
highlightSyntaxChange = mkOption { highlightSyntaxChange = mkDefaultOpt {
type = types.nullOr types.str; type = types.str;
default = null;
description = "Changed lines highlight group"; description = "Changed lines highlight group";
}; };
highlightSyntaxDel = mkOption { highlightSyntaxDel = mkDefaultOpt {
type = types.nullOr types.str; type = types.str;
default = null;
description = "Deleted lines highlight group"; description = "Deleted lines highlight group";
}; };
showHelpLine = mkOption { showHelpLine = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Show help line"; Show help line.
Default: `true`
'';
}; };
showCursorLine = mkOption { showCursorLine = mkDefaultOpt {
type = types.bool; type = types.bool;
default = true; description = ''
description = "Show cursor line"; Show cursor line
Default: `true`
'';
}; };
}; };
}; }
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
globals = {
undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout;
undotree_ShortIndicators = mkIf cfg.shortIndicators 1;
undotree_SplitWidth = mkIf (cfg.windowWidth != null) cfg.windowWidth;
undotree_DiffpanelHeight = mkIf (cfg.diffHeight != null) cfg.diffHeight;
undotree_DiffAutoOpen = mkIf (!cfg.autoOpenDiff) 0;
undotree_SetFocusWhenToggle = mkIf cfg.focusOnToggle 1;
undotree_TreeNodeShape = mkIf (cfg.treeNodeShape != null) cfg.treeNodeShape;
undotree_DiffCommand = mkIf (cfg.diffCommand != null) cfg.diffCommand;
undotree_RelativeTimestamp = mkIf (!cfg.relativeTimestamp) 0;
undotree_HighlightChangedText = mkIf (!cfg.highlightChangedText) 0;
undotree_HighlightChangedWithSign = mkIf (!cfg.highlightChangesWithSign) 0;
undotree_HighlightSyntaxAdd = mkIf (cfg.highlightSyntaxAdd != null) cfg.highlightSyntaxAdd;
undotree_HighlightSyntaxChange = mkIf (cfg.highlightSyntaxChange != null) cfg.highlightSyntaxAdd;
undotree_HighlightSyntaxDel = mkIf (cfg.highlightSyntaxDel != null) cfg.highlightSyntaxDel;
undotree_HelpLine = mkIf (!cfg.showHelpLine) 0;
undotree_CursorLine = mkIf (!cfg.showCursorLine) 0;
};
};
}