mini/notify: set vim.notify, assert nvim-notify

This commit is contained in:
LilleAila 2025-01-19 10:15:51 +01:00
parent 22a1aef09e
commit ae81ab2c5f
No known key found for this signature in database
GPG key ID: D1ACCDCF2B9B9799
2 changed files with 35 additions and 6 deletions

View file

@ -3,17 +3,18 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkAssert;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.mini.notify; cfg = config.vim.mini.notify;
in { in {
vim = mkIf cfg.enable { vim = mkIf cfg.enable (mkAssert (!config.vim.notify.nvim-notify.enable) "Mini.notify is incompatible with nvim-notify!" {
startPlugins = ["mini-notify"]; startPlugins = ["mini-notify"];
pluginRC.mini-notify = entryAnywhere '' pluginRC.mini-notify = entryAnywhere ''
require("mini.notify").setup(${toLuaObject cfg.setupOpts}) require("mini.notify").setup(${toLuaObject cfg.setupOpts})
vim.notify = MiniNotify.make_notify(${toLuaObject cfg.notifyOpts})
''; '';
}; });
} }

View file

@ -3,11 +3,39 @@
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.types) int str;
inherit (lib.nvim.types) mkPluginSetupOption borderType;
mkNotifyOpt = name: duration: hl_group: {
duration = mkOption {
type = int;
default = duration;
description = "The duration of the ${name} notification";
};
hl_group = mkOption {
type = str;
default = hl_group;
description = "The highlight group of the ${name} notification";
};
};
in { in {
options.vim.mini.notify = { options.vim.mini.notify = {
enable = mkEnableOption "mini.notify"; enable = mkEnableOption "mini.notify";
setupOpts = mkPluginSetupOption "mini.notify" {}; setupOpts = mkPluginSetupOption "mini.notify" {
window.config.border = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "The border type for the mini.notify-notifications";
};
};
notifyOpts = mkPluginSetupOption "mini.notify notifications" {
ERROR = mkNotifyOpt "error" 5000 "DiagnosticError";
WARN = mkNotifyOpt "warn" 5000 "DiagnosticWarn";
INFO = mkNotifyOpt "info" 5000 "DiagnosticInfo";
DEBUG = mkNotifyOpt "debug" 0 "DiagnosticHint";
TRACE = mkNotifyOpt "trace" 0 "DiagnosticOk";
OFF = mkNotifyOpt "off" 0 "MiniNotifyNormal";
};
}; };
} }