mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 00:48:58 +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,38 +5,39 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.colorschemes.base16;
|
||||
themes = import ./theme-list.nix;
|
||||
in {
|
||||
options = {
|
||||
colorschemes.base16 = {
|
||||
enable = mkEnableOption "base16";
|
||||
with lib;
|
||||
# We configure this plugin manually (no `settings` option) so there is no point in using
|
||||
# `mkNeovimPlugin` here.
|
||||
helpers.vim-plugin.mkVimPlugin config {
|
||||
name = "base16";
|
||||
isColorscheme = true;
|
||||
originalName = "base16.nvim";
|
||||
defaultPackage = pkgs.vimPlugins.base16-nvim;
|
||||
|
||||
package = helpers.mkPackageOption "base16" pkgs.vimPlugins.base16-nvim;
|
||||
maintainers = [maintainers.GaetanLepage];
|
||||
|
||||
useTruecolor = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to use truecolor for the colorschemes. If set to false, you'll need to set up base16 in your shell.";
|
||||
};
|
||||
# We manually set the colorscheme if needed.
|
||||
colorscheme = null;
|
||||
|
||||
colorscheme = mkOption {
|
||||
type = types.nullOr (types.enum themes);
|
||||
description = "The base16 colorscheme to use";
|
||||
default = null;
|
||||
};
|
||||
# TODO introduced 2024-03-12: remove 2024-05-12
|
||||
imports = let
|
||||
basePluginPath = ["colorschemes" "base16"];
|
||||
in [
|
||||
(
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ ["customColorScheme"])
|
||||
(basePluginPath ++ ["colorscheme"])
|
||||
)
|
||||
(
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ ["useTruecolor"])
|
||||
["options" "termguicolors"]
|
||||
)
|
||||
];
|
||||
|
||||
setUpBar = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to install the matching plugin for your statusbar. This does nothing as of yet, waiting for upstream support.";
|
||||
};
|
||||
|
||||
customColorScheme =
|
||||
helpers.mkNullOrOption
|
||||
(with types;
|
||||
submodule {
|
||||
extraOptions = {
|
||||
colorscheme = let
|
||||
customColorschemeType = types.submodule {
|
||||
options =
|
||||
listToAttrs
|
||||
(
|
||||
|
@ -46,18 +47,25 @@ in {
|
|||
name = "base0" + colorId;
|
||||
value = mkOption {
|
||||
type = types.str;
|
||||
description = "The value for color ${name}.";
|
||||
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.
|
||||
};
|
||||
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:
|
||||
Example for the latter:
|
||||
```nix
|
||||
{
|
||||
base00 = "#16161D";
|
||||
|
@ -79,34 +87,30 @@ in {
|
|||
}
|
||||
```
|
||||
'';
|
||||
example = "edge-light";
|
||||
};
|
||||
|
||||
setUpBar = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to set your status bar theme to 'base16'.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings = optional (cfg.colorscheme != null && cfg.customColorScheme != null) "
|
||||
You have set both `colorschemes.base16.colorscheme` and `colorschemes.base16.customColorScheme`, `colorscheme` will be preferred.
|
||||
";
|
||||
assertions = [
|
||||
extraConfig = cfg:
|
||||
mkMerge [
|
||||
{
|
||||
assertion = cfg.colorscheme != null || cfg.customColorScheme != null;
|
||||
message = ''
|
||||
You have enabled `colorschemes.base16` but haven't set a specific color scheme.
|
||||
Please set a color scheme using `colorschemes.base16.colorscheme` or `colorschemes.base16.customColorScheme`.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
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})
|
||||
}
|
||||
(mkIf (isString cfg.colorscheme) {
|
||||
colorscheme = "base16-${cfg.colorscheme}";
|
||||
})
|
||||
(mkIf (isAttrs cfg.colorscheme) {
|
||||
extraConfigLuaPre = ''
|
||||
require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme})
|
||||
'';
|
||||
};
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
colorschemes.base16 = {
|
||||
enable = true;
|
||||
|
||||
useTruecolor = true;
|
||||
colorscheme = "gruvbox-dark-hard";
|
||||
setUpBar = true;
|
||||
customColorScheme = null;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -17,7 +14,7 @@
|
|||
colorschemes.base16 = {
|
||||
enable = true;
|
||||
|
||||
customColorScheme = {
|
||||
colorscheme = {
|
||||
base00 = "#16161D";
|
||||
base01 = "#2c313c";
|
||||
base02 = "#3e4451";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue