nixos-config/modules/nixvim/plugins/legendary-nvim.nix
Gabriel Arazas ac4b36d550
nixvim: update helper library usage
Hope nothing like this ever happen again. It's a pain to track where
errors are coming from when debugging nixpkgs modules. T_T
2024-05-26 16:03:18 +08:00

69 lines
1.9 KiB
Nix

{ config, lib, helpers, pkgs, ... }:
let
cfg = config.plugins.legendary-nvim;
mkEnableOption' = desc: lib.mkEnableOption desc // { default = true; };
in
{
options.plugins.legendary-nvim = {
enable = lib.mkEnableOption "legendary.nvim";
package = helpers.mkPluginPackageOption "legendary.nvim" pkgs.vimPlugins.legendary-nvim;
additionalSetup = mkEnableOption' "dependencies for additional features like frecency sorting";
integrations = {
nvim-tree.enable =
mkEnableOption' "integration with nvim-tree (if installed)";
smart-splits.enable =
mkEnableOption' "integration with smart-splits.nvim (if installed)";
diffview.enable =
mkEnableOption' "integration with diffview (if installed)";
};
settings = lib.mkOption {
type = lib.types.submodule {
freeformType = with lib.types; attrsOf anything;
config = lib.mkMerge [
(lib.mkIf
(
config.plugins.nvim-tree.enable && cfg.integrations.nvim-tree.enable
)
{ extensions.nvim_tree = true; })
(lib.mkIf
(
config.plugins.smart-splits.enable && cfg.integrations.smart-splits.enable
)
{
extensions.smart_splits = {
directions = [ "h" "j" "k" "l" ];
mods = { };
};
})
(lib.mkIf
(
config.plugins.diffview.enable && cfg.integrations.diffview.enable
)
{ extensions.diffview = true; })
];
};
default = { };
example = { };
};
};
config = lib.mkIf cfg.enable {
extraPlugins =
[ cfg.package ]
++ lib.optional cfg.additionalSetup pkgs.vimPlugins.sqlite-lua;
extraPackages = lib.optional cfg.additionalSetup pkgs.sqlite;
extraConfigLua = ''
require('legendary').setup(${helpers.toLuaObject cfg.settings})
'';
};
}