From 8e55044f1e0c98e600edcc1355dc625325b5f562 Mon Sep 17 00:00:00 2001 From: Malo Bourgon Date: Sat, 28 Dec 2024 14:50:06 -0500 Subject: [PATCH] Try out OK Solar colorpalette --- configs/nvim/lua/lush_theme/malo.lua | 2 +- configs/nvim/lua/malo/theme.lua | 34 +++---- darwin/homebrew.nix | 5 +- home/colors.nix | 140 ++++++++++++++++++++++----- home/ghostty.nix | 14 +-- home/neovim.nix | 18 +++- 6 files changed, 159 insertions(+), 54 deletions(-) diff --git a/configs/nvim/lua/lush_theme/malo.lua b/configs/nvim/lua/lush_theme/malo.lua index 77c015c2f..a7cb16968 100644 --- a/configs/nvim/lua/lush_theme/malo.lua +++ b/configs/nvim/lua/lush_theme/malo.lua @@ -7,7 +7,7 @@ local c = require'malo.theme'.colors -- Function to set/update colors that are dependant on `vim.o.background` local function choose(dark, light) return vim.o.background == 'dark' and dark or light end local function highlight(color) - return vim.o.background == 'dark' and color.lightness(20) or color.lightness(80) + return vim.o.background == 'dark' and color.darken(50) or color.lighten(50) end ---@diagnostic disable: undefined-global diff --git a/configs/nvim/lua/malo/theme.lua b/configs/nvim/lua/malo/theme.lua index 9b303df35..194087aa0 100644 --- a/configs/nvim/lua/malo/theme.lua +++ b/configs/nvim/lua/malo/theme.lua @@ -3,29 +3,29 @@ -- Still early days, with lots of work needed -- https://github.com/rktjmp/lush.nvim local lush = require 'lush' -local hsl = lush.hsl +local hsluv = lush.hsluv local seq = require 'pl.seq' local M = {} -- Default colors are the Solarized colors M.colors = { - darkBase = hsl '#002b36', -- base03 - darkBaseHl = hsl '#073642', -- base02 - darkestTone = hsl '#586e75', -- base01 - darkTone = hsl '#657b83', -- base00 - lightTone = hsl '#839496', -- base0 - lightestTone = hsl '#93a1a1', -- base1 - lightBaseHl = hsl '#eee8d5', -- base2 - lightBase = hsl '#fdf6e3', -- base3 - yellow = hsl '#b58900', - orange = hsl '#cb4b16', - red = hsl '#dc322f', - magenta = hsl '#d33682', - violet = hsl '#6c71c4', - blue = hsl '#268bd2', - cyan = hsl '#2aa198', - green = hsl '#859900', + darkBase = hsluv (vim.g.theme_base03 or '#002b36'), + darkBaseHl = hsluv (vim.g.theme_base02 or '#073642'), + darkestTone = hsluv (vim.g.theme_base01 or '#586e75'), + darkTone = hsluv (vim.g.theme_base00 or '#657b83'), + lightTone = hsluv (vim.g.theme_base0 or '#839496'), + lightestTone = hsluv (vim.g.theme_base1 or '#93a1a1'), + lightBaseHl = hsluv (vim.g.theme_base2 or '#eee8d5'), + lightBase = hsluv (vim.g.theme_base3 or '#fdf6e3'), + yellow = hsluv (vim.g.theme_yellow or '#b58900'), + orange = hsluv (vim.g.theme_orange or '#cb4b16'), + red = hsluv (vim.g.theme_red or '#dc322f'), + magenta = hsluv (vim.g.theme_magenta or '#d33682'), + violet = hsluv (vim.g.theme_violet or '#6c71c4'), + blue = hsluv (vim.g.theme_blue or '#268bd2'), + cyan = hsluv (vim.g.theme_cyan or '#2aa198'), + green = hsluv (vim.g.theme_green or '#859900'), } -- A table of strings with the name of additonal Lush specs that should be merged with the diff --git a/darwin/homebrew.nix b/darwin/homebrew.nix index b8a77d8cb..7d30ce5ec 100644 --- a/darwin/homebrew.nix +++ b/darwin/homebrew.nix @@ -124,8 +124,9 @@ in }; # Hack: https://github.com/ghostty-org/ghostty/discussions/2832 - environment.variables.XDG_DATA_DIRS = - mkIf (caskPresent "ghostty") ["$GHOSTTY_SHELL_INTEGRATION_XDG_DIR"]; + environment.variables.XDG_DATA_DIRS = mkIf (caskPresent "ghostty") [ + "$GHOSTTY_SHELL_INTEGRATION_XDG_DIR" + ]; # For cli packages that aren't currently available for macOS in `nixpkgs`. Packages should be # installed in `../home/packages.nix` whenever possible. diff --git a/home/colors.nix b/home/colors.nix index 8336dafe1..e56016ea4 100644 --- a/home/colors.nix +++ b/home/colors.nix @@ -1,4 +1,4 @@ -# Colors from: https://ethanschoonover.com/solarized +# Colors from: https://ethanschoonover.com/solarized ---------------------------------------------- # SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B RGB HSB # --------- ------- ---- ------- ----------- ---------- ----------- ----------- @@ -19,29 +19,30 @@ # cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63 # green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60 -{ config, ... }: +# Colors from: https://meat.io/oksolar ------------------------------------------------------------ -{ - colors.solarized-light = { - colors = { - color0 = "#073642"; - color1 = "#dc322f"; - color2 = "#859900"; - color3 = "#b58900"; - color4 = "#268bd2"; - color5 = "#d33682"; - color6 = "#2aa198"; - color7 = "#eee8d5"; - color8 = "#002b36"; - color9 = "#cb4b16"; - color10 = "#586e75"; - color11 = "#657b83"; - color12 = "#839496"; - color13 = "#6c71c4"; - color14 = "#93a1a1"; - color15 = "#fdf6e3"; - }; +# Name OK Lightness Chrome Hue Hex +# base03 27.4% 0.05 219.6 #002d38 +# base02 32.1% 0.053 219.6 #093946 +# base01 53.5% 0.029 219.6 #5b7279 +# base00 54.4% 0.017 219.6 #657377 +# base0 71.8% 0.017 198 #98a8a8 +# base1 71.8% 0.03 198 #8faaab +# base2 93.4% 0.031 90 #f1e9d2 +# base3 97.7% 0.012 90 #fbf7ef +# yellow 63.1% 0.129 86.4 #ac8300 +# orange 63.1% 0.166 50.4 #d56500 +# red 63.1% 0.221 21.6 #f23749 +# magenta 63.1% 0.205 349.2 #dd459d +# violet 63.1% 0.121 280.8 #7d80d1 +# blue 63.1% 0.141 244.8 #2b90d8 +# cyan 63.1% 0.102 187.2 #259d94 +# green 63.1% 0.148 118.8 #819500 +{ config, ... }: + +let + commonLight = { namedColors = { # Solarized names base03 = "color8"; @@ -81,8 +82,8 @@ }; }; - colors.solarized-dark = { - inherit (config.colors.solarized-light) colors namedColors; + commonDark = { + inherit (commonLight) namedColors; terminal = { bg = "base03"; @@ -94,7 +95,7 @@ }; pkgThemes.kitty = { - inherit (config.colors.solarized-light.pkgThemes.kitty) + inherit (commonLight.pkgThemes.kitty) url_color active_tab_background active_tab_foreground @@ -105,4 +106,93 @@ inactive_tab_foreground = "base1"; }; }; +in + +{ + colors.solarized-light = { + colors = { + color0 = "#073642"; + color1 = "#dc322f"; + color2 = "#859900"; + color3 = "#b58900"; + color4 = "#268bd2"; + color5 = "#d33682"; + color6 = "#2aa198"; + color7 = "#eee8d5"; + color8 = "#002b36"; + color9 = "#cb4b16"; + color10 = "#586e75"; + color11 = "#657b83"; + color12 = "#839496"; + color13 = "#6c71c4"; + color14 = "#93a1a1"; + color15 = "#fdf6e3"; + }; + + inherit (commonLight) namedColors terminal pkgThemes; + }; + + colors.solarized-dark = { + inherit (config.colors.solarized-light) colors; + + inherit (commonDark) namedColors terminal pkgThemes; + }; + + colors.ok-solar-light = { + colors = { + color0 = "#093946"; + color1 = "#f23749"; + color2 = "#819500"; + color3 = "#ac8300"; + color4 = "#2b90d8"; + color5 = "#dd459d"; + color6 = "#259d94"; + color7 = "#f1e9d2"; + color8 = "#002d38"; + color9 = "#d56500"; + color10 = "#5b7279"; + color11 = "#657377"; + color12 = "#98a8a8"; + color13 = "#7d80d1"; + color14 = "#8faaab"; + color15 = "#fbf7ef"; + }; + + inherit (commonLight) namedColors terminal pkgThemes; + }; + + colors.ok-solar-dark = { + inherit (config.colors.ok-solar-light) colors; + + inherit (commonDark) namedColors terminal pkgThemes; + }; + + colors.malo-ok-solar-light = { + colors = { + color0 = "#093946"; + color1 = "#f23749"; + color2 = "#819500"; + color3 = "#ac8300"; + color4 = "#2b90d8"; + color5 = "#dd459d"; + color6 = "#259d94"; + color7 = "#ece9e0"; # changed chroma to 0.012 to match base3 + color8 = "#002d38"; + color9 = "#d56500"; + color10 = "#5b7279"; + color11 = "#657377"; + color12 = "#98a8a8"; + color13 = "#7d80d1"; + color14 = "#8faaab"; + color15 = "#fbf7ef"; + }; + + inherit (commonLight) namedColors terminal pkgThemes; + }; + + colors.malo-ok-solar-dark = { + inherit (config.colors.malo-ok-solar-light) colors; + + inherit (commonDark) namedColors terminal pkgThemes; + }; } diff --git a/home/ghostty.nix b/home/ghostty.nix index 90a48817b..ca603ced4 100644 --- a/home/ghostty.nix +++ b/home/ghostty.nix @@ -10,11 +10,11 @@ let in { - xdg.configFile."ghostty/themes/Solarized Light".text = - mkThemeConfig config.colors.solarized-light.pkgThemes.ghostty; + xdg.configFile."ghostty/themes/light".text = + mkThemeConfig config.colors.malo-ok-solar-light.pkgThemes.ghostty; - xdg.configFile."ghostty/themes/Solarized Dark".text = - mkThemeConfig config.colors.solarized-dark.pkgThemes.ghostty; + xdg.configFile."ghostty/themes/dark".text = + mkThemeConfig config.colors.malo-ok-solar-dark.pkgThemes.ghostty; xdg.configFile."ghostty/config".text = toKeyValue { mkKeyValue = mkKeyValueDefault { } " = "; } { font-family = "PragmataPro Liga"; @@ -27,11 +27,11 @@ in adjust-box-thickness = "100%"; adjust-underline-thickness = "400%"; - theme = "light:Solarized Light,dark:Solarized Dark"; + theme = "light:light,dark:dark"; window-theme = "system"; window-colorspace = "display-p3"; - background-opacity = 0.9; - background-blur-radius = 20; + # background-opacity = 0.9; + # background-blur-radius = 20; window-padding-x = 10; window-padding-y = 10; diff --git a/home/neovim.nix b/home/neovim.nix index deddf5154..264d76a3c 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -6,7 +6,13 @@ }: # Let-In ----------------------------------------------------------------------------------------{{{ let - inherit (lib) attrValues concatStringsSep optional; + inherit (lib) + attrValues + concatStringsSep + mapAttrsToList + optional + removePrefix + ; inherit (config.lib.file) mkOutOfStoreSymlink; inherit (config.home.user-info) nixConfigDirectory; @@ -103,6 +109,9 @@ let ++ optional (autoload && configFinal != "") configFinal )); }; + + mkVimColorVariable = k: v: ''let g:theme_${k} = "${v}"''; + colorSetToVimscript = colors: concatStringsSep "\n" (mapAttrsToList mkVimColorVariable colors); in # }}} { @@ -119,7 +128,12 @@ in mkOutOfStoreSymlink "${nixConfigDirectory}/configs/nvim/colors"; # Load the `init` module from the above configs - programs.neovim.extraConfig = "lua require('init')"; + programs.neovim.extraConfig = '' + ${colorSetToVimscript config.colors.malo-ok-solar-light.colors} + ${colorSetToVimscript config.colors.malo-ok-solar-light.namedColors} + + lua require('init') + ''; # Add `penlight` Lua module package since I used in the above configs programs.neovim.extraLuaPackages = ps: [ ps.penlight ];