From 4d1e7bcbe681bf2983e8733dff748bdbb016166d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 27 Feb 2023 22:26:31 +0300 Subject: [PATCH] feat: apply new module format to notification plugins --- modules/notifications/default.nix | 2 +- modules/notifications/nvim-notify.nix | 34 -------------- modules/notifications/nvim-notify/config.nix | 31 +++++++++++++ modules/notifications/nvim-notify/default.nix | 6 +++ .../notifications/nvim-notify/nvim-notify.nix | 45 +++++++++++++++++++ 5 files changed, 83 insertions(+), 35 deletions(-) delete mode 100644 modules/notifications/nvim-notify.nix create mode 100644 modules/notifications/nvim-notify/config.nix create mode 100644 modules/notifications/nvim-notify/default.nix create mode 100644 modules/notifications/nvim-notify/nvim-notify.nix diff --git a/modules/notifications/default.nix b/modules/notifications/default.nix index e978f42..aa5a73b 100644 --- a/modules/notifications/default.nix +++ b/modules/notifications/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./nvim-notify.nix + ./nvim-notify ]; } diff --git a/modules/notifications/nvim-notify.nix b/modules/notifications/nvim-notify.nix deleted file mode 100644 index 777d507..0000000 --- a/modules/notifications/nvim-notify.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.notify.nvim-notify; -in { - options.vim.notify.nvim-notify = { - enable = mkEnableOption "Enable nvim-notify plugin"; - }; - - config = mkIf cfg.enable { - vim.startPlugins = ["nvim-notify"]; - - vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' - require('notify').setup { - stages = 'fade_in_slide_out', - timeout = 1000, - background_colour = '#000000', - position = 'top_right', - icons = { - ERROR = '', - WARN = '', - INFO = '', - DEBUG = '', - TRACE = '', - }, - } - ''; - }; -} diff --git a/modules/notifications/nvim-notify/config.nix b/modules/notifications/nvim-notify/config.nix new file mode 100644 index 0000000..58fb303 --- /dev/null +++ b/modules/notifications/nvim-notify/config.nix @@ -0,0 +1,31 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notify.nvim-notify; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["nvim-notify"]; + + vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' + require('notify').setup { + stages = "${cfg.stages}", + timeout = ${toString cfg.timeout}, + background_colour = "${cfg.background_colour}", + position = "${cfg.position}", + icons = { + ERROR = "${cfg.icons.ERROR}", + WARN = "${cfg.icons.WARN}", + INFO = "${cfg.icons.INFO}", + DEBUG = "${cfg.icons.DEBUG}", + TRACE = "${cfg.icons.TRACE}", + }, + + } + ''; + }; +} diff --git a/modules/notifications/nvim-notify/default.nix b/modules/notifications/nvim-notify/default.nix new file mode 100644 index 0000000..0d4c39d --- /dev/null +++ b/modules/notifications/nvim-notify/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvim-notify.nix + ]; +} diff --git a/modules/notifications/nvim-notify/nvim-notify.nix b/modules/notifications/nvim-notify/nvim-notify.nix new file mode 100644 index 0000000..8aab984 --- /dev/null +++ b/modules/notifications/nvim-notify/nvim-notify.nix @@ -0,0 +1,45 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.notify.nvim-notify; +in { + options.vim.notify.nvim-notify = { + enable = mkEnableOption "Enable nvim-notify plugin"; + stages = mkOption { + type = types.enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; + default = "fade_in_slide_out"; + description = "The stages of the notification"; + }; + timeout = mkOption { + type = types.int; + default = 1000; + description = "The timeout of the notification"; + }; + background_colour = mkOption { + type = types.str; + default = "#000000"; + description = "The background colour of the notification"; + }; + position = mkOption { + type = types.enum ["top_left" "top_right" "bottom_left" "bottom_right"]; + default = "top_right"; + description = "The position of the notification"; + }; + icons = mkOption { + type = types.attrsOf types.str; + default = { + ERROR = ""; + WARN = ""; + INFO = ""; + DEBUG = ""; + TRACE = ""; + }; + description = "The icons of the notification"; + }; + }; +}