From fccfff474a8e1ce7d1495c4a17c5a47086e3e76d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Apr 2023 12:12:05 +0300 Subject: [PATCH] feat: modes.nvim --- flake.nix | 5 +++ modules/ui/default.nix | 2 + modules/ui/modes/config.nix | 20 +++++++++ modules/ui/modes/default.nix | 6 +++ modules/ui/modes/modes.nix | 0 modules/ui/notifications/default.nix | 5 +++ .../ui/notifications/nvim-notify/config.nix | 30 +++++++++++++ .../ui/notifications/nvim-notify/default.nix | 6 +++ .../notifications/nvim-notify/nvim-notify.nix | 42 +++++++++++++++++++ 9 files changed, 116 insertions(+) create mode 100644 modules/ui/modes/config.nix create mode 100644 modules/ui/modes/default.nix create mode 100644 modules/ui/modes/modes.nix create mode 100644 modules/ui/notifications/default.nix create mode 100644 modules/ui/notifications/nvim-notify/config.nix create mode 100644 modules/ui/notifications/nvim-notify/default.nix create mode 100644 modules/ui/notifications/nvim-notify/nvim-notify.nix diff --git a/flake.nix b/flake.nix index 533988c..7350421 100644 --- a/flake.nix +++ b/flake.nix @@ -429,6 +429,11 @@ flake = false; }; + modes-nvim = { + url = "github:mvllow/modes.nvim"; + flake = false; + }; + # Assistant copilot-lua = { url = "github:zbirenbaum/copilot.lua"; diff --git a/modules/ui/default.nix b/modules/ui/default.nix index 8f72316..abd2da1 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -1,5 +1,7 @@ _: { imports = [ ./noice + ./modes + ./notifications ]; } diff --git a/modules/ui/modes/config.nix b/modules/ui/modes/config.nix new file mode 100644 index 0000000..067a2e1 --- /dev/null +++ b/modules/ui/modes/config.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.ui.modes-nvim; +in { + config = mkIf cfg.enable { + vim.startPlugins = [ + "modes-nvim" + ]; + + vim.luaConfigRC.modes-nvim = nvim.dag.entryAnywhere '' + require('modes').setup() + ''; + }; +} diff --git a/modules/ui/modes/default.nix b/modules/ui/modes/default.nix new file mode 100644 index 0000000..8c668de --- /dev/null +++ b/modules/ui/modes/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./modes.nix + ./config.nix + ]; +} diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/ui/notifications/default.nix b/modules/ui/notifications/default.nix new file mode 100644 index 0000000..aa5a73b --- /dev/null +++ b/modules/ui/notifications/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./nvim-notify + ]; +} diff --git a/modules/ui/notifications/nvim-notify/config.nix b/modules/ui/notifications/nvim-notify/config.nix new file mode 100644 index 0000000..3c4b573 --- /dev/null +++ b/modules/ui/notifications/nvim-notify/config.nix @@ -0,0 +1,30 @@ +{ + 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/ui/notifications/nvim-notify/default.nix b/modules/ui/notifications/nvim-notify/default.nix new file mode 100644 index 0000000..0d4c39d --- /dev/null +++ b/modules/ui/notifications/nvim-notify/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./nvim-notify.nix + ]; +} diff --git a/modules/ui/notifications/nvim-notify/nvim-notify.nix b/modules/ui/notifications/nvim-notify/nvim-notify.nix new file mode 100644 index 0000000..d24e82d --- /dev/null +++ b/modules/ui/notifications/nvim-notify/nvim-notify.nix @@ -0,0 +1,42 @@ +{ + config, + lib, + ... +}: +with lib; +with builtins; { + 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"; + }; + }; +}