nix-community.nixvim/plugins/utils/notify.nix
2023-05-22 23:00:53 +02:00

76 lines
1.8 KiB
Nix

{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.notify;
helpers = import ../helpers.nix {inherit lib;};
icon = mkOption {
type = types.nullOr types.str;
default = null;
};
in {
options.plugins.notify = {
enable = mkEnableOption "notify";
package = helpers.mkPackageOption "notify" pkgs.vimPlugins.nvim-notify;
stages = mkOption {
type = types.nullOr (types.enum ["fade_in_slide_out" "fade" "slide" "static"]);
description = "Animation style";
default = null;
};
timeout = mkOption {
type = types.nullOr types.int;
description = "Default timeout for notifications";
default = null;
};
backgroundColour = mkOption {
type = types.nullOr types.str;
description = "For stages that change opacity this is treated as the highlight between the window";
default = null;
};
minimumWidth = mkOption {
type = types.nullOr types.int;
description = "Minimum width for notification windows";
default = null;
};
icons = mkOption {
type = types.nullOr (types.submodule {
options = {
error = icon;
warn = icon;
info = icon;
debug = icon;
trace = icon;
};
});
description = "Icons for the different levels";
default = {};
};
};
config = let
setupOptions = with cfg; {
inherit stages timeout;
background_colour = backgroundColour;
minimum_width = minimumWidth;
icons = with icons; {
ERROR = error;
WARN = warn;
INFO = info;
DEBUG = debug;
TRACE = trace;
};
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = ''
vim.notify = require('notify');
require('notify').setup(${helpers.toLuaObject setupOptions})
'';
};
}