diff --git a/plugins/default.nix b/plugins/default.nix index 0ae8aa8a..31908160 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -31,6 +31,7 @@ ./utils/intellitab.nix ./utils/specs.nix ./utils/mark-radar.nix + ./utils/notify.nix ./languages/treesitter.nix ./languages/nix.nix diff --git a/plugins/utils/notify.nix b/plugins/utils/notify.nix new file mode 100644 index 00000000..f58bf764 --- /dev/null +++ b/plugins/utils/notify.nix @@ -0,0 +1,73 @@ +{ pkgs, config, lib, ... }: +with lib; +let + cfg = config.programs.nixvim.plugins.notify; + helpers = import ../helpers.nix { lib = lib; }; + icon = mkOption { + type = types.nullOr types.str; + default = null; + }; +in +{ + options.programs.nixvim.plugins.notify = { + enable = mkEnableOption "Enable 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; + }; + backgroundColor = 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; { + stages = stages; + timeout = timeout; + background_color = backgroundColor; + minimum_width = minimumWidth; + icons = with icons; { + ERROR = error; + WARN = warn; + INFO = info; + DEBUG = debug; + TRACE = trace; + }; + }; + in mkIf cfg.enable { + programs.nixvim = { + extraPlugins = [ pkgs.vimPlugins.nvim-notify ]; + extraConfigLua = '' + vim.notify = require('notify'); + require('notify').setup(${helpers.toLuaObject setupOptions}) + ''; + }; + }; +}