2023-02-01 20:11:37 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 01:50:27 +01:00
|
|
|
}: let
|
2024-03-12 01:47:12 +01:00
|
|
|
inherit (lib.options) mkOption;
|
2024-10-05 15:47:33 +02:00
|
|
|
inherit (lib.attrsets) attrNames listToAttrs;
|
|
|
|
inherit (lib.strings) hasPrefix;
|
2024-03-12 01:47:12 +01:00
|
|
|
inherit (lib.types) bool lines enum;
|
|
|
|
inherit (lib.modules) mkIf;
|
2024-09-05 20:06:24 +02:00
|
|
|
inherit (lib.nvim.dag) entryBefore;
|
2024-10-05 15:47:33 +02:00
|
|
|
inherit (lib.nvim.types) hexColor;
|
2023-11-07 01:50:27 +01:00
|
|
|
|
2023-02-01 20:11:37 +01:00
|
|
|
cfg = config.vim.theme;
|
2024-07-20 10:30:48 +02:00
|
|
|
supportedThemes = import ./supported-themes.nix {
|
2024-05-23 15:51:05 +02:00
|
|
|
inherit lib config;
|
|
|
|
};
|
2024-10-05 15:47:33 +02:00
|
|
|
|
|
|
|
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);
|
2023-02-01 20:11:37 +01:00
|
|
|
in {
|
|
|
|
options.vim.theme = {
|
|
|
|
enable = mkOption {
|
2024-03-12 01:47:12 +01:00
|
|
|
type = bool;
|
2023-04-02 18:58:57 +02:00
|
|
|
description = "Enable theming";
|
2023-02-01 20:11:37 +01:00
|
|
|
};
|
|
|
|
name = mkOption {
|
2024-07-20 10:30:48 +02:00
|
|
|
type = enum (attrNames supportedThemes);
|
2024-10-05 15:47:33 +02:00
|
|
|
description = ''
|
|
|
|
Supported themes can be found in {file}`supportedThemes.nix`.
|
|
|
|
Setting the theme to "base16" enables base16 theming and
|
|
|
|
requires all of the colors in {option}`vim.theme.base16-colors` to be set.
|
|
|
|
'';
|
2023-02-01 20:11:37 +01:00
|
|
|
};
|
2024-10-05 15:47:33 +02:00
|
|
|
base16-colors = base16Options;
|
2023-02-01 20:11:37 +01:00
|
|
|
|
|
|
|
style = mkOption {
|
2024-07-20 10:30:48 +02:00
|
|
|
type = enum supportedThemes.${cfg.name}.styles;
|
2023-02-01 20:11:37 +01:00
|
|
|
description = "Specific style for theme if it supports it";
|
|
|
|
};
|
2023-04-11 12:57:47 +02:00
|
|
|
transparent = mkOption {
|
2024-03-12 01:47:12 +01:00
|
|
|
type = bool;
|
2023-04-11 12:57:47 +02:00
|
|
|
default = false;
|
|
|
|
description = "Whether or not transparency should be enabled. Has no effect for themes that do not support transparency";
|
|
|
|
};
|
|
|
|
|
2023-02-01 20:11:37 +01:00
|
|
|
extraConfig = mkOption {
|
2024-03-12 01:47:12 +01:00
|
|
|
type = lines;
|
2023-02-01 20:11:37 +01:00
|
|
|
description = "Additional lua configuration to add before setup";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-03-12 01:47:12 +01:00
|
|
|
vim = {
|
|
|
|
startPlugins = [cfg.name];
|
2024-09-05 20:06:24 +02:00
|
|
|
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
2024-06-14 11:17:06 +02:00
|
|
|
${cfg.extraConfig}
|
2024-10-05 15:47:33 +02:00
|
|
|
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
2024-06-14 11:17:06 +02:00
|
|
|
'';
|
2024-03-12 01:47:12 +01:00
|
|
|
};
|
2023-02-01 20:11:37 +01:00
|
|
|
};
|
|
|
|
}
|