theme/supported-themes.nix: switch to setupOpts

This commit is contained in:
Charlie Root 2024-10-07 00:02:51 +02:00
parent 3299facbaa
commit b41163959b
No known key found for this signature in database

View file

@ -3,86 +3,79 @@
lib, lib,
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString warnIf; inherit (lib.modules) mkDefault;
inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.theme;
in { in {
base16 = { base16 = {
setup = {base16-colors, ...}: '' setupOpts = {
-- Base16 theme inherit (cfg) base16-colors;
require('base16-colorscheme').setup(${toLuaObject base16-colors}) };
'';
}; };
onedark = { onedark = {
setup = {style ? "dark", ...}: '' setupOpts = {
style = cfg.style ? "dark";
};
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 = {
style ? "night", inherit (cfg) transparent;
transparent, };
... setup = {style ? "night", ...}: ''
}: ''
require('tokyonight').setup {
transparent = ${boolToString transparent};
}
vim.cmd[[colorscheme tokyonight-${style}]] vim.cmd[[colorscheme tokyonight-${style}]]
''; '';
styles = ["day" "night" "storm" "moon"]; styles = ["day" "night" "storm" "moon"];
}; };
dracula = { dracula = {
setup = {transparent, ...}: '' setupOpts = {
require('dracula').setup({ transparent_bg = cfg.transparent;
transparent_bg = ${boolToString transparent}, };
}); setup = _: ''
require('dracula').load(); require('dracula').load();
''; '';
}; };
catppuccin = { catppuccin = {
setup = { setupOpts = {
style ? "mocha", flavour = cfg.style ? "mocha";
transparent ? false, transparent_background = cfg.transparent;
... term_colors = mkDefault true;
}: ''
-- Catppuccin theme
require('catppuccin').setup {
flavour = "${style}",
transparent_background = ${boolToString transparent},
term_colors = true,
integrations = { integrations = {
nvimtree = { nvimtree = {
enabled = true, enabled = mkDefault true;
transparent_panel = ${boolToString transparent}, transparent_panel = cfg.transparent;
show_root = true, show_root = mkDefault true;
}, };
hop = true, hop = mkDefault true;
gitsigns = true, gitsigns = mkDefault true;
telescope = true, telescope = mkDefault true;
treesitter = true, treesitter = mkDefault true;
treesitter_context = true, treesitter_context = mkDefault true;
ts_rainbow = true, ts_rainbow = mkDefault true;
fidget = true, fidget = mkDefault true;
alpha = true, alpha = mkDefault true;
leap = true, leap = mkDefault true;
markdown = true, markdown = mkDefault true;
noice = true, noice = mkDefault true;
notify = true, -- nvim-notify # nvim-notify
which_key = true, notify = mkDefault true;
which_key = mkDefault true;
navic = { navic = {
enabled = true, enabled = mkDefault true;
custom_bg = "NONE", -- "lualine" will set background to mantle # lualine will set backgound to mantle
}, custom_bg = "NONE";
}, };
} };
};
setup = _: ''
-- Catppuccin theme
-- setup must be called before loading -- setup must be called before loading
vim.cmd.colorscheme "catppuccin" vim.cmd.colorscheme "catppuccin"
''; '';
@ -90,17 +83,12 @@ in {
}; };
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 ? "dark"}"
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 +102,58 @@ in {
}; };
gruvbox = { gruvbox = {
setup = { setupOpts = {
style ? "dark", transparent_mode = cfg.transparent;
transparent ? false, # add neovim terminal colors
}: '' terminal_colors = mkDefault true;
-- Gruvbox theme undercurl = mkDefault true;
require("gruvbox").setup({ underline = mkDefault true;
terminal_colors = true, -- add neovim terminal colors bold = mkDefault true;
undercurl = true,
underline = true,
bold = true,
italic = { italic = {
strings = true, strings = mkDefault true;
emphasis = true, emphasis = mkDefault true;
comments = true, comments = mkDefault true;
operators = false, operators = mkDefault false;
folds = true, folds = mkDefault true;
}, };
strikethrough = true, strikethrough = mkDefault true;
invert_selection = false, invert_selection = mkDefault false;
invert_signs = false, invert_signs = mkDefault false;
invert_tabline = false, invert_tabline = mkDefault false;
invert_intend_guides = false, invert_intend_guides = mkDefault false;
inverse = true, inverse = mkDefault true;
contrast = "", contrast = "";
palette_overrides = {}, palette_overrides = {};
overrides = {}, overrides = {};
dim_inactive = false, dim_inactive = mkDefault false;
transparent_mode = ${boolToString transparent}, };
}) setup = _: ''
vim.o.background = "${style}" -- Gruvbox theme
vim.o.background = "${cfg.style ? "dark"}"
vim.cmd("colorscheme gruvbox") vim.cmd("colorscheme gruvbox")
''; '';
styles = ["dark" "light"]; styles = ["dark" "light"];
}; };
rose-pine = { rose-pine = {
setup = { setupOpts = {
style ? "main", dark_variant = cfg.style ? "main";
transparent ? false, dim_inactive_windows = mkDefault false;
}: '' extend_background_behind_borders = mkDefault true;
require("rose-pine").setup({
dark_variant = "${style}", -- main, moon, or dawn
dim_inactive_windows = false,
extend_background_behind_borders = true,
enable = { enable = {
terminal = true, terminal = mkDefault true;
migrations = true, migrations = mkDefault true;
}, };
styles = { styles = {
bold = false, bold = mkDefault false;
italic = false, -- I would like to add more options for this # I would like to add more options for this
transparency = ${boolToString transparent}, italic = mkDefault false;
}, transparency = cfg.transparent;
}) };
};
setup = _: ''
vim.cmd("colorscheme rose-pine") vim.cmd("colorscheme rose-pine")
''; '';
styles = ["main" "moon" "dawn"]; styles = ["main" "moon" "dawn"];