From 64f167e7c513586e5df78e576e44822f64bd9ad3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 19:02:04 +0000 Subject: [PATCH] feat(modes): custom setup opts --- modules/ui/modes/config.nix | 15 ++-------- modules/ui/modes/modes.nix | 60 +++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/modules/ui/modes/config.nix b/modules/ui/modes/config.nix index 25ee337..9f49dc4 100644 --- a/modules/ui/modes/config.nix +++ b/modules/ui/modes/config.nix @@ -4,8 +4,8 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.ui.modes-nvim; in { @@ -15,18 +15,7 @@ in { ]; vim.luaConfigRC.modes-nvim = entryAnywhere '' - require('modes').setup({ - set_cursorline = ${boolToString cfg.setCursorline}, - line_opacity = { - visual = 0, - }, - colors = { - copy = "${toString cfg.colors.copy}", - delete = "${toString cfg.colors.delete}", - insert = "${toString cfg.colors.insert}", - visual = "${toString cfg.colors.visual}", - }, - }) + require('modes').setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix index af45d30..f73a298 100644 --- a/modules/ui/modes/modes.nix +++ b/modules/ui/modes/modes.nix @@ -1,39 +1,47 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) str; + inherit (lib.types) bool str float; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.ui.modes-nvim = { enable = mkEnableOption "modes.nvim's prismatic line decorations"; - setCursorline = mkOption { - type = bool; - description = "Set a colored cursorline on current line"; - default = false; # looks ugly, disabled by default - }; - - colors = { - copy = mkOption { - type = str; - default = "#f5c359"; - description = "The #RRGGBB color code for the visual mode highlights"; + setupOpts = { + setCursorline = mkOption { + type = bool; + description = "Set a colored cursorline on current line"; + default = false; # looks ugly, disabled by default }; - delete = mkOption { - type = str; - default = "#c75c6a"; - description = "The #RRGGBB color code for the visual mode highlights"; + line_opacity = { + visual = mkOption { + type = float; + description = "Set opacity for cursorline and number background"; + default = 0.0; + }; }; - insert = mkOption { - type = str; - default = "#78ccc5"; - description = "The #RRGGBB color code for the visual mode highlights"; - }; - - visual = mkOption { - type = str; - default = "#9745be"; - description = "The #RRGGBB color code for the visual mode highlights"; + colors = mkPluginSetupOption "modes.nvim" { + copy = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#f5c359"; + }; + delete = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#c75c6a"; + }; + insert = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#78ccc5"; + }; + visual = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#9745be"; + }; }; }; };