mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 14:55:59 +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,68 +1,104 @@
|
|||
{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]";
|
||||
|
||||
filetypes = mkOption {
|
||||
type = attrsOf attrs;
|
||||
default = {
|
||||
css = {};
|
||||
scss = {};
|
||||
};
|
||||
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";
|
||||
setupOpts = mkPluginSetupOption "nvim-colorizer" {
|
||||
filetypes = mkOption {
|
||||
type = attrsOf attrs;
|
||||
default = {
|
||||
css = {};
|
||||
scss = {};
|
||||
};
|
||||
description = "Filetypes to highlight on";
|
||||
};
|
||||
|
||||
rrggbb = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "#RRGGBB hex codes";
|
||||
};
|
||||
user_default_options = {
|
||||
rgb = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "#RGB hex codes";
|
||||
};
|
||||
|
||||
names = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''"Name" codes such as "Blue"'';
|
||||
};
|
||||
rrggbb = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "#RRGGBB hex codes";
|
||||
};
|
||||
|
||||
rgb_fn = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "CSS rgb() and rgba() functions";
|
||||
};
|
||||
names = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''"Name" codes such as "Blue"'';
|
||||
};
|
||||
|
||||
rrggbbaa = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "#RRGGBBAA hex codes";
|
||||
};
|
||||
rgb_fn = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "CSS rgb() and rgba() functions";
|
||||
};
|
||||
|
||||
hsl_fn = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "CSS hsl() and hsla() functions";
|
||||
};
|
||||
rrggbbaa = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "#RRGGBBAA hex codes";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = enum ["foreground" "background"];
|
||||
default = "background";
|
||||
description = "Set the display mode";
|
||||
};
|
||||
hsl_fn = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "CSS hsl() and hsla() functions";
|
||||
};
|
||||
|
||||
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";
|
||||
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 = 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