modules/ui: switch to explicit lib calls

This commit is contained in:
raf 2024-03-16 16:25:30 +03:00
commit a7531186a8
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
25 changed files with 251 additions and 272 deletions

View file

@ -1,15 +1,12 @@
{
config,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf attrs bool enum;
in {
options.vim.ui.colorizer = {
enable = mkEnableOption "nvim-colorizer.lua for color highlighting";
enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";
filetypes = mkOption {
type = with types; attrsOf attrs;
type = attrsOf attrs;
default = {
css = {};
scss = {};
@ -18,77 +15,54 @@ in {
};
options = {
alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
rgb = mkOption {
type = types.bool;
type = bool;
default = true;
description = "#RGB hex codes";
};
rrggbb = mkOption {
type = types.bool;
type = bool;
default = true;
description = "#RRGGBB hex codes";
};
names = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''"Name" codes such as "Blue"'';
};
rgb_fn = mkOption {
type = types.bool;
type = bool;
default = false;
description = "CSS rgb() and rgba() functions";
};
rrggbbaa = mkOption {
type = types.bool;
type = bool;
default = false;
description = "#RRGGBBAA hex codes";
};
hsl_fn = mkOption {
type = types.bool;
type = bool;
default = false;
description = "CSS hsl() and hsla() functions";
};
css = mkOption {
type = types.bool;
default = false;
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"];
type = enum ["foreground" "background"];
default = "background";
description = "Set the display mode";
};
tailwind = mkOption {
type = types.bool;
default = false;
description = "Enable tailwind colors";
};
sass = mkOption {
type = types.bool;
default = false;
description = "Enable sass colors";
};
alwaysUpdate = mkOption {
type = types.bool;
default = false;
description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs";
};
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";
};
};
}

View file

@ -1,10 +1,12 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) attrsetToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.colorizer;
in {
@ -13,14 +15,14 @@ in {
"nvim-colorizer-lua"
];
vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere ''
vim.luaConfigRC.colorizer = entryAnywhere ''
require('colorizer').setup({
filetypes = ${nvim.lua.attrsetToLuaTable cfg.filetypes},
filetypes = ${attrsetToLuaTable cfg.filetypes},
user_default_options = {
RGB = ${boolToString cfg.options.rgb};
RRGGBB = ${boolToString cfg.options.rrggbb};
names = ${boolToString cfg.options.names};
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};

View file

@ -1,4 +1,4 @@
_: {
{
imports = [
./colorizer.nix
./config.nix