more changes

This commit is contained in:
Charlie Root 2024-10-07 17:47:08 +02:00
parent 59b8335a26
commit c177916790
No known key found for this signature in database
2 changed files with 12 additions and 22 deletions

View file

@ -2,9 +2,10 @@
config, config,
lib, lib,
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) hasPrefix optionalString;
inherit (lib.attrsets) listToAttrs; inherit (lib.attrsets) listToAttrs;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) bool str; inherit (lib.types) bool str;
inherit (lib.nvim.types) hexColor mkPluginSetupOption; inherit (lib.nvim.types) hexColor mkPluginSetupOption;
cfg = config.vim.theme; cfg = config.vim.theme;
@ -17,7 +18,10 @@
value = mkOption { value = mkOption {
description = "The base0${n} color to use"; description = "The base0${n} color to use";
type = hexColor; type = hexColor;
default = cfg.base16-colors."base0${n}"; apply = v:
if hasPrefix "#" v
then v
else "#${v}";
}; };
}) })
numbers); numbers);
@ -174,8 +178,8 @@ in {
default = ""; default = "";
}; };
# TODO: fix these # TODO: fix these
# palette_overrides = mkOption{}; palette_overrides = mkLuaInline "{}";
# overrides = {}; overrides = mkLuaInline "{}";
dim_inactive = mkEnableOption "dim_inactive"; dim_inactive = mkEnableOption "dim_inactive";
}; };
setup = '' setup = ''

View file

@ -4,30 +4,16 @@
... ...
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames listToAttrs; inherit (lib.attrsets) attrNames;
inherit (lib.strings) elemAt hasPrefix; inherit (lib.strings) elemAt;
inherit (lib.types) bool lines enum; inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.types) hexColor;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.theme; cfg = config.vim.theme;
supportedThemes = import ./supported-themes.nix { supportedThemes = import ./supported-themes.nix {
inherit lib config; 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 { in {
options.vim.theme = { options.vim.theme = {
enable = mkOption { enable = mkOption {
@ -42,8 +28,8 @@ in {
requires all of the colors in {option}`vim.theme.base16-colors` to be set. requires all of the colors in {option}`vim.theme.base16-colors` to be set.
''; '';
}; };
setupOpts = cfg.themes.${cfg.name}.setupOpts;
themes = supportedThemes; themes = supportedThemes;
base16-colors = base16Options;
style = mkOption { style = mkOption {
type = enum supportedThemes.${cfg.name}.styles; type = enum supportedThemes.${cfg.name}.styles;