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 ''
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. 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` `@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. 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 highlights Highlights`
`@param colors ColorScheme` `@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 { sidebars = ["qf" "vista_kind" "terminal" "packer"];
colorscheme = "tokyonight"; day_brightness = 0.3;
extraPlugins = [cfg.package]; hide_inactive_statusline = false;
opts.termguicolors = true; dim_inactive = false;
extraConfigLuaPre = let lualine_bold = false;
setupOptions = with cfg; { on_colors = "function(colors) end";
inherit (cfg) style transparent styles sidebars; on_highlights = "function(highlights, colors) end";
terminal_colors = terminalColors;
hide_inactive_statusline = hideInactiveStatusline;
dim_inactive = dimInactive;
lualine_bold = lualineBold;
day_brightness = dayBrightness;
on_colors = onColors;
on_highlights = onHighlights;
}; };
in ''
require("tokyonight").setup(${helpers.toLuaObject setupOptions}) extraConfig = cfg: {
''; opts.termguicolors = mkDefault true;
}; };
} }

View file

@ -7,26 +7,27 @@
colorschemes.tokyonight = { colorschemes.tokyonight = {
enable = true; enable = true;
settings = {
style = "storm"; style = "storm";
# Not implemented light_style = "day";
# lightStyle = "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"]; sidebars = ["qf" "help"];
dayBrightness = 0.3; day_brightness = 0.3;
hideInactiveStatusline = false; hide_inactive_statusline = false;
dimInactive = false; dim_inactive = false;
lualineBold = false; lualine_bold = false;
onColors = "function(colors) end"; on_colors = "function(colors) end";
onHighlights = "function(highlights, colors) end"; on_highlights = "function(highlights, colors) end";
};
}; };
}; };
} }