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

View file

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