Skip to content

Commit 49ec0ad

Browse files
committed
plugins/theme: apply requested changes
types/types.nix: remove unneeded inherit theme/theme.nix: remove commented inherit
1 parent 5db7e2a commit 49ec0ad

File tree

4 files changed

+20
-77
lines changed

4 files changed

+20
-77
lines changed

lib/types/types.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{lib}: let
22
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
3-
inherit (lib.strings) isString hasPrefix;
3+
inherit (lib.strings) isString;
44
inherit (lib.types) anything attrsOf;
55
inherit (lib.nvim.types) anythingConcatLists;
66
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;

modules/plugins/theme/base16-colors.nix

-69
This file was deleted.

modules/plugins/theme/supported-themes.nix

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
inherit (lib.strings) optionalString;
66
inherit (lib.trivial) boolToString warnIf;
77
inherit (lib.nvim.lua) toLuaObject;
8-
cfg = config.vim.theme;
98
in {
109
base16 = {
1110
setup = {base16-colors, ...}: ''
12-
-- Base-16 theme
13-
require('base16-colorscheme').setup(${toLuaObject cfg.base16-colors})
11+
-- Base16 theme
12+
require('base16-colorscheme').setup(${toLuaObject base16-colors})
1413
'';
1514
};
1615
onedark = {

modules/plugins/theme/theme.nix

+17-4
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,43 @@
33
lib,
44
...
55
}: let
6+
inherit (builtins) listToAttrs;
67
inherit (lib.options) mkOption;
78
inherit (lib.attrsets) attrNames;
9+
inherit (lib.strings) hasPrefix;
810
inherit (lib.types) bool lines enum;
911
inherit (lib.modules) mkIf;
1012
inherit (lib.nvim.dag) entryBefore;
13+
inherit (lib.nvim.types) hexColor;
1114

1215
cfg = config.vim.theme;
1316
supportedThemes = import ./supported-themes.nix {
1417
inherit lib config;
1518
};
16-
base16-colors = import ./base16-colors.nix {
17-
inherit lib;
18-
};
19+
20+
numbers = lib.stringToCharacters "0123456789ABCDEF";
21+
generateBase16Options = listToAttrs (map (i: {
22+
name = "base0${i}";
23+
value = mkOption {
24+
type = hexColor;
25+
apply = v:
26+
if hasPrefix "#" v
27+
then v
28+
else "#${v}";
29+
};
30+
})
31+
numbers);
1932
in {
2033
options.vim.theme = {
2134
enable = mkOption {
2235
type = bool;
2336
description = "Enable theming";
2437
};
25-
inherit base16-colors;
2638
name = mkOption {
2739
type = enum (attrNames supportedThemes);
2840
description = "Supported themes can be found in `supportedThemes.nix`";
2941
};
42+
base16-colors = generateBase16Options;
3043

3144
style = mkOption {
3245
type = enum supportedThemes.${cfg.name}.styles;

0 commit comments

Comments
 (0)