Compare commits

...

13 commits

Author SHA1 Message Date
Charlie Root
013a6ddd9f
progress 2024-11-10 18:35:18 +01:00
Charlie Root
67fb3e00a4
theme/supported-themes.nix: use mergeAttrsList to generate options 2024-10-09 00:17:23 +02:00
Charlie Root
e9f9353c45
more mapAttrs
because diniamo loves it so much
2024-10-09 00:08:30 +02:00
Charlie Root
7c01a7c875
theme: switch to mapAttrs for setupOpts 2024-10-08 23:57:47 +02:00
Charlie Root
8f10028449
oxocarbon and gruvbox borked 2024-10-07 23:03:59 +02:00
Charlie Root
2c3350eb15
Merge branch 'NotAShelf:v0.7' into v0.7 2024-10-07 20:24:42 +00:00
Charlie Root
0fa8fbdf6f
theming: works now!!! 2024-10-07 22:24:04 +02:00
Charlie Root
c177916790
more changes 2024-10-07 17:47:08 +02:00
Charlie Root
59b8335a26
more progress 2024-10-07 10:47:17 +02:00
Charlie Root
b66ee19ff3
theme: finish switching to setupOpts, not building 2024-10-07 01:22:41 +02:00
Charlie Root
ba1c3645ee
theme/supported-themes.nix: switch to setupOpts 2024-10-07 00:16:22 +02:00
Charlie Root
b2ba2c0ab5
Merge branch 'NotAShelf:v0.7' into v0.7 2024-10-06 22:03:23 +00:00
Charlie Root
b41163959b
theme/supported-themes.nix: switch to setupOpts 2024-10-07 00:02:51 +02:00
11 changed files with 315 additions and 139 deletions

View file

@ -5,7 +5,7 @@ in {
vim.theme = { vim.theme = {
enable = mkDefault false; enable = mkDefault false;
name = mkDefault "onedark"; name = mkDefault "onedark";
style = mkDefault "darker"; # style = mkDefault "darker";
transparent = mkDefault false; transparent = mkDefault false;
extraConfig = mkDefault ""; extraConfig = mkDefault "";
}; };

View file

@ -2,105 +2,139 @@
config, config,
lib, lib,
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) hasPrefix optionalString;
inherit (lib.trivial) boolToString warnIf; inherit (lib.attrsets) genAttrs listToAttrs mergeAttrsList;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) bool str;
inherit (lib.nvim.types) hexColor mkPluginSetupOption;
cfg = config.vim.theme;
mkEnableOption' = name: mkEnableOption name // {default = true;};
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 { in {
base16 = { base16 = {
setup = {base16-colors, ...}: '' setupOpts = mkPluginSetupOption "base16" base16Options;
-- Base16 theme setup = "";
require('base16-colorscheme').setup(${toLuaObject base16-colors})
'';
}; };
onedark = { onedark = {
setup = {style ? "dark", ...}: '' setupOpts = mkPluginSetupOption "onedark" {
style = mkOption {
type = str;
default = cfg.style;
internal = true;
};
};
setup = ''
-- OneDark theme -- OneDark theme
require('onedark').setup {
style = "${style}"
}
require('onedark').load() require('onedark').load()
''; '';
styles = ["dark" "darker" "cool" "deep" "warm" "warmer"]; styles = ["dark" "darker" "cool" "deep" "warm" "warmer"];
}; };
tokyonight = { tokyonight = {
setup = { setupOpts = mkPluginSetupOption "tokyonight" {
style ? "night", transparent = mkOption {
transparent, type = bool;
... default = cfg.transparent;
}: '' internal = true;
require('tokyonight').setup { };
transparent = ${boolToString transparent}; };
} setup = ''
vim.cmd[[colorscheme tokyonight-${style}]] vim.cmd[[colorscheme tokyonight-${cfg.style}]]
''; '';
styles = ["day" "night" "storm" "moon"]; styles = ["night" "day" "storm" "moon"];
}; };
dracula = { dracula = {
setup = {transparent, ...}: '' setupOpts = mkPluginSetupOption "dracula" {
require('dracula').setup({ transparent_bg = mkOption {
transparent_bg = ${boolToString transparent}, type = bool;
}); default = cfg.transparent;
internal = true;
};
};
setup = ''
require('dracula').load(); require('dracula').load();
''; '';
}; };
catppuccin = { catppuccin = {
setup = { setupOpts = mkPluginSetupOption "catppuccin" {
style ? "mocha", flavour = mkOption {
transparent ? false, type = str;
... default = cfg.style;
}: '' # internal = true;
-- Catppuccin theme };
require('catppuccin').setup { transparent_background = mkOption {
flavour = "${style}", type = bool;
transparent_background = ${boolToString transparent}, default = cfg.transparent;
term_colors = true, internal = true;
integrations = { };
term_colors = mkEnableOption' "term_colors";
integrations =
{
nvimtree = { nvimtree = {
enabled = true, enabled = mkEnableOption' "enabled";
transparent_panel = ${boolToString transparent}, transparent_panel = mkOption {
show_root = true, type = bool;
}, default = cfg.transparent;
};
show_root = mkEnableOption' "show_root";
};
hop = true,
gitsigns = true,
telescope = true,
treesitter = true,
treesitter_context = true,
ts_rainbow = true,
fidget = true,
alpha = true,
leap = true,
markdown = true,
noice = true,
notify = true, -- nvim-notify
which_key = true,
navic = { navic = {
enabled = true, enabled = mkEnableOption' "enabled";
custom_bg = "NONE", -- "lualine" will set background to mantle # lualine will set backgound to mantle
}, custom_bg = mkOption {
}, type = str;
default = "NONE";
};
};
} }
// genAttrs [
"hop"
"gitsigns"
"telescope"
"treesitter"
"treesitter_context"
"ts_rainbow"
"fidget"
"alpha"
"leap"
"markdown"
"noice"
"notify"
"which_key"
] (name: mkEnableOption' name);
};
setup = ''
-- Catppuccin theme
-- setup must be called before loading -- setup must be called before loading
vim.cmd.colorscheme "catppuccin" vim.cmd.colorscheme "catppuccin"
''; '';
styles = ["latte" "frappe" "macchiato" "mocha"]; styles = ["mocha" "latte" "frappe" "macchiato"];
}; };
oxocarbon = { oxocarbon = {
setup = { setupOpts = {};
style ? "dark", setup = ''
transparent ? false,
}: let
style' =
warnIf (style == "light") "oxocarbon: light theme is not well-supported" style;
in ''
require('oxocarbon') require('oxocarbon')
vim.opt.background = "${style'}" vim.opt.background = "${cfg.style}"
vim.cmd.colorscheme = "oxocarbon" vim.cmd.colorscheme = "oxocarbon"
${optionalString transparent '' ${optionalString cfg.transparent ''
vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
vim.api.nvim_set_hl(0, "LineNr", { bg = "none" }) vim.api.nvim_set_hl(0, "LineNr", { bg = "none" })
@ -114,62 +148,84 @@ in {
}; };
gruvbox = { gruvbox = {
setup = { setupOpts =
style ? "dark", mkPluginSetupOption "gruvbox" {
transparent ? false, transparent_mode = mkOption {
}: '' type = bool;
default = cfg.transparent;
internal = true;
};
italic =
{
operators = mkEnableOption "operators";
}
// genAttrs [
"strings"
"emphasis"
"comments"
"folds"
] (name: mkEnableOption' name);
contrast = mkOption {
type = str;
default = "";
};
# TODO: fix these
# palette_overrides = mkLuaInline "{}";
# overrides = mkLuaInline "{}";
}
// mergeAttrsList [
(genAttrs [
"terminal_colors"
"undercurls"
"underline"
"bold"
"strikethrough"
"inverse"
] (name: mkEnableOption' name))
(genAttrs [
"invert_selection"
"invert_signs"
"invert_tabline"
"invert_intend_guides"
"dim_inactive"
] (name: mkEnableOption name))
];
setup = ''
-- Gruvbox theme -- Gruvbox theme
require("gruvbox").setup({ vim.o.background = "${cfg.style}"
terminal_colors = true, -- add neovim terminal colors
undercurl = true,
underline = true,
bold = true,
italic = {
strings = true,
emphasis = true,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
invert_intend_guides = false,
inverse = true,
contrast = "",
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = ${boolToString transparent},
})
vim.o.background = "${style}"
vim.cmd("colorscheme gruvbox") vim.cmd("colorscheme gruvbox")
''; '';
styles = ["dark" "light"]; styles = ["dark" "light"];
}; };
rose-pine = { rose-pine = {
setup = { setupOpts = mkPluginSetupOption "rose-pine" {
style ? "main", dark_variant = mkOption {
transparent ? false, type = str;
}: '' default = cfg.style;
require("rose-pine").setup({ internal = true;
dark_variant = "${style}", -- main, moon, or dawn };
dim_inactive_windows = false, dim_inactive_windows = mkEnableOption "dim_inactive_windows";
extend_background_behind_borders = true, extend_background_behind_borders = mkEnableOption' "extend_background_behind_borders";
enable = { enable = {
terminal = true, terminal = mkEnableOption' "terminal";
migrations = true, migrations = mkEnableOption' "migrations";
}, };
styles = { styles = {
bold = false, bold = mkEnableOption "bold";
italic = false, -- I would like to add more options for this # I would like to add more options for this
transparency = ${boolToString transparent}, italic = mkEnableOption "italic";
}, transparency = mkOption {
}) type = bool;
default = cfg.transparent;
internal = true;
};
};
};
setup = ''
vim.cmd("colorscheme rose-pine") vim.cmd("colorscheme rose-pine")
''; '';
styles = ["main" "moon" "dawn"]; styles = ["main" "moon" "dawn"];

View file

@ -0,0 +1,43 @@
{
config,
lib,
...
}: let
cfg = config.vim.theme;
inherit (lib.strings) hasPrefix;
inherit (lib.attrsets) listToAttrs;
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf;
inherit (lib.nvim.types) hexColor mkPluginSetupOption;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.lua) toLuaObject;
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 {
base16 = {
setupOpts = mkPluginSetupOption "base16" base16Options;
setup = "";
};
config =
mkIf cfg.name
== "base16" {
vim = {
startPlugins = ["base16"];
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
require('base16-colorscheme').setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

@ -0,0 +1,78 @@
{
config,
lib,
...
}: let
cfg = config.vim.theme;
inherit (lib.strings) hasPrefix optionalString;
inherit (lib.attrsets) genAttrs listToAttrs mergeAttrsList;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) bool str;
inherit (lib.modules) mkIf;
inherit (lib.nvim.types) hexColor mkPluginSetupOption;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.lua) toLuaObject;
mkEnableOption' = name: mkEnableOption name // {default = true;};
in {
catppuccin = {
setupOpts = mkPluginSetupOption "catppuccin" {
flavour = mkOption {
type = str;
default = cfg.style;
# internal = true;
};
transparent_background = mkOption {
type = bool;
default = cfg.transparent;
internal = true;
};
term_colors = mkEnableOption' "term_colors";
integrations =
{
nvimtree = {
enabled = mkEnableOption' "enabled";
transparent_panel = mkOption {
type = bool;
default = cfg.transparent;
};
show_root = mkEnableOption' "show_root";
};
navic = {
enabled = mkEnableOption' "enabled";
# lualine will set backgound to mantle
custom_bg = mkOption {
type = str;
default = "NONE";
};
};
}
// genAttrs [
"hop"
"gitsigns"
"telescope"
"treesitter"
"treesitter_context"
"ts_rainbow"
"fidget"
"alpha"
"leap"
"markdown"
"noice"
"notify"
"which_key"
] (name: mkEnableOption' name);
};
};
config =
mkIf cfg.name
== "catppuccin" {
vim = {
startPlugins = ["catppuccin"];
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
then "require('catppuccin').setup(${toLuaObject cfg.setupOpts})"
}
'';
};
};
}

View file

@ -4,33 +4,21 @@
... ...
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames listToAttrs; inherit (lib.attrsets) attrNames;
inherit (lib.strings) hasPrefix; inherit (lib.strings) elemAt;
inherit (lib.types) bool lines enum; inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.types) hexColor; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.theme; cfg = config.vim.theme;
supportedThemes = import ./supported-themes.nix { supportedThemes = import ./supported-themes.nix {
inherit lib config; inherit lib config;
}; };
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 { in {
options.vim.theme = { options.vim.theme = {
inherit (supportedThemes.${cfg.name}) setupOpts;
enable = mkOption { enable = mkOption {
type = bool; type = bool;
description = "Enable theming"; description = "Enable theming";
@ -43,10 +31,9 @@ in {
requires all of the colors in {option}`vim.theme.base16-colors` to be set. requires all of the colors in {option}`vim.theme.base16-colors` to be set.
''; '';
}; };
base16-colors = base16Options;
style = mkOption { style = mkOption {
type = enum supportedThemes.${cfg.name}.styles; type = enum supportedThemes.${cfg.name}.styles;
default = elemAt supportedThemes.${cfg.name}.styles 0;
description = "Specific style for theme if it supports it"; description = "Specific style for theme if it supports it";
}; };
transparent = mkOption { transparent = mkOption {
@ -62,11 +49,23 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = let
name' =
if cfg.name == "base16"
then "base16-colorscheme"
else cfg.name;
in {
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 base16-colors;}}
${
if name' != "oxocarbon"
then "require('${name'}').setup(${toLuaObject cfg.setupOpts})"
else ""
}
${supportedThemes.${cfg.name}.setup}
''; '';
}; };
}; };