nix-community.nixvim/plugins/by-name/diffview/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

123 lines
3.7 KiB
Nix
Raw Permalink Normal View History

2023-07-06 09:01:07 +02:00
{
lib,
config,
2023-07-06 09:01:07 +02:00
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
2023-07-06 09:01:07 +02:00
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "diffview";
package = "diffview-nvim";
maintainers = [ lib.maintainers.khaneliman ];
settingsOptions = {
keymaps =
let
keymapEntryType = types.submodule {
options = {
mode = lib.mkOption {
type = types.str;
description = "Mode to bind keybinding to";
example = "n";
2024-05-05 19:39:35 +02:00
};
key = lib.mkOption {
type = types.str;
description = "Key to bind keybinding to";
example = "<tab>";
2024-05-05 19:39:35 +02:00
};
action = lib.mkOption {
type = with types; maybeRaw str;
description = "Action for keybinding";
example = lib.nixvim.nestedLiteralLua "require('diffview.actions').select_next_entry";
2024-05-05 19:39:35 +02:00
};
description = defaultNullOpts.mkStr null "Description for keybinding";
2023-07-06 09:01:07 +02:00
};
};
keymapContexts = {
disable_defaults = {
type = "bool";
description = "Disable the default keymaps";
2024-05-05 19:39:35 +02:00
};
view = "The `view` bindings are active in the diff buffers, only when the current tabpage is a Diffview";
diff1 = "Mappings in single window diff layouts";
diff2 = "Mappings in 2-way diff layouts";
diff3 = "Mappings in 3-way diff layouts";
diff4 = "Mappings in 4-way diff layouts";
file_panel = "Mappings in file panel";
file_history_panel = "Mappings in file history panel";
option_panel = "Mappings in options panel";
help_panel = "Mappings in help panel";
2023-07-06 09:01:07 +02:00
};
convertToKeybinding = attr: [
attr.mode
attr.key
attr.action
{ "desc" = attr.description; }
];
in
lib.mkOption {
type = types.submodule {
options = lib.mapAttrs (
name: desc:
if name == "disable_defaults" then
defaultNullOpts.mkBool false desc.description
else
lib.mkOption {
type = types.listOf keymapEntryType;
default = [ ];
description = "List of keybindings. ${desc}";
example = [
{
mode = "n";
key = "<tab>";
action = lib.nixvim.nestedLiteralLua "require('diffview.actions').select_next_entry";
description = "Open the diff for the next file";
}
];
}
) keymapContexts;
2023-07-06 09:01:07 +02:00
};
default = { };
description = ''
Keymap configuration for different diffview contexts.
Each keymap list will be automatically converted to the format expected by diffview.nvim.
'';
apply =
keymapCfg:
2023-07-06 09:01:07 +02:00
{
inherit (keymapCfg) disable_defaults;
}
// lib.mapAttrs (_: keyList: map convertToKeybinding keyList) (
lib.removeAttrs keymapCfg [ "disable_defaults" ]
);
2023-07-06 09:01:07 +02:00
};
};
extraConfig =
cfg:
lib.mkIf cfg.enable {
# TODO: added 2024-09-20 remove after 24.11
plugins.web-devicons = lib.mkIf (
!(
(
config.plugins.mini.enable
&& config.plugins.mini.modules ? icons
&& config.plugins.mini.mockDevIcons
)
|| (config.plugins.mini-icons.enable && config.plugins.mini-icons.mockDevIcons)
)
) { enable = lib.mkOverride 1490 true; };
2023-07-06 09:01:07 +02:00
};
# TODO: Deprecated 2025-10-04
inherit (import ./deprecations.nix { inherit lib; })
optionsRenamedToSettings
deprecateExtraOptions
;
2023-07-06 09:01:07 +02:00
}