summaryrefslogtreecommitdiffstats
path: root/modules/plugins/ui/colorizer/colorizer.nix
blob: 77928d124e388a9a9644c9bd10463a07c8379b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{lib, ...}: let
  inherit (lib.options) mkOption mkEnableOption;
  inherit (lib.types) attrsOf enum nullOr submodule bool str;
  inherit (lib.modules) mkRenamedOptionModule;
  inherit (lib.nvim.types) mkPluginSetupOption;

  settingSubmodule = submodule {
    options = {
      RGB = mkOption {
        description = "Colorize #RGB hex codes";
        default = null;
        type = nullOr bool;
      };

      RRGGBB = mkOption {
        description = "Colorize #RRGGBB hex codes";
        default = null;
        type = nullOr bool;
      };

      names = mkOption {
        description = ''Colorize "Name" codes like Blue'';
        default = null;
        type = nullOr bool;
      };

      RRGGBBAA = mkOption {
        description = "Colorize #RRGGBBAA hex codes";
        default = null;
        type = nullOr bool;
      };

      AARRGGBB = mkOption {
        description = "Colorize 0xAARRGGBB hex codes";
        default = null;
        type = nullOr bool;
      };

      rgb_fn = mkOption {
        description = "Colorize CSS rgb() and rgba() functions";
        default = null;
        type = nullOr bool;
      };

      hsl_fn = mkOption {
        description = "Colorize CSS hsl() and hsla() functions";
        default = null;
        type = nullOr bool;
      };

      css = mkOption {
        description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB";
        default = null;
        type = nullOr bool;
      };

      css_fn = mkOption {
        description = "Enable all CSS *functions*: rgb_fn, hsl_fn";
        default = null;
        type = nullOr bool;
      };

      tailwind = mkOption {
        description = "Enable tailwind colors";
        default = null;
        type = nullOr bool;
      };

      sass = mkOption {
        description = "Enable sass colors";
        default = null;
        type = nullOr bool;
      };

      virtualtext = mkOption {
        description = "String to display as virtualtext";
        type = nullOr str;
        default = null;
      };

      mode = mkOption {
        description = "Set the display mode";
        type = nullOr (enum ["foreground" "background" "virtualtext"]);
        default = null;
      };

      always_update = mkOption {
        description = "Update color values even if buffer is not focused. Example use: cmp_menu, cmp_docs";
        default = null;
        type = nullOr bool;
      };
    };
  };
in {
  imports = [
    (mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "defaultOptions"])
    (mkRenamedOptionModule ["vim" "ui" "colorizer" "filetypes"] ["vim" "ui" "colorizer" "setupOpts" "filetypes"])
  ];

  options.vim.ui.colorizer = {
    enable = mkEnableOption "color highlighting [nvim-colorizer.lua]";

    setupOpts = mkPluginSetupOption "colorizer" {
      filetypes = mkOption {
        type = attrsOf settingSubmodule;
        default = {
          "*" = {};
        };
        example = {
          "*" = {};
          "!vim" = {};
          javascript = {
            AARRGGBB = false;
          };
        };
        description = ''
          Filetypes to enable on and their option overrides.

          `"*"` means enable on all filetypes. Filetypes prefixed with `"!"` are disabled.
        '';
      };

      user_default_options = mkOption {
        type = settingSubmodule;
        default = {};
        description = ''
          `user_default_options` is the second parameter to nvim-colorizer's setup function.

          Anything set here is the inverse of the previous setup configuration.
        '';
      };
    };
  };
}