theme: add minimal transparency support for oxocarbon

This commit is contained in:
Frothy 2024-05-23 09:51:05 -04:00
parent 1061c920be
commit fc4e471490
2 changed files with 29 additions and 12 deletions

View file

@ -1,4 +1,10 @@
{lib}: { {
config,
lib,
}: let
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString warnIf;
in {
onedark = { onedark = {
setup = { setup = {
style ? "dark", style ? "dark",
@ -19,7 +25,7 @@
transparent, transparent,
}: '' }: ''
require('tokyonight').setup { require('tokyonight').setup {
transparent = ${lib.boolToString transparent}; transparent = ${boolToString transparent};
} }
vim.cmd[[colorscheme tokyonight-${style}]] vim.cmd[[colorscheme tokyonight-${style}]]
''; '';
@ -32,7 +38,7 @@
transparent, transparent,
}: '' }: ''
require('dracula').setup({ require('dracula').setup({
transparent_bg = ${lib.boolToString transparent}, transparent_bg = ${boolToString transparent},
}); });
require('dracula').load(); require('dracula').load();
''; '';
@ -46,11 +52,11 @@
-- Catppuccin theme -- Catppuccin theme
require('catppuccin').setup { require('catppuccin').setup {
flavour = "${style}", flavour = "${style}",
transparent_background = ${lib.boolToString transparent}, transparent_background = ${boolToString transparent},
integrations = { integrations = {
nvimtree = { nvimtree = {
enabled = true, enabled = true,
transparent_panel = ${lib.boolToString transparent}, transparent_panel = ${boolToString transparent},
show_root = true, show_root = true,
}, },
@ -85,11 +91,20 @@
transparent ? false, transparent ? false,
}: let }: let
style' = style' =
lib.warnIf (style == "light") "oxocarbon: light theme is not well-supported" style; warnIf (style == "light") "oxocarbon: light theme is not well-supported" style;
in '' in ''
require('oxocarbon') require('oxocarbon')
vim.opt.background = "${style'}" vim.opt.background = "${style'}"
vim.cmd.colorscheme = "oxocarbon" vim.cmd.colorscheme = "oxocarbon"
${optionalString 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" })
vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" })
${lib.optionalString config.vim.filetree.nvimTree.enable ''
vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "none" })
''}
''}
''; '';
styles = ["dark" "light"]; styles = ["dark" "light"];
}; };
@ -122,7 +137,7 @@
palette_overrides = {}, palette_overrides = {},
overrides = {}, overrides = {},
dim_inactive = false, dim_inactive = false,
transparent_mode = ${lib.boolToString transparent}, transparent_mode = ${boolToString transparent},
}) })
vim.o.background = "${style}" vim.o.background = "${style}"
vim.cmd("colorscheme gruvbox") vim.cmd("colorscheme gruvbox")
@ -147,7 +162,7 @@
styles = { styles = {
bold = false, bold = false,
italic = false, -- I would like to add more options for this italic = false, -- I would like to add more options for this
transparency = ${lib.boolToString transparent}, transparency = ${boolToString transparent},
}, },
}) })

View file

@ -10,7 +10,9 @@
inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.dag) entryBefore;
cfg = config.vim.theme; cfg = config.vim.theme;
supported_themes = import ./supported_themes.nix {inherit lib;}; supported_themes = import ./supported_themes.nix {
inherit lib config;
};
in { in {
options.vim.theme = { options.vim.theme = {
enable = mkOption { enable = mkOption {