mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
colorschemes/base16: use mkVimPlugin
This commit is contained in:
parent
4fd3cd1203
commit
c2cd3cb7a1
2 changed files with 101 additions and 100 deletions
|
@ -5,108 +5,112 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib;
|
||||||
cfg = config.colorschemes.base16;
|
# We configure this plugin manually (no `settings` option) so there is no point in using
|
||||||
themes = import ./theme-list.nix;
|
# `mkNeovimPlugin` here.
|
||||||
in {
|
helpers.vim-plugin.mkVimPlugin config {
|
||||||
options = {
|
name = "base16";
|
||||||
colorschemes.base16 = {
|
isColorscheme = true;
|
||||||
enable = mkEnableOption "base16";
|
originalName = "base16.nvim";
|
||||||
|
defaultPackage = pkgs.vimPlugins.base16-nvim;
|
||||||
|
|
||||||
package = helpers.mkPackageOption "base16" pkgs.vimPlugins.base16-nvim;
|
maintainers = [maintainers.GaetanLepage];
|
||||||
|
|
||||||
useTruecolor = mkOption {
|
# We manually set the colorscheme if needed.
|
||||||
type = types.bool;
|
colorscheme = null;
|
||||||
default = true;
|
|
||||||
description = "Whether to use truecolor for the colorschemes. If set to false, you'll need to set up base16 in your shell.";
|
|
||||||
};
|
|
||||||
|
|
||||||
colorscheme = mkOption {
|
# TODO introduced 2024-03-12: remove 2024-05-12
|
||||||
type = types.nullOr (types.enum themes);
|
imports = let
|
||||||
description = "The base16 colorscheme to use";
|
basePluginPath = ["colorschemes" "base16"];
|
||||||
default = null;
|
in [
|
||||||
};
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(basePluginPath ++ ["customColorScheme"])
|
||||||
|
(basePluginPath ++ ["colorscheme"])
|
||||||
|
)
|
||||||
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(basePluginPath ++ ["useTruecolor"])
|
||||||
|
["options" "termguicolors"]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
colorscheme = let
|
||||||
|
customColorschemeType = types.submodule {
|
||||||
|
options =
|
||||||
|
listToAttrs
|
||||||
|
(
|
||||||
|
map
|
||||||
|
(
|
||||||
|
colorId: rec {
|
||||||
|
name = "base0" + colorId;
|
||||||
|
value = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The value for color `${name}`.";
|
||||||
|
example = "#16161D";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkOption {
|
||||||
|
type = with types;
|
||||||
|
either
|
||||||
|
(enum (import ./theme-list.nix))
|
||||||
|
customColorschemeType;
|
||||||
|
description = ''
|
||||||
|
The base16 colorscheme to use.
|
||||||
|
It can either be the name of a builtin colorscheme or an attrs specifying each color explicitly.
|
||||||
|
|
||||||
|
Example for the latter:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
base00 = "#16161D";
|
||||||
|
base01 = "#2c313c";
|
||||||
|
base02 = "#3e4451";
|
||||||
|
base03 = "#6c7891";
|
||||||
|
base04 = "#565c64";
|
||||||
|
base05 = "#abb2bf";
|
||||||
|
base06 = "#9a9bb3";
|
||||||
|
base07 = "#c5c8e6";
|
||||||
|
base08 = "#e06c75";
|
||||||
|
base09 = "#d19a66";
|
||||||
|
base0A = "#e5c07b";
|
||||||
|
base0B = "#98c379";
|
||||||
|
base0C = "#56b6c2";
|
||||||
|
base0D = "#0184bc";
|
||||||
|
base0E = "#c678dd";
|
||||||
|
base0F = "#a06949";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
example = "edge-light";
|
||||||
|
};
|
||||||
|
|
||||||
setUpBar = mkOption {
|
setUpBar = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to install the matching plugin for your statusbar. This does nothing as of yet, waiting for upstream support.";
|
description = "Whether to set your status bar theme to 'base16'.";
|
||||||
};
|
};
|
||||||
|
|
||||||
customColorScheme =
|
|
||||||
helpers.mkNullOrOption
|
|
||||||
(with types;
|
|
||||||
submodule {
|
|
||||||
options =
|
|
||||||
listToAttrs
|
|
||||||
(
|
|
||||||
map
|
|
||||||
(
|
|
||||||
colorId: rec {
|
|
||||||
name = "base0" + colorId;
|
|
||||||
value = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "The value for color ${name}.";
|
|
||||||
example = "#16161D";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]
|
|
||||||
);
|
|
||||||
})
|
|
||||||
''
|
|
||||||
Optionally, you can provide a table specifying your colors to the setup function.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```nix
|
|
||||||
{
|
|
||||||
base00 = "#16161D";
|
|
||||||
base01 = "#2c313c";
|
|
||||||
base02 = "#3e4451";
|
|
||||||
base03 = "#6c7891";
|
|
||||||
base04 = "#565c64";
|
|
||||||
base05 = "#abb2bf";
|
|
||||||
base06 = "#9a9bb3";
|
|
||||||
base07 = "#c5c8e6";
|
|
||||||
base08 = "#e06c75";
|
|
||||||
base09 = "#d19a66";
|
|
||||||
base0A = "#e5c07b";
|
|
||||||
base0B = "#98c379";
|
|
||||||
base0C = "#56b6c2";
|
|
||||||
base0D = "#0184bc";
|
|
||||||
base0E = "#c678dd";
|
|
||||||
base0F = "#a06949";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
extraConfig = cfg:
|
||||||
warnings = optional (cfg.colorscheme != null && cfg.customColorScheme != null) "
|
mkMerge [
|
||||||
You have set both `colorschemes.base16.colorscheme` and `colorschemes.base16.customColorScheme`, `colorscheme` will be preferred.
|
{
|
||||||
";
|
plugins.airline.settings.theme = mkIf cfg.setUpBar "base16";
|
||||||
assertions = [
|
plugins.lualine.theme = mkIf cfg.setUpBar "base16";
|
||||||
{
|
plugins.lightline.colorscheme = null;
|
||||||
assertion = cfg.colorscheme != null || cfg.customColorScheme != null;
|
}
|
||||||
message = ''
|
(mkIf (isString cfg.colorscheme) {
|
||||||
You have enabled `colorschemes.base16` but haven't set a specific color scheme.
|
colorscheme = "base16-${cfg.colorscheme}";
|
||||||
Please set a color scheme using `colorschemes.base16.colorscheme` or `colorschemes.base16.customColorScheme`.
|
})
|
||||||
'';
|
(mkIf (isAttrs cfg.colorscheme) {
|
||||||
}
|
extraConfigLuaPre = ''
|
||||||
];
|
require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme})
|
||||||
|
'';
|
||||||
colorscheme = mkIf (cfg.colorscheme != null) "base16-${cfg.colorscheme}";
|
})
|
||||||
extraPlugins = [cfg.package];
|
];
|
||||||
|
}
|
||||||
plugins.airline.settings.theme = mkIf cfg.setUpBar "base16";
|
|
||||||
plugins.lualine.theme = mkIf cfg.setUpBar "base16";
|
|
||||||
plugins.lightline.colorscheme = null;
|
|
||||||
|
|
||||||
options.termguicolors = mkIf cfg.useTruecolor true;
|
|
||||||
|
|
||||||
extraConfigLuaPre = mkIf (cfg.customColorScheme != null) ''
|
|
||||||
require('base16-colorscheme').setup(${helpers.toLuaObject cfg.customColorScheme})
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
{
|
{
|
||||||
# No empty test because not setting `colorscheme` and `customColorScheme` would error
|
# No empty test because not setting `colorscheme` would error
|
||||||
|
|
||||||
# All the upstream default options of poimandres
|
|
||||||
defaults = {
|
defaults = {
|
||||||
colorschemes.base16 = {
|
colorschemes.base16 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
useTruecolor = true;
|
|
||||||
colorscheme = "gruvbox-dark-hard";
|
colorscheme = "gruvbox-dark-hard";
|
||||||
setUpBar = true;
|
setUpBar = true;
|
||||||
customColorScheme = null;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +14,7 @@
|
||||||
colorschemes.base16 = {
|
colorschemes.base16 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
customColorScheme = {
|
colorscheme = {
|
||||||
base00 = "#16161D";
|
base00 = "#16161D";
|
||||||
base01 = "#2c313c";
|
base01 = "#2c313c";
|
||||||
base02 = "#3e4451";
|
base02 = "#3e4451";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue