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 = {
enable = mkDefault false;
name = mkDefault "onedark";
style = mkDefault "darker";
# style = mkDefault "darker";
transparent = mkDefault false;
extraConfig = mkDefault "";
};

View file

@ -2,105 +2,139 @@
config,
lib,
}: let
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString warnIf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.strings) hasPrefix optionalString;
inherit (lib.attrsets) genAttrs listToAttrs mergeAttrsList;
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 {
base16 = {
setup = {base16-colors, ...}: ''
-- Base16 theme
require('base16-colorscheme').setup(${toLuaObject base16-colors})
'';
setupOpts = mkPluginSetupOption "base16" base16Options;
setup = "";
};
onedark = {
setup = {style ? "dark", ...}: ''
setupOpts = mkPluginSetupOption "onedark" {
style = mkOption {
type = str;
default = cfg.style;
internal = true;
};
};
setup = ''
-- OneDark theme
require('onedark').setup {
style = "${style}"
}
require('onedark').load()
'';
styles = ["dark" "darker" "cool" "deep" "warm" "warmer"];
};
tokyonight = {
setup = {
style ? "night",
transparent,
...
}: ''
require('tokyonight').setup {
transparent = ${boolToString transparent};
}
vim.cmd[[colorscheme tokyonight-${style}]]
setupOpts = mkPluginSetupOption "tokyonight" {
transparent = mkOption {
type = bool;
default = cfg.transparent;
internal = true;
};
};
setup = ''
vim.cmd[[colorscheme tokyonight-${cfg.style}]]
'';
styles = ["day" "night" "storm" "moon"];
styles = ["night" "day" "storm" "moon"];
};
dracula = {
setup = {transparent, ...}: ''
require('dracula').setup({
transparent_bg = ${boolToString transparent},
});
setupOpts = mkPluginSetupOption "dracula" {
transparent_bg = mkOption {
type = bool;
default = cfg.transparent;
internal = true;
};
};
setup = ''
require('dracula').load();
'';
};
catppuccin = {
setup = {
style ? "mocha",
transparent ? false,
...
}: ''
-- Catppuccin theme
require('catppuccin').setup {
flavour = "${style}",
transparent_background = ${boolToString transparent},
term_colors = true,
integrations = {
nvimtree = {
enabled = true,
transparent_panel = ${boolToString transparent},
show_root = true,
},
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";
};
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 = {
enabled = true,
custom_bg = "NONE", -- "lualine" will set background to mantle
},
},
}
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);
};
setup = ''
-- Catppuccin theme
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin"
'';
styles = ["latte" "frappe" "macchiato" "mocha"];
styles = ["mocha" "latte" "frappe" "macchiato"];
};
oxocarbon = {
setup = {
style ? "dark",
transparent ? false,
}: let
style' =
warnIf (style == "light") "oxocarbon: light theme is not well-supported" style;
in ''
setupOpts = {};
setup = ''
require('oxocarbon')
vim.opt.background = "${style'}"
vim.opt.background = "${cfg.style}"
vim.cmd.colorscheme = "oxocarbon"
${optionalString transparent ''
${optionalString cfg.transparent ''
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
vim.api.nvim_set_hl(0, "LineNr", { bg = "none" })
@ -114,62 +148,84 @@ in {
};
gruvbox = {
setup = {
style ? "dark",
transparent ? false,
}: ''
setupOpts =
mkPluginSetupOption "gruvbox" {
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
require("gruvbox").setup({
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.o.background = "${cfg.style}"
vim.cmd("colorscheme gruvbox")
'';
styles = ["dark" "light"];
};
rose-pine = {
setup = {
style ? "main",
transparent ? false,
}: ''
require("rose-pine").setup({
dark_variant = "${style}", -- main, moon, or dawn
dim_inactive_windows = false,
extend_background_behind_borders = true,
setupOpts = mkPluginSetupOption "rose-pine" {
dark_variant = mkOption {
type = str;
default = cfg.style;
internal = true;
};
dim_inactive_windows = mkEnableOption "dim_inactive_windows";
extend_background_behind_borders = mkEnableOption' "extend_background_behind_borders";
enable = {
terminal = true,
migrations = true,
},
enable = {
terminal = mkEnableOption' "terminal";
migrations = mkEnableOption' "migrations";
};
styles = {
bold = false,
italic = false, -- I would like to add more options for this
transparency = ${boolToString transparent},
},
})
styles = {
bold = mkEnableOption "bold";
# I would like to add more options for this
italic = mkEnableOption "italic";
transparency = mkOption {
type = bool;
default = cfg.transparent;
internal = true;
};
};
};
setup = ''
vim.cmd("colorscheme rose-pine")
'';
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
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames listToAttrs;
inherit (lib.strings) hasPrefix;
inherit (lib.attrsets) attrNames;
inherit (lib.strings) elemAt;
inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.types) hexColor;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.theme;
supportedThemes = import ./supported-themes.nix {
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 {
options.vim.theme = {
inherit (supportedThemes.${cfg.name}) setupOpts;
enable = mkOption {
type = bool;
description = "Enable theming";
@ -43,10 +31,9 @@ in {
requires all of the colors in {option}`vim.theme.base16-colors` to be set.
'';
};
base16-colors = base16Options;
style = mkOption {
type = enum supportedThemes.${cfg.name}.styles;
default = elemAt supportedThemes.${cfg.name}.styles 0;
description = "Specific style for theme if it supports it";
};
transparent = mkOption {
@ -62,11 +49,23 @@ in {
};
config = mkIf cfg.enable {
vim = {
vim = let
name' =
if cfg.name == "base16"
then "base16-colorscheme"
else cfg.name;
in {
startPlugins = [cfg.name];
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
${cfg.extraConfig}
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
${cfg.extraConfig}
${
if name' != "oxocarbon"
then "require('${name'}').setup(${toLuaObject cfg.setupOpts})"
else ""
}
${supportedThemes.${cfg.name}.setup}
'';
};
};