theme: switch to mapAttrs for setupOpts

This commit is contained in:
Charlie Root 2024-10-08 23:57:47 +02:00
parent 8f10028449
commit 7c01a7c875
No known key found for this signature in database
2 changed files with 70 additions and 67 deletions

View file

@ -3,9 +3,8 @@
lib, lib,
}: let }: let
inherit (lib.strings) hasPrefix optionalString; inherit (lib.strings) hasPrefix optionalString;
inherit (lib.attrsets) listToAttrs; inherit (lib.attrsets) genAttrs 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;
@ -85,7 +84,8 @@ in {
internal = true; internal = true;
}; };
term_colors = mkEnableOption' "term_colors"; term_colors = mkEnableOption' "term_colors";
integrations = { integrations =
{
nvimtree = { nvimtree = {
enabled = mkEnableOption' "enabled"; enabled = mkEnableOption' "enabled";
transparent_panel = mkOption { transparent_panel = mkOption {
@ -95,20 +95,6 @@ in {
show_root = mkEnableOption' "show_root"; show_root = mkEnableOption' "show_root";
}; };
hop = mkEnableOption' "hop";
gitsigns = mkEnableOption' "gitsigns";
telescope = mkEnableOption' "telescope";
treesitter = mkEnableOption' "treesitter";
treesitter_context = mkEnableOption' "treesitter_context";
ts_rainbow = mkEnableOption' "ts_rainbow";
fidget = mkEnableOption' "fidget";
alpha = mkEnableOption' "alpha";
leap = mkEnableOption' "leap";
markdown = mkEnableOption' "markdown";
noice = mkEnableOption' "noice";
# nvim-notify
notify = mkEnableOption' "notify";
which_key = mkEnableOption' "which_key";
navic = { navic = {
enabled = mkEnableOption' "enabled"; enabled = mkEnableOption' "enabled";
# lualine will set backgound to mantle # lualine will set backgound to mantle
@ -117,7 +103,22 @@ in {
default = "NONE"; default = "NONE";
}; };
}; };
}; }
// genAttrs [
"hop"
"gitsigns"
"telescope"
"treesitter"
"treesitter_context"
"ts_rainbow"
"fidget"
"alpha"
"leap"
"markdown"
"noice"
"notify"
"which_key"
] (name: mkEnableOption' name);
}; };
setup = '' setup = ''
-- Catppuccin theme -- Catppuccin theme
@ -147,18 +148,13 @@ in {
}; };
gruvbox = { gruvbox = {
setupOpts = mkPluginSetupOption "gruvbox" { setupOpts =
mkPluginSetupOption "gruvbox" {
transparent_mode = mkOption { transparent_mode = mkOption {
type = bool; type = bool;
default = cfg.transparent; default = cfg.transparent;
internal = true; internal = true;
}; };
# transparent_mode = cfg.transparent;
# add neovim terminal colors
terminal_colors = mkEnableOption' "terminal_colors";
undercurl = mkEnableOption' "undercurls";
underline = mkEnableOption' "underline";
bold = mkEnableOption' "bold";
italic = { italic = {
strings = mkEnableOption' "strings"; strings = mkEnableOption' "strings";
emphasis = mkEnableOption' "emphasis"; emphasis = mkEnableOption' "emphasis";
@ -166,12 +162,6 @@ in {
operators = mkEnableOption "operators"; operators = mkEnableOption "operators";
folds = mkEnableOption' "folds"; folds = mkEnableOption' "folds";
}; };
strikethrough = mkEnableOption' "strikethrough";
invert_selection = mkEnableOption "invert_selection";
invert_signs = mkEnableOption "invert_signs";
invert_tabline = mkEnableOption "invert_tabline";
invert_intend_guides = mkEnableOption "invert_intend_guides";
inverse = mkEnableOption' "inverse";
contrast = mkOption { contrast = mkOption {
type = str; type = str;
default = ""; default = "";
@ -179,8 +169,22 @@ in {
# TODO: fix these # TODO: fix these
# palette_overrides = mkLuaInline "{}"; # palette_overrides = mkLuaInline "{}";
# overrides = mkLuaInline "{}"; # overrides = mkLuaInline "{}";
dim_inactive = mkEnableOption "dim_inactive"; }
}; // genAttrs [
"terminal_colors"
"undercurls"
"underline"
"bold"
"strikethrough"
"inverse"
] (name: mkEnableOption' name)
// genAttrs [
"invert_selection"
"invert_signs"
"invert_tabline"
"invert_intend_guides"
"dim_inactive"
] (name: mkEnableOption name);
setup = '' setup = ''
-- Gruvbox theme -- Gruvbox theme
vim.o.background = "${cfg.style}" vim.o.background = "${cfg.style}"

View file

@ -17,7 +17,6 @@
}; };
in { in {
options.vim.theme = { options.vim.theme = {
themes = supportedThemes;
inherit (supportedThemes.${cfg.name}) setupOpts; inherit (supportedThemes.${cfg.name}) setupOpts;
enable = mkOption { enable = mkOption {