From 5db7e2aff92af2402749b8fc1d5379b5957798ff Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 13:01:39 +0200 Subject: [PATCH 1/7] lib/types: rename custom.nix to types.nix, mov theme.nix into types.nix --- lib/types/default.nix | 6 ++---- lib/types/theme.nix | 14 -------------- lib/types/{custom.nix => types.nix} | 10 +++++++++- 3 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 lib/types/theme.nix rename lib/types/{custom.nix => types.nix} (89%) diff --git a/lib/types/default.nix b/lib/types/default.nix index d7ddd240..70ca6bef 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -6,12 +6,10 @@ typesDag = import ./dag.nix {inherit lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesLanguage = import ./languages.nix {inherit lib;}; - typesCustom = import ./custom.nix {inherit lib;}; - typesTheme = import ./theme.nix {inherit lib;}; + typesTypes = import ./types.nix {inherit lib;}; in { inherit (typesDag) dagOf; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesLanguage) diagnostics mkGrammarOption; - inherit (typesCustom) anythingConcatLists char; - inherit (typesTheme) hexColorType; + inherit (typesTypes) anythingConcatLists char hexColor; } diff --git a/lib/types/theme.nix b/lib/types/theme.nix deleted file mode 100644 index 3ba2f489..00000000 --- a/lib/types/theme.nix +++ /dev/null @@ -1,14 +0,0 @@ -{lib}: let - inherit (lib.strings) isString; - inherit (lib.types) mkOptionType; - inherit (builtins) match; - # This was almost entirely taken from raf himself. -in { - hexColorType = mkOptionType { - name = "hex-color"; - descriptionClass = "noun"; - description = "RGB color in hex format"; - # Check to determine wether the provided color is base16-valid - check = x: isString x && (match "#[0-9a-fA-F]{6}" x) != null; - }; -} diff --git a/lib/types/custom.nix b/lib/types/types.nix similarity index 89% rename from lib/types/custom.nix rename to lib/types/types.nix index a94735c5..52358bf9 100644 --- a/lib/types/custom.nix +++ b/lib/types/types.nix @@ -1,8 +1,9 @@ {lib}: let inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; + inherit (lib.strings) isString hasPrefix; inherit (lib.types) anything attrsOf; inherit (lib.nvim.types) anythingConcatLists; - inherit (builtins) typeOf isAttrs any head concatLists stringLength; + inherit (builtins) typeOf isAttrs any head concatLists stringLength match; in { # HACK: Does this break anything in our case? # A modified version of the nixpkgs anything type that concatenates lists @@ -58,4 +59,11 @@ in { check = value: stringLength value < 2; merge = mergeEqualOption; }; + + hexColor = mkOptionType { + name = "hex-color"; + descriptionClass = "noun"; + description = "RGB color in hex format"; + check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null; + }; } From 49ec0adca373bbca6507e22cd1a7d81a140383fb Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 13:02:22 +0200 Subject: [PATCH 2/7] plugins/theme: apply requested changes types/types.nix: remove unneeded inherit theme/theme.nix: remove commented inherit --- lib/types/types.nix | 2 +- modules/plugins/theme/base16-colors.nix | 69 ---------------------- modules/plugins/theme/supported-themes.nix | 5 +- modules/plugins/theme/theme.nix | 21 +++++-- 4 files changed, 20 insertions(+), 77 deletions(-) delete mode 100644 modules/plugins/theme/base16-colors.nix diff --git a/lib/types/types.nix b/lib/types/types.nix index 52358bf9..250d7636 100644 --- a/lib/types/types.nix +++ b/lib/types/types.nix @@ -1,6 +1,6 @@ {lib}: let inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; - inherit (lib.strings) isString hasPrefix; + inherit (lib.strings) isString; inherit (lib.types) anything attrsOf; inherit (lib.nvim.types) anythingConcatLists; inherit (builtins) typeOf isAttrs any head concatLists stringLength match; diff --git a/modules/plugins/theme/base16-colors.nix b/modules/plugins/theme/base16-colors.nix deleted file mode 100644 index 95ff2e82..00000000 --- a/modules/plugins/theme/base16-colors.nix +++ /dev/null @@ -1,69 +0,0 @@ -{lib}: let - inherit (lib.options) mkOption; - inherit (lib.nvim.types) hexColorType; -in { - base00 = mkOption { - type = hexColorType; - default = "#1e1e2e"; - }; - base01 = mkOption { - type = hexColorType; - default = "#181825"; - }; - base02 = mkOption { - type = hexColorType; - default = "#313244"; - }; - base03 = mkOption { - type = hexColorType; - default = "#45475a"; - }; - base04 = mkOption { - type = hexColorType; - default = "#585b70"; - }; - base05 = mkOption { - type = hexColorType; - default = "#cdd6f4"; - }; - base06 = mkOption { - type = hexColorType; - default = "#f5e0dc"; - }; - base07 = mkOption { - type = hexColorType; - default = "#b4befe"; - }; - base08 = mkOption { - type = hexColorType; - default = "#f38ba8"; - }; - base09 = mkOption { - type = hexColorType; - default = "#fab387"; - }; - base0A = mkOption { - type = hexColorType; - default = "#a6e3a1"; - }; - base0B = mkOption { - type = hexColorType; - default = "#94e2d5"; - }; - base0C = mkOption { - type = hexColorType; - default = "#a6e3a1"; - }; - base0D = mkOption { - type = hexColorType; - default = "#89b4fa"; - }; - base0E = mkOption { - type = hexColorType; - default = "#cba6f4"; - }; - base0F = mkOption { - type = hexColorType; - default = "#f2cdcd"; - }; -} diff --git a/modules/plugins/theme/supported-themes.nix b/modules/plugins/theme/supported-themes.nix index 24f54222..27951750 100644 --- a/modules/plugins/theme/supported-themes.nix +++ b/modules/plugins/theme/supported-themes.nix @@ -5,12 +5,11 @@ inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString warnIf; inherit (lib.nvim.lua) toLuaObject; - cfg = config.vim.theme; in { base16 = { setup = {base16-colors, ...}: '' - -- Base-16 theme - require('base16-colorscheme').setup(${toLuaObject cfg.base16-colors}) + -- Base16 theme + require('base16-colorscheme').setup(${toLuaObject base16-colors}) ''; }; onedark = { diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index ef79349a..9ab088a1 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -3,30 +3,43 @@ lib, ... }: let + inherit (builtins) listToAttrs; inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames; + inherit (lib.strings) hasPrefix; inherit (lib.types) bool lines enum; inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryBefore; + inherit (lib.nvim.types) hexColor; cfg = config.vim.theme; supportedThemes = import ./supported-themes.nix { inherit lib config; }; - base16-colors = import ./base16-colors.nix { - inherit lib; - }; + + numbers = lib.stringToCharacters "0123456789ABCDEF"; + generateBase16Options = listToAttrs (map (i: { + name = "base0${i}"; + value = mkOption { + type = hexColor; + apply = v: + if hasPrefix "#" v + then v + else "#${v}"; + }; + }) + numbers); in { options.vim.theme = { enable = mkOption { type = bool; description = "Enable theming"; }; - inherit base16-colors; name = mkOption { type = enum (attrNames supportedThemes); description = "Supported themes can be found in `supportedThemes.nix`"; }; + base16-colors = generateBase16Options; style = mkOption { type = enum supportedThemes.${cfg.name}.styles; From 423ed4d1d62d2bed1493586fcf6bacf1088bf82e Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 11:18:17 +0000 Subject: [PATCH 3/7] theme/theme.nix: fix up base16 helper func Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- modules/plugins/theme/theme.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index 9ab088a1..72a006d3 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -17,18 +17,18 @@ inherit lib config; }; - numbers = lib.stringToCharacters "0123456789ABCDEF"; - generateBase16Options = listToAttrs (map (i: { - name = "base0${i}"; - value = mkOption { - type = hexColor; - apply = v: - if hasPrefix "#" v - then v - else "#${v}"; - }; - }) - numbers); + numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]; + base16Options = listToAttrs (map (n: { + name = "base0${n}"; + value = mkOption { + description = "The base0${n} color to use"; + type = hexColor; + apply = v: + if hasPrefix "#" v + then v + else "#${v}"; + }; + }) numbers); in { options.vim.theme = { enable = mkOption { From 266f880561e9e68139867632d4a6f9eaa022cc89 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 14:55:19 +0200 Subject: [PATCH 4/7] theme/theme.nix: move listToAttrs inheriting, fix base16-colors declaration --- modules/plugins/theme/theme.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index 72a006d3..da590a3a 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -3,9 +3,8 @@ lib, ... }: let - inherit (builtins) listToAttrs; inherit (lib.options) mkOption; - inherit (lib.attrsets) attrNames; + inherit (lib.attrsets) attrNames listToAttrs; inherit (lib.strings) hasPrefix; inherit (lib.types) bool lines enum; inherit (lib.modules) mkIf; @@ -19,16 +18,17 @@ numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]; base16Options = listToAttrs (map (n: { - name = "base0${n}"; - value = mkOption { - description = "The base0${n} color to use"; - type = hexColor; - apply = v: - if hasPrefix "#" v - then v - else "#${v}"; - }; - }) numbers); + name = "base0${n}"; + value = mkOption { + description = "The base0${n} color to use"; + type = hexColor; + apply = v: + if hasPrefix "#" v + then v + else "#${v}"; + }; + }) + numbers); in { options.vim.theme = { enable = mkOption { @@ -39,7 +39,7 @@ in { type = enum (attrNames supportedThemes); description = "Supported themes can be found in `supportedThemes.nix`"; }; - base16-colors = generateBase16Options; + base16-colors = base16Options; style = mkOption { type = enum supportedThemes.${cfg.name}.styles; From 77239bee8371caaf60943012104b5338ee4e7838 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 15:37:03 +0200 Subject: [PATCH 5/7] theme/theme.nix: add documentation to vim.theme.name --- modules/plugins/theme/theme.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index da590a3a..a97992c6 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -37,7 +37,11 @@ in { }; name = mkOption { type = enum (attrNames supportedThemes); - description = "Supported themes can be found in `supportedThemes.nix`"; + description = '' + Supported themes can be found in `supportedThemes.nix`. + Setting the theme to "base16" enables base16 theming and + requires all of the colors in `vim.theme.base16-colors` to be set. + ''; }; base16-colors = base16Options; From 1ac041ba818d5bcaf531116f8de6f57056c3a1a8 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 15:41:32 +0200 Subject: [PATCH 6/7] release-notes/rl-0.7.md: add changelog entry for base16 --- docs/release-notes/rl-0.7.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 55746f2b..fe5c226d 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -204,3 +204,8 @@ everyone. - Add LSP and Treesitter support for R under `vim.languages.R`. - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with ccc + +[Bloxx12](https://github.com/Bloxx12) + +- Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under + `vim.theme` From a75da31d953187079b598fff0600d27f944844a6 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 5 Oct 2024 15:41:48 +0200 Subject: [PATCH 7/7] theme/theme.nix: fix documentation rendering --- modules/plugins/theme/theme.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index a97992c6..95d15d40 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -38,9 +38,9 @@ in { name = mkOption { type = enum (attrNames supportedThemes); description = '' - Supported themes can be found in `supportedThemes.nix`. + Supported themes can be found in {file}`supportedThemes.nix`. Setting the theme to "base16" enables base16 theming and - requires all of the colors in `vim.theme.base16-colors` to be set. + requires all of the colors in {option}`vim.theme.base16-colors` to be set. ''; }; base16-colors = base16Options;