mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 18:31:35 +00:00
feat: color previews via nvim-colorizer-lua
This commit is contained in:
parent
1cc6bb8b8a
commit
471677d403
8 changed files with 130 additions and 4 deletions
67
modules/ui/colorizer/colorizer.nix
Normal file
67
modules/ui/colorizer/colorizer.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
32
modules/ui/colorizer/config.nix
Normal file
32
modules/ui/colorizer/config.nix
Normal 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}';
|
||||
}
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/ui/colorizer/default.nix
Normal file
6
modules/ui/colorizer/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./colorizer.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue