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 { require('onedark').load()
style = "${style}"
}
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;
}: '' integrations = {
-- Catppuccin theme nvimtree = {
require('catppuccin').setup { enabled = mkDefault true;
flavour = "${style}", transparent_panel = cfg.transparent;
transparent_background = ${boolToString transparent}, show_root = mkDefault true;
term_colors = true, };
integrations = {
nvimtree = {
enabled = true,
transparent_panel = ${boolToString transparent},
show_root = 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;
navic = { which_key = mkDefault true;
enabled = true, navic = {
custom_bg = "NONE", -- "lualine" will set background to mantle enabled = mkDefault true;
}, # 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;
undercurl = mkDefault true;
underline = mkDefault true;
bold = mkDefault true;
italic = {
strings = mkDefault true;
emphasis = mkDefault true;
comments = mkDefault true;
operators = mkDefault false;
folds = mkDefault true;
};
strikethrough = mkDefault true;
invert_selection = mkDefault false;
invert_signs = mkDefault false;
invert_tabline = mkDefault false;
invert_intend_guides = mkDefault false;
inverse = mkDefault true;
contrast = "";
palette_overrides = {};
overrides = {};
dim_inactive = mkDefault false;
};
setup = _: ''
-- Gruvbox theme -- Gruvbox theme
require("gruvbox").setup({ vim.o.background = "${cfg.style ? "dark"}"
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 = {
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"];