mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01: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,10 +1,22 @@
|
|||
{lib, ...}: let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf attrs bool enum;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
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 = {
|
||||
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
|
||||
|
||||
setupOpts = mkPluginSetupOption "nvim-colorizer" {
|
||||
filetypes = mkOption {
|
||||
type = attrsOf attrs;
|
||||
default = {
|
||||
|
@ -14,9 +26,7 @@ in {
|
|||
description = "Filetypes to highlight on";
|
||||
};
|
||||
|
||||
options = {
|
||||
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
|
||||
|
||||
user_default_options = {
|
||||
rgb = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
|
@ -53,16 +63,42 @@ in {
|
|||
description = "CSS hsl() and hsla() functions";
|
||||
};
|
||||
|
||||
css = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
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 = mkEnableOption "tailwind colors";
|
||||
sass = mkEnableOption "sass colors";
|
||||
css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
|
||||
css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn";
|
||||
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
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.lua) attrsetToLuaTable;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.ui.colorizer;
|
||||
in {
|
||||
|
@ -16,23 +15,7 @@ in {
|
|||
];
|
||||
|
||||
vim.luaConfigRC.colorizer = entryAnywhere ''
|
||||
require('colorizer').setup({
|
||||
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};
|
||||
}
|
||||
})
|
||||
require('colorizer').setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue