tokyonight: Refactor to use nullable options (#153)

This commit is contained in:
traxys 2023-02-01 17:17:27 +01:00 committed by GitHub
parent 247e3da2fe
commit 12bdded4db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,75 +1,56 @@
{ pkgs, config, lib, ... }: { pkgs
with lib; , config
let , lib
, ...
}@args:
with lib; let
cfg = config.colorschemes.tokyonight; cfg = config.colorschemes.tokyonight;
style = types.enum [ "storm" "night" "day" ]; helpers = import ../helpers.nix args;
helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
colorschemes.tokyonight = { colorschemes.tokyonight = {
enable = mkEnableOption "tokyonight"; enable = mkEnableOption "tokyonight";
package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim; package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim;
style = mkOption { style = helpers.defaultNullOpts.mkEnumFirstDefault [ "storm" "night" "day" ] "Theme style";
type = style; terminalColors =
default = "storm"; helpers.defaultNullOpts.mkBool true
description = "Theme style"; "Configure the colors used when opening a :terminal in Neovim";
}; transparent = helpers.defaultNullOpts.mkBool false "disable setting the background color";
terminalColors = mkOption {
type = types.bool;
default = true;
description = "Configure the colors used when opening a :terminal in Neovim";
};
transparent = mkEnableOption "disable setting the background color";
styles = styles =
let let
mkBackgroundStyle = name: mkOption { mkBackgroundStyle = name:
type = types.enum [ "dark" "transparent" "normal" ]; helpers.defaultNullOpts.mkEnumFirstDefault [ "dark" "transparent" "normal" ]
description = "Background style for ${name}"; "Background style for ${name}";
default = "dark";
};
in in
{ {
comments = mkOption { comments =
type = types.attrsOf types.anything; helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
description = "Define comments highlight properties"; "Define comments highlight properties";
default = { italic = true; }; keywords =
}; helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
keywords = mkOption { "Define keywords highlight properties";
type = types.attrsOf types.anything; functions =
description = "Define keywords highlight properties"; helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
default = { italic = true; }; "Define functions highlight properties";
}; variables =
functions = mkOption { helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
type = types.attrsOf types.anything; "Define variables highlight properties";
description = "Define functions highlight properties";
default = { };
};
variables = mkOption {
type = types.attrsOf types.anything;
description = "Define variables highlight properties";
default = { };
};
sidebars = mkBackgroundStyle "sidebars"; sidebars = mkBackgroundStyle "sidebars";
floats = mkBackgroundStyle "floats"; floats = mkBackgroundStyle "floats";
}; };
sidebars = mkOption { sidebars =
type = types.listOf types.str; helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["qf" "help"]''
default = [ "qf" "help" ]; "Set a darker background on sidebar-like windows";
description = "Set a darker background on sidebar-like windows"; dayBrightness =
example = ''["qf" "vista_kind" "terminal" "packer"]''; helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3"
}; "Adjusts the brightness of the colors of the **Day** style";
dayBrightness = mkOption {
type = types.numbers.between 0.0 1.0;
default = 0.3;
description = "Adjusts the brightness of the colors of the **Day** style";
};
hideInactiveStatusline = hideInactiveStatusline =
mkEnableOption helpers.defaultNullOpts.mkBool false
"Enabling this option will hide inactive statuslines and replace them with a thin border"; "Enabling this option will hide inactive statuslines and replace them with a thin border";
dimInactive = mkEnableOption "dims inactive windows"; dimInactive = helpers.defaultNullOpts.mkBool false "dims inactive windows";
lualineBold = lualineBold =
mkEnableOption helpers.defaultNullOpts.mkBool false
"When true, section headers in the lualine theme will be bold"; "When true, section headers in the lualine theme will be bold";
}; };
}; };