mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00:00
feat(colorizer): custom setup opts
This commit is contained in:
parent
7e16923952
commit
5387ca2b5a
2 changed files with 89 additions and 70 deletions
|
@ -1,68 +1,104 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.types) attrsOf attrs bool enum;
|
inherit (lib.types) attrsOf attrs bool enum;
|
||||||
|
inherit (lib.modules) mkRenamedOptionModule;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
(mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "user_default_options"])
|
||||||
|
(mkRenamedOptionModule ["vim" "ui" "colorizer" "filetypes"] ["vim" "ui" "colorizer" "setupOpts" "filetypes"])
|
||||||
|
];
|
||||||
|
|
||||||
options.vim.ui.colorizer = {
|
options.vim.ui.colorizer = {
|
||||||
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
|
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
|
||||||
|
|
||||||
filetypes = mkOption {
|
setupOpts = mkPluginSetupOption "nvim-colorizer" {
|
||||||
type = attrsOf attrs;
|
filetypes = mkOption {
|
||||||
default = {
|
type = attrsOf attrs;
|
||||||
css = {};
|
default = {
|
||||||
scss = {};
|
css = {};
|
||||||
};
|
scss = {};
|
||||||
description = "Filetypes to highlight on";
|
};
|
||||||
};
|
description = "Filetypes to highlight on";
|
||||||
|
|
||||||
options = {
|
|
||||||
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
|
|
||||||
|
|
||||||
rgb = mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = true;
|
|
||||||
description = "#RGB hex codes";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rrggbb = mkOption {
|
user_default_options = {
|
||||||
type = bool;
|
rgb = mkOption {
|
||||||
default = true;
|
type = bool;
|
||||||
description = "#RRGGBB hex codes";
|
default = true;
|
||||||
};
|
description = "#RGB hex codes";
|
||||||
|
};
|
||||||
|
|
||||||
names = mkOption {
|
rrggbb = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''"Name" codes such as "Blue"'';
|
description = "#RRGGBB hex codes";
|
||||||
};
|
};
|
||||||
|
|
||||||
rgb_fn = mkOption {
|
names = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = true;
|
||||||
description = "CSS rgb() and rgba() functions";
|
description = ''"Name" codes such as "Blue"'';
|
||||||
};
|
};
|
||||||
|
|
||||||
rrggbbaa = mkOption {
|
rgb_fn = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "#RRGGBBAA hex codes";
|
description = "CSS rgb() and rgba() functions";
|
||||||
};
|
};
|
||||||
|
|
||||||
hsl_fn = mkOption {
|
rrggbbaa = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "CSS hsl() and hsla() functions";
|
description = "#RRGGBBAA hex codes";
|
||||||
};
|
};
|
||||||
|
|
||||||
mode = mkOption {
|
hsl_fn = mkOption {
|
||||||
type = enum ["foreground" "background"];
|
type = bool;
|
||||||
default = "background";
|
default = false;
|
||||||
description = "Set the display mode";
|
description = "CSS hsl() and hsla() functions";
|
||||||
};
|
};
|
||||||
|
|
||||||
tailwind = mkEnableOption "tailwind colors";
|
css = mkOption {
|
||||||
sass = mkEnableOption "sass colors";
|
type = bool;
|
||||||
css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
|
default = false;
|
||||||
css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn";
|
description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
|
||||||
|
};
|
||||||
|
|
||||||
|
css_fn = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
|
||||||
|
};
|
||||||
|
|
||||||
|
mode = mkOption {
|
||||||
|
type = enum ["foreground" "background"];
|
||||||
|
default = "background";
|
||||||
|
description = "Set the display mode";
|
||||||
|
};
|
||||||
|
|
||||||
|
tailwind = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable tailwind colors";
|
||||||
|
};
|
||||||
|
|
||||||
|
sass = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable sass colors";
|
||||||
|
};
|
||||||
|
|
||||||
|
alwaysUpdate = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.trivial) boolToString;
|
|
||||||
inherit (lib.nvim.lua) attrsetToLuaTable;
|
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.ui.colorizer;
|
cfg = config.vim.ui.colorizer;
|
||||||
in {
|
in {
|
||||||
|
@ -16,23 +15,7 @@ in {
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.colorizer = entryAnywhere ''
|
vim.luaConfigRC.colorizer = entryAnywhere ''
|
||||||
require('colorizer').setup({
|
require('colorizer').setup(${toLuaObject cfg.setupOpts})
|
||||||
filetypes = ${attrsetToLuaTable cfg.filetypes},
|
|
||||||
user_default_options = {
|
|
||||||
RGB = ${boolToString cfg.options.rgb};
|
|
||||||
RRGGBB = ${boolToString cfg.options.rrggbb};
|
|
||||||
RRGGBBAA = ${boolToString cfg.options.rrggbbaa};
|
|
||||||
names = ${boolToString cfg.options.names};
|
|
||||||
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}';
|
|
||||||
tailwind = ${boolToString cfg.options.tailwind};
|
|
||||||
sass = ${boolToString cfg.options.tailwind};
|
|
||||||
always_update = ${boolToString cfg.options.alwaysUpdate};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue