From c177916790882fab48db01e2c809f359dffd5b71 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Mon, 7 Oct 2024 17:47:08 +0200 Subject: [PATCH] more changes --- modules/plugins/theme/supported-themes.nix | 14 +++++++++----- modules/plugins/theme/theme.nix | 20 +++----------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/modules/plugins/theme/supported-themes.nix b/modules/plugins/theme/supported-themes.nix index 6560caa..e2f3783 100644 --- a/modules/plugins/theme/supported-themes.nix +++ b/modules/plugins/theme/supported-themes.nix @@ -2,9 +2,10 @@ config, lib, }: let - inherit (lib.strings) optionalString; + inherit (lib.strings) hasPrefix optionalString; inherit (lib.attrsets) listToAttrs; inherit (lib.options) mkOption mkEnableOption; + inherit (lib.generators) mkLuaInline; inherit (lib.types) bool str; inherit (lib.nvim.types) hexColor mkPluginSetupOption; cfg = config.vim.theme; @@ -17,7 +18,10 @@ value = mkOption { description = "The base0${n} color to use"; type = hexColor; - default = cfg.base16-colors."base0${n}"; + apply = v: + if hasPrefix "#" v + then v + else "#${v}"; }; }) numbers); @@ -37,7 +41,7 @@ in { }; setup = '' -- OneDark theme - require('onedark').load() + require('onedark').load() ''; styles = ["dark" "darker" "cool" "deep" "warm" "warmer"]; }; @@ -174,8 +178,8 @@ in { default = ""; }; # TODO: fix these - # palette_overrides = mkOption{}; - # overrides = {}; + palette_overrides = mkLuaInline "{}"; + overrides = mkLuaInline "{}"; dim_inactive = mkEnableOption "dim_inactive"; }; setup = '' diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index d14e77e..06da3a1 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -4,30 +4,16 @@ ... }: let inherit (lib.options) mkOption; - inherit (lib.attrsets) attrNames listToAttrs; - inherit (lib.strings) elemAt hasPrefix; + inherit (lib.attrsets) attrNames; + inherit (lib.strings) elemAt; inherit (lib.types) bool lines enum; inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryBefore; - inherit (lib.nvim.types) hexColor; inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.theme; supportedThemes = import ./supported-themes.nix { inherit lib config; }; - numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]; - base16Options = listToAttrs (map (n: { - name = "base0${n}"; - value = mkOption { - description = "The base0${n} color to use"; - type = hexColor; - apply = v: - if hasPrefix "#" v - then v - else "#${v}"; - }; - }) - numbers); in { options.vim.theme = { enable = mkOption { @@ -42,8 +28,8 @@ in { requires all of the colors in {option}`vim.theme.base16-colors` to be set. ''; }; + setupOpts = cfg.themes.${cfg.name}.setupOpts; themes = supportedThemes; - base16-colors = base16Options; style = mkOption { type = enum supportedThemes.${cfg.name}.styles;