colorschemes/tokyonight: switch to mkNeovimPlugin

This commit is contained in:
Gaetan Lepage 2024-04-15 23:49:04 +02:00 committed by Gaétan Lepage
parent d5a309286d
commit 4662a06f4e
2 changed files with 145 additions and 92 deletions

View file

@ -1,89 +1,141 @@
{
lib,
helpers,
config,
pkgs,
config,
...
}:
with lib; let
cfg = config.colorschemes.tokyonight;
in {
options = {
colorschemes.tokyonight = {
enable = mkEnableOption "tokyonight";
package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim;
style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] "Theme style";
terminalColors =
helpers.defaultNullOpts.mkBool true
"Configure the colors used when opening a :terminal in Neovim";
transparent = helpers.defaultNullOpts.mkBool false "disable setting the background color";
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "tokyonight";
isColorscheme = true;
originalName = "tokyonight.nvim";
defaultPackage = pkgs.vimPlugins.tokyonight-nvim;
maintainers = [maintainers.GaetanLepage];
# TODO introduced 2024-04-15: remove 2024-06-15
optionsRenamedToSettings = [
"style"
"transparent"
"terminalColors"
["styles" "comments"]
["styles" "keywords"]
["styles" "functions"]
["styles" "variables"]
["styles" "sidebars"]
["styles" "floats"]
"sidebars"
"dayBrightness"
"hideInactiveStatusline"
"dimInactive"
"lualineBold"
"onColors"
"onHighlights"
];
settingsOptions = {
style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] ''
The theme comes in three styles, `storm`, a darker variant `night` and `day`.
'';
light_style = helpers.defaultNullOpts.mkStr "day" ''
The theme to use when the background is set to `light`.
'';
transparent = helpers.defaultNullOpts.mkBool false ''
Disable setting the background color.
'';
terminal_colors = helpers.defaultNullOpts.mkBool true ''
Configure the colors used when opening a :terminal in Neovim
'';
styles = let
mkBackgroundStyle = name:
helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"]
"Background style for ${name}";
in {
comments =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define comments highlight properties";
keywords =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define keywords highlight properties";
functions =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define functions highlight properties";
variables =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define variables highlight properties";
comments = helpers.defaultNullOpts.mkHighlight "{italic = true;}" "" ''
Define comments highlight properties.
'';
keywords = helpers.defaultNullOpts.mkHighlight "{italic = true;}" "" ''
Define keywords highlight properties.
'';
functions = helpers.defaultNullOpts.mkHighlight "{}" "" ''
Define functions highlight properties.
'';
variables = helpers.defaultNullOpts.mkHighlight "{}" "" ''
Define variables highlight properties.
'';
sidebars = mkBackgroundStyle "sidebars";
floats = mkBackgroundStyle "floats";
};
sidebars =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["qf" "help"]''
"Set a darker background on sidebar-like windows";
dayBrightness =
helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3"
"Adjusts the brightness of the colors of the **Day** style";
hideInactiveStatusline =
helpers.defaultNullOpts.mkBool false
"Enabling this option will hide inactive statuslines and replace them with a thin border";
dimInactive = helpers.defaultNullOpts.mkBool false "dims inactive windows";
lualineBold =
helpers.defaultNullOpts.mkBool false
"When true, section headers in the lualine theme will be bold";
onColors =
helpers.defaultNullOpts.mkLuaFn "function(colors) end"
''
sidebars = helpers.defaultNullOpts.mkListOf types.str ''["qf" "help"]'' ''
Set a darker background on sidebar-like windows.
'';
day_brightness = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3" ''
Adjusts the brightness of the colors of the **Day** style.
Number between 0 and 1, from dull to vibrant colors.
'';
hide_inactive_statusline = helpers.defaultNullOpts.mkBool false ''
Enabling this option will hide inactive statuslines and replace them with a thin border instead.
Should work with the standard **StatusLine** and **LuaLine**.
'';
dim_inactive = helpers.defaultNullOpts.mkBool false ''
Dims inactive windows.
'';
lualine_bold = helpers.defaultNullOpts.mkBool false ''
When true, section headers in the lualine theme will be bold.
'';
on_colors = helpers.defaultNullOpts.mkLuaFn "function(colors) end" ''
Override specific color groups to use other groups or a hex color.
function will be called with a ColorScheme table.
Function will be called with a `ColorScheme` table.
`@param colors ColorScheme`
'';
onHighlights =
helpers.defaultNullOpts.mkLuaFn "function(highlights, colors) end"
''
on_highlights = helpers.defaultNullOpts.mkLuaFn "function(highlights, colors) end" ''
Override specific highlights to use other groups or a hex color.
function will be called with a Highlights and ColorScheme table
Function will be called with a `Highlights` and `ColorScheme` table.
`@param highlights Highlights`
`@param colors ColorScheme`
'';
};
settingsExample = {
style = "storm";
light_style = "day";
transparent = false;
terminal_colors = true;
styles = {
comments.italic = true;
keywords.italic = true;
functions = {};
variables = {};
sidebars = "dark";
floats = "dark";
};
config = mkIf cfg.enable {
colorscheme = "tokyonight";
extraPlugins = [cfg.package];
opts.termguicolors = true;
extraConfigLuaPre = let
setupOptions = with cfg; {
inherit (cfg) style transparent styles sidebars;
terminal_colors = terminalColors;
hide_inactive_statusline = hideInactiveStatusline;
dim_inactive = dimInactive;
lualine_bold = lualineBold;
day_brightness = dayBrightness;
on_colors = onColors;
on_highlights = onHighlights;
sidebars = ["qf" "vista_kind" "terminal" "packer"];
day_brightness = 0.3;
hide_inactive_statusline = false;
dim_inactive = false;
lualine_bold = false;
on_colors = "function(colors) end";
on_highlights = "function(highlights, colors) end";
};
in ''
require("tokyonight").setup(${helpers.toLuaObject setupOptions})
'';
extraConfig = cfg: {
opts.termguicolors = mkDefault true;
};
}

View file

@ -7,26 +7,27 @@
colorschemes.tokyonight = {
enable = true;
settings = {
style = "storm";
# Not implemented
# lightStyle = "day";
light_style = "day";
transparent = false;
terminalColors = true;
terminal_colors = true;
styles = {
comments = {italic = true;};
keywords = {italic = true;};
comments.italic = true;
keywords.italic = true;
functions = {};
variables = {};
sidebars = "dark";
floats = "dark";
};
sidebars = ["qf" "help"];
dayBrightness = 0.3;
hideInactiveStatusline = false;
dimInactive = false;
lualineBold = false;
onColors = "function(colors) end";
onHighlights = "function(highlights, colors) end";
day_brightness = 0.3;
hide_inactive_statusline = false;
dim_inactive = false;
lualine_bold = false;
on_colors = "function(colors) end";
on_highlights = "function(highlights, colors) end";
};
};
};
}