diff options
Diffstat (limited to 'bin/udt-palette')
| -rwxr-xr-x | bin/udt-palette | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/bin/udt-palette b/bin/udt-palette index 234d97a..6a15a52 100755 --- a/bin/udt-palette +++ b/bin/udt-palette @@ -28,7 +28,8 @@ SELECTOR = Path.home() / ".config" / "udt" / "roles.conf" SELECTOR_SEED = PALETTE_DIR / "roles.conf.default" # The Lua dashboard lives in its own repo; UDT only renders its colours. -CONKY_REPO = Path("~/Programming/GIT/conky-theme-udt").expanduser() +# A sibling checkout, like waybar-theme-udt; skipped when it is not cloned. +CONKY_REPO = REPO.parent / "conky-theme-udt" def parse_conf(path): @@ -267,6 +268,47 @@ def gen_kitty(res, scheme, palette): return "\n".join(lines) + "\n" +# Catppuccin's 26 names, and the role that stands in for each when the scheme +# does not define that name itself. +NVIM_NAMES = [ + ("rosewater", "cursor"), ("flamingo", "cursor"), ("pink", "magenta"), + ("mauve", "highlight"), ("red", "red"), ("maroon", "bright_red"), + ("peach", "peach"), ("yellow", "yellow"), ("green", "green"), + ("teal", "cyan"), ("sky", "bright_cyan"), ("sapphire", "bright_blue"), + ("blue", "blue"), ("lavender", "accent"), + ("text", "fg"), ("subtext1", "fg_bright"), ("subtext0", "fg_dim"), + ("overlay2", "mid_high"), ("overlay1", "mid_low"), ("overlay0", "fg_faint"), + ("surface2", "surface_high"), ("surface1", "surface_alt"), + ("surface0", "surface"), + ("base", "bg"), ("mantle", "bg_alt"), ("crust", "bg_deep"), +] + + +def gen_nvim(res, scheme, palette): + """neovim: a colorscheme that is catppuccin/nvim with every colour replaced. + + catppuccin's highlight groups are written against its 26 palette names, so + overriding all of them re-skins the whole editor without restating a single + group. The Catppuccin schemes define those names and pass straight through; + the rest are filled from roles, so a few near-duplicate hues (maroon, sky, + sapphire, flamingo) collapse onto their neighbours there. + """ + rows = "\n".join( + f' {name} = "{palette[name].lower() if name in palette else hex6(res[role])}",' + for name, role in NVIM_NAMES) + return ( + f"-- {BANNER.format(scheme=scheme)}\n" + "-- Selected with `colorscheme udt`. Needs the catppuccin/nvim plugin.\n" + f"local colors = {{\n{rows}\n}}\n\n" + "require(\"catppuccin\").setup({\n" + " flavour = \"macchiato\",\n" + " color_overrides = { macchiato = colors },\n" + "})\n" + "vim.cmd.colorscheme(\"catppuccin-macchiato\")\n" + "vim.g.colors_name = \"udt\"\n" + ) + + def gen_hyprlock(res, scheme, palette): """hyprlock: the lock screen's scheme-level palette, as hyprlang variables. @@ -743,6 +785,7 @@ TARGETS = [ ("templates/waybar/theme.css", gen_waybar, None), ("templates/terminal/kitty-theme.conf", gen_kitty, None), ("templates/hyprlock/hyprlock-palette.conf", gen_hyprlock, None), + ("templates/nvim/udt.lua", gen_nvim, None), (str(CONKY_REPO / "conky.conf"), gen_conky, str(CONKY_REPO / "conky.conf.in")), ("bin/udt_colors.py", gen_accent_py, None), ("templates/homepage/custom.css", gen_homepage, None), @@ -774,6 +817,10 @@ def generate(roles_path, out_dir, scheme=None): scheme, palette, res, snap_names = load(roles_path, scheme=scheme) written = [] for target, fn, template in TARGETS: + # A sibling repo that is not cloned here is not an error: its + # template is missing too, and there is nothing to theme. + if Path(target).is_absolute() and not Path(target).parent.is_dir(): + continue # A target outside this repo (the conky dashboard) is an absolute path, # and `out_dir / absolute` discards out_dir entirely. For the real # render that is what we want, since the file genuinely belongs at that |
