Compare commits

...

6 commits

Author SHA1 Message Date
Charlie Root
e5c6a220fb
Merge 354dcbd573 into 108cfd8383 2024-10-03 12:41:35 +00:00
Charlie Root
354dcbd573
Merge branch 'main' into main 2024-10-03 12:41:32 +00:00
Charlie Root
c6bdea316b
Merge branch 'NotAShelf:main' into main 2024-09-30 18:17:11 +00:00
Charlie Root
77bd81b3c9
supported-themes.nix: formatting 2024-09-29 23:26:53 +02:00
Charlie Root
42e122ac6c
theme/theme.nix: fix formatting 2024-09-29 23:23:20 +02:00
Charlie Root
9c9dd1d670
modules: add base16 Theming support 2024-09-29 23:22:26 +02:00
7 changed files with 129 additions and 6 deletions

17
flake.lock generated
View file

@ -172,6 +172,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-base16-nvim": {
"flake": false,
"locked": {
"lastModified": 1716483968,
"narHash": "sha256-GRF/6AobXHamw8TZ3FjL7SI6ulcpwpcohsIuZeCSh2A=",
"owner": "rrethy",
"repo": "base16-nvim",
"rev": "6ac181b5733518040a33017dde654059cd771b7c",
"type": "github"
},
"original": {
"owner": "rrethy",
"repo": "base16-nvim",
"type": "github"
}
},
"plugin-bufdelete-nvim": { "plugin-bufdelete-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1802,6 +1818,7 @@
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nmd": "nmd", "nmd": "nmd",
"plugin-alpha-nvim": "plugin-alpha-nvim", "plugin-alpha-nvim": "plugin-alpha-nvim",
"plugin-base16-nvim": "plugin-base16-nvim",
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim", "plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
"plugin-catppuccin": "plugin-catppuccin", "plugin-catppuccin": "plugin-catppuccin",
"plugin-ccc": "plugin-ccc", "plugin-ccc": "plugin-ccc",

View file

@ -349,6 +349,11 @@
}; };
# Themes # Themes
plugin-base16-nvim = {
url = "github:rrethy/base16-nvim";
flake = false;
};
plugin-tokyonight = { plugin-tokyonight = {
url = "github:folke/tokyonight.nvim"; url = "github:folke/tokyonight.nvim";
flake = false; flake = false;

View file

@ -7,9 +7,11 @@
typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
typesCustom = import ./custom.nix {inherit lib;}; typesCustom = import ./custom.nix {inherit lib;};
typesTheme = import ./theme.nix {inherit lib;};
in { in {
inherit (typesDag) dagOf; inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (typesCustom) anythingConcatLists char; inherit (typesCustom) anythingConcatLists char;
inherit (typesTheme) hexColorType;
} }

13
lib/types/theme.nix Normal file
View file

@ -0,0 +1,13 @@
{lib}: let
inherit (lib.strings) isString hasPrefix;
inherit (lib.types) mkOptionType;
inherit (builtins) stringLength;
# This was almost entirely taken from raf himself.
in {
hexColorType = mkOptionType {
name = "hex-color";
descriptionClass = "noun";
description = "RGB color in hex format";
check = x: isString x && hasPrefix "#" x && stringLength x == 7;
};
}

View file

@ -0,0 +1,72 @@
{
config,
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";
};
}

View file

@ -4,7 +4,15 @@
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString warnIf; inherit (lib.trivial) boolToString warnIf;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.theme;
in { in {
base16-nvim = {
setup = {base16-colors, ...}: ''
-- Base-16 theme
require('base16-colorscheme').setup(${toLuaObject cfg.base16-colors})
'';
};
onedark = { onedark = {
setup = {style ? "dark", ...}: '' setup = {style ? "dark", ...}: ''
-- OneDark theme -- OneDark theme
@ -20,6 +28,7 @@ in {
setup = { setup = {
style ? "night", style ? "night",
transparent, transparent,
...
}: '' }: ''
require('tokyonight').setup { require('tokyonight').setup {
transparent = ${boolToString transparent}; transparent = ${boolToString transparent};
@ -42,6 +51,7 @@ in {
setup = { setup = {
style ? "mocha", style ? "mocha",
transparent ? false, transparent ? false,
...
}: '' }: ''
-- Catppuccin theme -- Catppuccin theme
require('catppuccin').setup { require('catppuccin').setup {

View file

@ -13,13 +13,16 @@
supportedThemes = import ./supported-themes.nix { supportedThemes = import ./supported-themes.nix {
inherit lib config; inherit lib config;
}; };
base16-colors = import ./base16-colors.nix {
inherit lib config;
};
in { in {
options.vim.theme = { options.vim.theme = {
enable = mkOption { enable = mkOption {
type = bool; type = bool;
description = "Enable theming"; description = "Enable theming";
}; };
inherit base16-colors;
name = mkOption { name = mkOption {
type = enum (attrNames supportedThemes); type = enum (attrNames supportedThemes);
description = "Supported themes can be found in `supportedThemes.nix`"; description = "Supported themes can be found in `supportedThemes.nix`";
@ -29,7 +32,6 @@ in {
type = enum supportedThemes.${cfg.name}.styles; type = enum supportedThemes.${cfg.name}.styles;
description = "Specific style for theme if it supports it"; description = "Specific style for theme if it supports it";
}; };
transparent = mkOption { transparent = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -45,10 +47,12 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = [cfg.name]; startPlugins = [cfg.name];
luaConfigRC.theme = entryBefore ["pluginConfigs"] '' luaConfigRC = {
theme = entryBefore ["pluginConfigs"] ''
${cfg.extraConfig} ${cfg.extraConfig}
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}} ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
''; '';
}; };
}; };
};
} }