2023-02-01 19:11:37 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
2024-03-12 00:47:12 +00:00
|
|
|
inherit (lib.options) mkOption;
|
2024-10-07 15:47:08 +00:00
|
|
|
inherit (lib.attrsets) attrNames;
|
|
|
|
inherit (lib.strings) elemAt;
|
2024-03-12 00:47:12 +00:00
|
|
|
inherit (lib.types) bool lines enum;
|
|
|
|
inherit (lib.modules) mkIf;
|
2024-09-05 18:06:24 +00:00
|
|
|
inherit (lib.nvim.dag) entryBefore;
|
2024-10-06 23:22:41 +00:00
|
|
|
inherit (lib.nvim.lua) toLuaObject;
|
2024-10-07 20:24:04 +00:00
|
|
|
|
2023-02-01 19:11:37 +00:00
|
|
|
cfg = config.vim.theme;
|
2024-07-20 08:30:48 +00:00
|
|
|
supportedThemes = import ./supported-themes.nix {
|
2024-05-23 13:51:05 +00:00
|
|
|
inherit lib config;
|
|
|
|
};
|
2023-02-01 19:11:37 +00:00
|
|
|
in {
|
|
|
|
options.vim.theme = {
|
2024-10-07 20:24:04 +00:00
|
|
|
inherit (supportedThemes.${cfg.name}) setupOpts;
|
|
|
|
|
2023-02-01 19:11:37 +00:00
|
|
|
enable = mkOption {
|
2024-03-12 00:47:12 +00:00
|
|
|
type = bool;
|
2023-04-02 16:58:57 +00:00
|
|
|
description = "Enable theming";
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
name = mkOption {
|
2024-07-20 08:30:48 +00:00
|
|
|
type = enum (attrNames supportedThemes);
|
2024-10-05 13:47:33 +00: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 19:11:37 +00:00
|
|
|
};
|
|
|
|
style = mkOption {
|
2024-07-20 08:30:48 +00:00
|
|
|
type = enum supportedThemes.${cfg.name}.styles;
|
2024-10-07 08:47:17 +00:00
|
|
|
default = elemAt supportedThemes.${cfg.name}.styles 0;
|
2023-02-01 19:11:37 +00:00
|
|
|
description = "Specific style for theme if it supports it";
|
|
|
|
};
|
2023-04-11 10:57:47 +00:00
|
|
|
transparent = mkOption {
|
2024-03-12 00:47:12 +00:00
|
|
|
type = bool;
|
2023-04-11 10:57:47 +00:00
|
|
|
default = false;
|
|
|
|
description = "Whether or not transparency should be enabled. Has no effect for themes that do not support transparency";
|
|
|
|
};
|
|
|
|
|
2023-02-01 19:11:37 +00:00
|
|
|
extraConfig = mkOption {
|
2024-03-12 00:47:12 +00:00
|
|
|
type = lines;
|
2023-02-01 19:11:37 +00:00
|
|
|
description = "Additional lua configuration to add before setup";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-10-06 23:22:41 +00:00
|
|
|
vim = let
|
|
|
|
name' =
|
|
|
|
if cfg.name == "base16"
|
|
|
|
then "base16-colorscheme"
|
|
|
|
else cfg.name;
|
|
|
|
in {
|
2024-03-12 00:47:12 +00:00
|
|
|
startPlugins = [cfg.name];
|
2024-09-05 18:06:24 +00:00
|
|
|
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
2024-10-06 23:22:41 +00:00
|
|
|
${cfg.extraConfig}
|
|
|
|
|
2024-10-07 21:03:59 +00:00
|
|
|
${
|
|
|
|
if name' != "oxocarbon"
|
|
|
|
then "require('${name'}').setup(${toLuaObject cfg.setupOpts})"
|
|
|
|
else ""
|
|
|
|
}
|
2024-10-06 23:22:41 +00:00
|
|
|
|
|
|
|
${supportedThemes.${cfg.name}.setup}
|
2024-06-14 09:17:06 +00:00
|
|
|
'';
|
2024-03-12 00:47:12 +00:00
|
|
|
};
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
}
|