plugins/colorschemes: remove with lib;

This commit is contained in:
Austin Horstman 2024-08-22 10:03:02 -05:00
parent fba168aba7
commit 77cbd0313d
No known key found for this signature in database
13 changed files with 94 additions and 101 deletions

View file

@ -4,7 +4,6 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts toLuaObject;
in
@ -17,7 +16,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
colorscheme = null;
callSetup = false;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
deprecateExtraOptions = true;
optionsRenamedToSettings = [
@ -30,7 +29,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
Set to `true` to use `mirage` variant instead of `dark` for dark background.
'';
overrides = defaultNullOpts.mkStrLuaOr (with types; attrsOf highlight) { } ''
overrides = defaultNullOpts.mkStrLuaOr (with lib.types; attrsOf highlight) { } ''
A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex.

View file

@ -4,7 +4,6 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts toLuaObject;
@ -18,7 +17,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
defaultPackage = pkgs.vimPlugins.base16-nvim;
isColorscheme = true;
maintainers = with maintainers; [
maintainers = with lib.maintainers; [
GaetanLepage
MattSturgeon
];
@ -32,10 +31,10 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
];
in
[
(mkRenamedOptionModule (basePluginPath ++ [ "customColorScheme" ]) (
(lib.mkRenamedOptionModule (basePluginPath ++ [ "customColorScheme" ]) (
basePluginPath ++ [ "colorscheme" ]
))
(mkRenamedOptionModule (basePluginPath ++ [ "useTruecolor" ]) [
(lib.mkRenamedOptionModule (basePluginPath ++ [ "useTruecolor" ]) [
"options"
"termguicolors"
])
@ -92,11 +91,11 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
extraOptions = {
colorscheme =
let
customColorschemeType = types.submodule {
options = mapAttrs (
customColorschemeType = lib.types.submodule {
options = lib.mapAttrs (
name: example:
mkOption {
type = with types; maybeRaw str;
lib.mkOption {
type = with lib.types; maybeRaw str;
description = "The value for color `${name}`.";
inherit example;
}
@ -125,19 +124,21 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
builtinColorschemeExamples = import ./theme-list.nix;
in
defaultNullOpts.mkNullable' {
type = types.oneOf [
types.str
customColorschemeType
types.rawLua
];
pluginDefault = literalMD ''`vim.env.BASE16_THEME` or `"schemer-dark"`'';
type =
with lib.types;
oneOf [
str
customColorschemeType
rawLua
];
pluginDefault = lib.literalMD ''`vim.env.BASE16_THEME` or `"schemer-dark"`'';
description = ''
The base16 colorscheme to use.
You may use the name of a builtin colorscheme or an attrs that specifies the colors explicitly.
Examples of builtin themes include:
${concatStrings (
${lib.concatStrings (
map (e: ''
- "${e}"
'') builtinColorschemeExamples
@ -158,8 +159,8 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
example = customColorschemeExample;
};
setUpBar = mkOption {
type = types.bool;
setUpBar = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = "Whether to set your status bar theme to 'base16'.";
@ -171,11 +172,11 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
callSetup = false;
extraConfig = cfg: {
plugins.airline.settings.theme = mkIf cfg.setUpBar (mkDefault name);
plugins.lualine.theme = mkIf cfg.setUpBar (mkDefault name);
plugins.lightline.colorscheme = mkDefault null;
plugins.airline.settings.theme = lib.mkIf cfg.setUpBar (lib.mkDefault name);
plugins.lualine.theme = lib.mkIf cfg.setUpBar (lib.mkDefault name);
plugins.lightline.colorscheme = lib.mkDefault null;
opts.termguicolors = mkDefault true;
opts.termguicolors = lib.mkDefault true;
# `settings` can either be passed to `with_config` before calling `setup`,
# or it can be passed as `setup`'s 2nd argument.

View file

@ -4,16 +4,16 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStrLuaFnOr;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
name = "catppuccin";
isColorscheme = true;
defaultPackage = pkgs.vimPlugins.catppuccin-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-03-27: remove 2024-05-27
optionsRenamedToSettings = [
@ -92,10 +92,10 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
"integrations"
];
imports =
mapAttrsToList
lib.mapAttrsToList
(
old: new:
mkRenamedOptionModule
lib.mkRenamedOptionModule
[
"colorschemes"
"catppuccin"
@ -236,7 +236,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
'';
};
color_overrides = genAttrs (flavours ++ [ "all" ]) (
color_overrides = lib.genAttrs (flavours ++ [ "all" ]) (
flavour:
defaultNullOpts.mkAttrsOf types.str { } (
if flavour == "all" then
@ -318,5 +318,5 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
};
};
extraConfig = cfg: { opts.termguicolors = mkDefault true; };
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
}

View file

@ -4,7 +4,6 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
in
@ -38,7 +37,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
'';
theme = {
highlights = defaultNullOpts.mkAttrsOf types.highlight { } ''
highlights = defaultNullOpts.mkAttrsOf lib.types.highlight { } ''
Highlight groups to override, adding new groups is also possible.
See `:h highlight-groups` for a list of highlight groups.
@ -57,7 +56,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
Complete list can be found in `lua/cyberdream/theme.lua` in upstream repository.
'';
colors = defaultNullOpts.mkAttrsOf types.str { } ''
colors = defaultNullOpts.mkAttrsOf lib.types.str { } ''
Override the default colors used.
For a full list of colors, see upstream documentation.

View file

@ -4,57 +4,57 @@
pkgs,
...
}:
with lib;
let
inherit (lib) types;
cfg = config.colorschemes.dracula;
in
{
options = {
colorschemes.dracula = {
enable = mkEnableOption "dracula";
enable = lib.mkEnableOption "dracula";
package = lib.nixvim.mkPluginPackageOption "dracula" pkgs.vimPlugins.dracula-vim;
bold = mkOption {
bold = lib.mkOption {
type = types.bool;
default = true;
description = "Include bold attributes in highlighting";
};
italic = mkOption {
italic = lib.mkOption {
type = types.bool;
default = true;
description = "Include italic attributes in highlighting";
};
underline = mkOption {
underline = lib.mkOption {
type = types.bool;
default = true;
description = "Include underline attributes in highlighting";
};
undercurl = mkOption {
undercurl = lib.mkOption {
type = types.bool;
default = true;
description = "Include undercurl attributes in highlighting (only if underline enabled)";
};
fullSpecialAttrsSupport = mkOption {
fullSpecialAttrsSupport = lib.mkOption {
type = types.bool;
default = false;
description = "Explicitly declare full support for special attributes. On terminal emulators, set to 1 to allow underline/undercurl highlights without changing the foreground color";
};
highContrastDiff = mkOption {
highContrastDiff = lib.mkOption {
type = types.bool;
default = false;
description = "Use high-contrast color when in diff mode";
};
inverse = mkOption {
inverse = lib.mkOption {
type = types.bool;
default = true;
description = "Include inverse attributes in highlighting";
};
colorterm = mkOption {
colorterm = lib.mkOption {
type = types.bool;
default = true;
description = "Include background fill colors";
@ -62,21 +62,21 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
colorscheme = "dracula";
extraPlugins = [ cfg.package ];
globals = {
dracula_bold = mkIf (!cfg.bold) 0;
dracula_italic = mkIf (!cfg.italic) 0;
dracula_underline = mkIf (!cfg.underline) 0;
dracula_undercurl = mkIf (!cfg.undercurl) 0;
dracula_full_special_attrs_support = mkIf cfg.fullSpecialAttrsSupport 1;
dracula_high_contrast_diff = mkIf cfg.highContrastDiff 1;
dracula_inverse = mkIf (!cfg.inverse) 0;
dracula_colorterm = mkIf (!cfg.colorterm) 0;
dracula_bold = lib.mkIf (!cfg.bold) 0;
dracula_italic = lib.mkIf (!cfg.italic) 0;
dracula_underline = lib.mkIf (!cfg.underline) 0;
dracula_undercurl = lib.mkIf (!cfg.undercurl) 0;
dracula_full_special_attrs_support = lib.mkIf cfg.fullSpecialAttrsSupport 1;
dracula_high_contrast_diff = lib.mkIf cfg.highContrastDiff 1;
dracula_inverse = lib.mkIf (!cfg.inverse) 0;
dracula_colorterm = lib.mkIf (!cfg.colorterm) 0;
};
opts.termguicolors = mkDefault true;
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -4,9 +4,9 @@
config,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
name = "kanagawa";
@ -20,7 +20,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
- Set `colorschemes.kanagawa.settings.background` (the active theme will depend on the value of `vim.o.background`).
'';
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-03-15: remove 2024-05-15
deprecateExtraOptions = true;
@ -34,7 +34,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
(map
(
optionPath:
mkRenamedOptionModule (basePluginPath ++ optionPath) (
lib.mkRenamedOptionModule (basePluginPath ++ optionPath) (
basePluginPath ++ [ "settings" ] ++ optionPath
)
)
@ -69,7 +69,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
]
)
++ [
(mkRemovedOptionModule (basePluginPath ++ [ "overrides" ]) ''
(lib.mkRemovedOptionModule (basePluginPath ++ [ "overrides" ]) ''
Use `colorschemes.kanagawa.settings.overrides` but you now have to add the full function definition:
```
function(colors)

View file

@ -4,14 +4,13 @@
pkgs,
...
}:
with lib;
lib.nixvim.vim-plugin.mkVimPlugin config {
name = "melange";
isColorscheme = true;
originalName = "melange-nvim";
defaultPackage = pkgs.vimPlugins.melange-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = cfg: { opts.termguicolors = mkDefault true; };
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
}

View file

@ -4,9 +4,9 @@
config,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) types;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
name = "nightfox";
@ -14,11 +14,11 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
originalName = "nightfox.nvim";
defaultPackage = pkgs.vimPlugins.nightfox-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
colorscheme = null;
extraOptions = {
flavor = mkOption {
flavor = lib.mkOption {
type = types.enum [
"carbonfox"
"dawnfox"
@ -33,7 +33,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
description = "Which palette/flavor to use as the colorscheme.";
};
};
extraConfig = cfg: { colorscheme = mkDefault cfg.flavor; };
extraConfig = cfg: { colorscheme = lib.mkDefault cfg.flavor; };
settingsOptions = {
options = {
@ -132,7 +132,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
'';
severity =
mapAttrs
lib.mapAttrs
(
name: color:
defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0 ''

View file

@ -4,7 +4,6 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
in
@ -14,7 +13,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
originalName = "palette.nvim";
defaultPackage = pkgs.vimPlugins.palette-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
extraPlugins = [
# Annoyingly, lspconfig is required, otherwise this line is breaking:
@ -50,15 +49,15 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
};
customPalettes =
mapAttrs
lib.mapAttrs
(
name: colorNames:
defaultNullOpts.mkAttrsOf
(types.submodule {
options = genAttrs colorNames (
(lib.types.submodule {
options = lib.genAttrs colorNames (
colorName:
mkOption {
type = types.str;
lib.mkOption {
type = lib.types.str;
description = "Definition of color '${colorName}'";
}
);
@ -121,19 +120,19 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
extraConfig = cfg: {
assertions =
mapAttrsToList
lib.mapAttrsToList
(
name: defaultPaletteNames:
let
customPalettesNames = attrNames cfg.settings.custom_palettes.${name};
customPalettesNames = lib.attrNames cfg.settings.custom_palettes.${name};
allowedPaletteNames = customPalettesNames ++ defaultPaletteNames;
palette = cfg.settings.palettes.${name};
in
{
assertion = isString palette -> elem palette allowedPaletteNames;
assertion = lib.isString palette -> lib.elem palette allowedPaletteNames;
message = ''
Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${concatStringsSep " " allowedPaletteNames}).
Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${lib.concatStringsSep " " allowedPaletteNames}).
'';
}
)

View file

@ -4,7 +4,6 @@
config,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
in
@ -14,7 +13,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
originalName = "poimandres.nvim";
defaultPackage = pkgs.vimPlugins.poimandres-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15
deprecateExtraOptions = true;
@ -54,13 +53,13 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
Dark variant.
'';
groups = mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
groups = mkNullOrOption (with lib.types; attrsOf (either str (attrsOf str))) ''
Which color to use for each group.
default: see [source](https://github.com/olivercederborg/poimandres.nvim/blob/main/lua/poimandres/init.lua)
'';
highlight_groups = defaultNullOpts.mkAttrsOf types.str { } ''
highlight_groups = defaultNullOpts.mkAttrsOf lib.types.str { } ''
Highlight groups.
'';
};

View file

@ -4,7 +4,6 @@
config,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
in
@ -13,7 +12,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
isColorscheme = true;
defaultPackage = pkgs.vimPlugins.rose-pine;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15
optionsRenamedToSettings = [
@ -28,30 +27,30 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
];
in
[
(mkRenamedOptionModule (basePluginPath ++ [ "style" ]) (
(lib.mkRenamedOptionModule (basePluginPath ++ [ "style" ]) (
basePluginPath
++ [
"settings"
"dark_variant"
]
))
(mkRenamedOptionModule (basePluginPath ++ [ "dimInactive" ]) (
(lib.mkRenamedOptionModule (basePluginPath ++ [ "dimInactive" ]) (
basePluginPath
++ [
"settings"
"dim_inactive_windows"
]
))
(mkRemovedOptionModule (
(lib.mkRemovedOptionModule (
basePluginPath ++ [ "disableItalics" ]
) "Use `colorschemes.rose-pine.settings.enable.italics` instead.")
(mkRemovedOptionModule (
(lib.mkRemovedOptionModule (
basePluginPath ++ [ "boldVerticalSplit" ]
) "Use `colorschemes.rose-pine.settings.highlight_groups` instead.")
(mkRemovedOptionModule (
(lib.mkRemovedOptionModule (
basePluginPath ++ [ "transparentFloat" ]
) "Use `colorschemes.rose-pine.settings.highlight_groups.NormalFloat` instead.")
(mkRenamedOptionModule (basePluginPath ++ [ "transparentBackground" ]) (
(lib.mkRenamedOptionModule (basePluginPath ++ [ "transparentBackground" ]) (
basePluginPath
++ [
"settings"
@ -64,7 +63,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
settingsOptions = {
variant =
lib.nixvim.mkNullOrOption
(types.enum [
(lib.types.enum [
"auto"
"main"
"moon"
@ -111,13 +110,13 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
transparency = defaultNullOpts.mkBool true "Enable transparency.";
};
groups = mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
groups = mkNullOrOption (with lib.types; attrsOf (either str (attrsOf str))) ''
Highlight groups.
default: see [source](https://github.com/rose-pine/neovim/blob/main/lua/rose-pine/config.lua)
'';
highlight_groups = defaultNullOpts.mkAttrsOf types.highlight { } ''
highlight_groups = defaultNullOpts.mkAttrsOf lib.types.highlight { } ''
Custom highlight groups.
'';
@ -158,5 +157,5 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
before_highlight = "function(group, highlight, palette) end";
};
extraConfig = cfg: { opts.termguicolors = mkDefault true; };
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
}

View file

@ -4,7 +4,6 @@
config,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
in
@ -14,7 +13,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
originalName = "tokyonight.nvim";
defaultPackage = pkgs.vimPlugins.tokyonight-nvim;
maintainers = [ maintainers.GaetanLepage ];
maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15
optionsRenamedToSettings = [
@ -111,7 +110,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
};
sidebars =
defaultNullOpts.mkListOf types.str
defaultNullOpts.mkListOf lib.types.str
[
"qf"
"help"
@ -120,7 +119,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
Set a darker background on sidebar-like windows.
'';
day_brightness = defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.3 ''
day_brightness = defaultNullOpts.mkNullable (lib.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.
'';
@ -179,5 +178,5 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
on_highlights = "function(highlights, colors) end";
};
extraConfig = cfg: { opts.termguicolors = mkDefault true; };
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
}

View file

@ -4,7 +4,6 @@
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) defaultNullOpts toLuaObject;
in
@ -16,18 +15,18 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
colorscheme = null; # Color scheme is set by `require.("vscode").load()`
callSetup = false;
maintainers = [ maintainers.loicreynier ];
maintainers = [ lib.maintainers.loicreynier ];
settingsOptions = {
transparent = defaultNullOpts.mkBool false "Whether to enable transparent background";
italic_comments = defaultNullOpts.mkBool false "Whether to enable italic comments";
underline_links = defaultNullOpts.mkBool false "Whether to underline links";
disable_nvimtree_bg = defaultNullOpts.mkBool true "Whether to disable nvim-tree background";
color_overrides = defaultNullOpts.mkAttrsOf types.str { } ''
color_overrides = defaultNullOpts.mkAttrsOf lib.types.str { } ''
A dictionary of color overrides.
See https://github.com/Mofiqul/vscode.nvim/blob/main/lua/vscode/colors.lua for color names.
'';
group_overrides = defaultNullOpts.mkAttrsOf types.highlight { } ''
group_overrides = defaultNullOpts.mkAttrsOf lib.types.highlight { } ''
A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex.
'';