feat: color previews via nvim-colorizer-lua

This commit is contained in:
NotAShelf 2023-06-04 10:24:06 +03:00
commit 471677d403
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
8 changed files with 130 additions and 4 deletions

View file

@ -0,0 +1,67 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
options.vim.ui.colorizer = {
enable = mkEnableOption "Enable nvim-colorizer.lua for color highlighting";
options = {
rgb = mkOption {
type = types.bool;
default = true;
description = "#RGB hex codes";
};
rrggbb = mkOption {
type = types.bool;
default = true;
description = "#RRGGBB hex codes";
};
names = mkOption {
type = types.bool;
default = true;
description = ''"Name" codes such as "Blue"'';
};
rgb_fn = mkOption {
type = types.bool;
default = false;
description = "CSS rgb() and rgba() functions";
};
rrggbbaa = mkOption {
type = types.bool;
default = false;
description = "#RRGGBBAA hex codes";
};
hsl_fn = mkOption {
type = types.bool;
default = false;
description = "CSS hsl() and hsla() functions";
};
css = mkOption {
type = types.bool;
default = true;
description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
};
css_fn = mkOption {
type = types.bool;
default = false;
description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
};
mode = mkOption {
type = types.enum ["foreground" "background"];
default = "background";
description = "Set the display mode";
};
};
};
}

View file

@ -0,0 +1,32 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.ui.colorizer;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"nvim-colorizer-lua"
];
vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere ''
require('colorizer').setup({
DEFAULT_OPTIONS = {
RGB = ${boolToString cfg.options.rgb};
RRGGBB = ${boolToString cfg.options.rrggbb};
names = ${boolToString cfg.options.names};
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
rgb_fn = ${boolToString cfg.options.rgb_fn};
hsl_fn = ${boolToString cfg.options.hsl_fn};
css = ${boolToString cfg.options.css};
css_fn = ${boolToString cfg.options.css_fn};
mode = '${toString cfg.options.mode}';
}
})
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./colorizer.nix
./config.nix
];
}