mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 02:08:40 +02:00
colorschemes/palette: switch to mkNeovimPlugin
This commit is contained in:
parent
d348bb3e03
commit
07de1fe92e
2 changed files with 83 additions and 84 deletions
|
@ -5,18 +5,34 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib;
|
||||||
cfg = config.colorschemes.palette;
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
in {
|
name = "palette";
|
||||||
meta.maintainers = [maintainers.GaetanLepage];
|
isColorscheme = true;
|
||||||
|
originalName = "palette.nvim";
|
||||||
|
defaultPackage = pkgs.vimPlugins.palette-nvim;
|
||||||
|
|
||||||
options.colorschemes.palette =
|
maintainers = [maintainers.GaetanLepage];
|
||||||
helpers.neovim-plugin.extraOptionsOptions
|
|
||||||
// {
|
|
||||||
enable = mkEnableOption "palette.nvim";
|
|
||||||
|
|
||||||
package = helpers.mkPackageOption "palette.nvim" pkgs.vimPlugins.palette-nvim;
|
extraPlugins = [
|
||||||
|
# Annoyingly, lspconfig is required, otherwise this line is breaking:
|
||||||
|
# https://github.com/roobert/palette.nvim/blob/a808c190a4f74f73782302152ebf323660d8db5f/lua/palette/init.lua#L45
|
||||||
|
# An issue has been opened upstream to warn the maintainer: https://github.com/roobert/palette.nvim/issues/2
|
||||||
|
pkgs.vimPlugins.nvim-lspconfig
|
||||||
|
];
|
||||||
|
|
||||||
|
# TODO introduced 2024-04-07: remove 2024-06-07
|
||||||
|
deprecateExtraOptions = true;
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"palettes"
|
||||||
|
"customPalettes"
|
||||||
|
"italics"
|
||||||
|
"transparentBackground"
|
||||||
|
"caching"
|
||||||
|
"cacheDir"
|
||||||
|
];
|
||||||
|
|
||||||
|
settingsOptions = {
|
||||||
palettes = {
|
palettes = {
|
||||||
main = helpers.defaultNullOpts.mkStr "dark" ''
|
main = helpers.defaultNullOpts.mkStr "dark" ''
|
||||||
Palette for the main colors.
|
Palette for the main colors.
|
||||||
|
@ -89,7 +105,7 @@ in {
|
||||||
Whether to use italics.
|
Whether to use italics.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
transparentBackground = helpers.defaultNullOpts.mkBool false ''
|
transparent_background = helpers.defaultNullOpts.mkBool false ''
|
||||||
Whether to use transparent background.
|
Whether to use transparent background.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -97,54 +113,33 @@ in {
|
||||||
Whether to enable caching.
|
Whether to enable caching.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
cacheDir =
|
cache_dir =
|
||||||
helpers.defaultNullOpts.mkStr
|
helpers.defaultNullOpts.mkStr
|
||||||
''{__raw = "vim.fn.stdpath('cache') .. '/palette'";}''
|
''{__raw = "vim.fn.stdpath('cache') .. '/palette'";}''
|
||||||
"Cache directory.";
|
"Cache directory.";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
settingsExample = {};
|
||||||
assertions =
|
|
||||||
mapAttrsToList (
|
|
||||||
name: defaultPaletteNames: let
|
|
||||||
palette = cfg.palettes.${name};
|
|
||||||
allowedPaletteNames = (attrNames cfg.customPalettes.${name}) ++ defaultPaletteNames;
|
|
||||||
in {
|
|
||||||
assertion = isString palette -> elem palette allowedPaletteNames;
|
|
||||||
message = ''
|
|
||||||
Nixvim: `colorschemes.palette.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${concatStringsSep " " allowedPaletteNames}).
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{
|
|
||||||
main = ["dark" "light"];
|
|
||||||
accent = ["pastel" "dark" "bright"];
|
|
||||||
state = ["pastel" "dark" "bright"];
|
|
||||||
};
|
|
||||||
|
|
||||||
colorscheme = "palette";
|
extraConfig = cfg: {
|
||||||
|
assertions =
|
||||||
|
mapAttrsToList (
|
||||||
|
name: defaultPaletteNames: let
|
||||||
|
customPalettesNames = attrNames cfg.settings.custom_palettes.${name};
|
||||||
|
allowedPaletteNames = customPalettesNames ++ defaultPaletteNames;
|
||||||
|
|
||||||
extraPlugins = [
|
palette = cfg.settings.palettes.${name};
|
||||||
cfg.package
|
in {
|
||||||
# Annoyingly, lspconfig is required, otherwise this line is breaking:
|
assertion = isString palette -> elem palette allowedPaletteNames;
|
||||||
# https://github.com/roobert/palette.nvim/blob/a808c190a4f74f73782302152ebf323660d8db5f/lua/palette/init.lua#L45https://github.com/roobert/palette.nvim/blob/a808c190a4f74f73782302152ebf323660d8db5f/lua/palette/init.lua#L45
|
message = ''
|
||||||
# An issue has been opened upstream to warn the maintainer: https://github.com/roobert/palette.nvim/issues/2
|
Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${concatStringsSep " " allowedPaletteNames}).
|
||||||
pkgs.vimPlugins.nvim-lspconfig
|
'';
|
||||||
];
|
}
|
||||||
|
)
|
||||||
extraConfigLuaPre = let
|
|
||||||
setupOptions = with cfg;
|
|
||||||
{
|
{
|
||||||
inherit palettes;
|
main = ["dark" "light"];
|
||||||
custom_palettes = customPalettes;
|
accent = ["pastel" "dark" "bright"];
|
||||||
inherit italics;
|
state = ["pastel" "dark" "bright"];
|
||||||
transparent_background = transparentBackground;
|
};
|
||||||
inherit caching;
|
};
|
||||||
cache_dir = cacheDir;
|
}
|
||||||
}
|
|
||||||
// cfg.extraOptions;
|
|
||||||
in ''
|
|
||||||
require('palette').setup(${helpers.toLuaObject setupOptions})
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,20 +7,22 @@
|
||||||
colorschemes.palette = {
|
colorschemes.palette = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
palettes = {
|
settings = {
|
||||||
main = "dark";
|
palettes = {
|
||||||
accent = "pastel";
|
main = "dark";
|
||||||
state = "pastel";
|
accent = "pastel";
|
||||||
|
state = "pastel";
|
||||||
|
};
|
||||||
|
custom_palettes = {
|
||||||
|
main = {};
|
||||||
|
accent = {};
|
||||||
|
state = {};
|
||||||
|
};
|
||||||
|
italics = true;
|
||||||
|
transparent_background = false;
|
||||||
|
caching = true;
|
||||||
|
cache_dir.__raw = "vim.fn.stdpath('cache') .. '/palette'";
|
||||||
};
|
};
|
||||||
customPalettes = {
|
|
||||||
main = {};
|
|
||||||
accent = {};
|
|
||||||
state = {};
|
|
||||||
};
|
|
||||||
italics = true;
|
|
||||||
transparentBackground = false;
|
|
||||||
caching = true;
|
|
||||||
cacheDir.__raw = "vim.fn.stdpath('cache') .. '/palette'";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,28 +30,30 @@
|
||||||
colorschemes.palette = {
|
colorschemes.palette = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
palettes = {
|
settings = {
|
||||||
main = "dust_dusk";
|
palettes = {
|
||||||
};
|
main = "dust_dusk";
|
||||||
|
};
|
||||||
|
|
||||||
customPalettes = {
|
custom_palettes = {
|
||||||
main = {
|
main = {
|
||||||
dust_dusk = {
|
dust_dusk = {
|
||||||
color0 = "#121527";
|
color0 = "#121527";
|
||||||
color1 = "#1A1E39";
|
color1 = "#1A1E39";
|
||||||
color2 = "#232A4D";
|
color2 = "#232A4D";
|
||||||
color3 = "#3E4D89";
|
color3 = "#3E4D89";
|
||||||
color4 = "#687BBA";
|
color4 = "#687BBA";
|
||||||
color5 = "#A4B1D6";
|
color5 = "#A4B1D6";
|
||||||
color6 = "#bdbfc9";
|
color6 = "#bdbfc9";
|
||||||
color7 = "#DFE5F1";
|
color7 = "#DFE5F1";
|
||||||
color8 = "#e9e9ed";
|
color8 = "#e9e9ed";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
italics = true;
|
italics = true;
|
||||||
transparentBackground = false;
|
transparent_background = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue