colorschemes/dracula: switch to mkVimPlugin

This commit is contained in:
Gaetan Lepage 2024-12-13 16:26:54 +01:00
parent 2b5a4a3896
commit c181014422
2 changed files with 80 additions and 77 deletions

View file

@ -1,87 +1,75 @@
{ {
lib, lib,
config,
pkgs,
... ...
}: }:
let let
inherit (lib) types; inherit (lib.nixvim) defaultNullOpts;
cfg = config.colorschemes.dracula;
in in
{ lib.nixvim.vim-plugin.mkVimPlugin {
options = { name = "dracula";
colorschemes.dracula = { package = "dracula-vim";
enable = lib.mkEnableOption "dracula"; isColorscheme = true;
globalPrefix = "dracula_";
package = lib.mkPackageOption pkgs "dracula" { maintainers = [ lib.maintainers.GaetanLepage ];
default = [
"vimPlugins" optionsRenamedToSettings = [
"dracula-vim" "bold"
"italic"
"underline"
"undercurl"
"fullSpecialAttrsSupport"
"highContrastDiff"
"inverse"
"colorterm"
]; ];
settingsOptions = {
bold = defaultNullOpts.mkBool true ''
Include bold attributes in highlighting.
'';
italic = defaultNullOpts.mkBool true ''
Include italic attributes in highlighting.
'';
strikethrough = defaultNullOpts.mkBool true ''
Include strikethrough attributes in highlighting.
'';
underline = defaultNullOpts.mkBool true ''
Include underline attributes in highlighting.
'';
undercurl = defaultNullOpts.mkBool true ''
Include undercurl attributes in highlighting (only if `underline` is enabled).
'';
full_special_attrs_support = defaultNullOpts.mkBool false ''
Explicitly declare full support for special attributes.
On terminal emulators, set to `true` to allow `underline`/`undercurl` highlights without
changing the foreground color.
'';
high_contrast_diff = defaultNullOpts.mkBool false ''
Use high-contrast color when in diff mode.
'';
inverse = defaultNullOpts.mkBool true ''
Include inverse attributes in highlighting.
'';
colorterm = defaultNullOpts.mkBool true ''
Include background fill colors.
'';
}; };
bold = lib.mkOption { settingsExample = {
type = types.bool; italic = false;
default = true; colorterm = false;
description = "Include bold attributes in highlighting";
};
italic = lib.mkOption {
type = types.bool;
default = true;
description = "Include italic attributes in highlighting";
};
underline = lib.mkOption {
type = types.bool;
default = true;
description = "Include underline attributes in highlighting";
};
undercurl = lib.mkOption {
type = types.bool;
default = true;
description = "Include undercurl attributes in highlighting (only if underline enabled)";
};
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 = lib.mkOption {
type = types.bool;
default = false;
description = "Use high-contrast color when in diff mode";
};
inverse = lib.mkOption {
type = types.bool;
default = true;
description = "Include inverse attributes in highlighting";
};
colorterm = lib.mkOption {
type = types.bool;
default = true;
description = "Include background fill colors";
};
};
};
config = lib.mkIf cfg.enable {
colorscheme = "dracula";
extraPlugins = [ cfg.package ];
globals = {
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;
}; };
extraConfig = {
opts.termguicolors = lib.mkDefault true; opts.termguicolors = lib.mkDefault true;
}; };
} }

View file

@ -6,14 +6,29 @@
defaults = { defaults = {
colorschemes.dracula = { colorschemes.dracula = {
enable = true; enable = true;
settings = {
bold = true; bold = true;
italic = true; italic = true;
strikethrough = true;
underline = true; underline = true;
undercurl = true; undercurl = true;
fullSpecialAttrsSupport = false; full_special_attrs_support = false;
highContrastDiff = false; high_contrast_diff = false;
inverse = true; inverse = true;
colorterm = true; colorterm = true;
}; };
}; };
};
example = {
colorschemes.dracula = {
enable = true;
settings = {
italic = false;
colorterm = false;
};
};
};
} }