catppuccin / wezterm

:shell: Soothing pastel theme for WezTerm
MIT License
229 stars 4 forks source link

[Suggestion] Support wezterm directly #6

Closed vihu closed 2 years ago

vihu commented 2 years ago

Hello, thank you for your excellent color schemes. I primarily use wezterm and thought it would be preferable to add support for catppuccin directly in wezterm. To that end I have opened a PR for wezterm. Would be helpful if you could also review :slightly_smiling_face:

vihu commented 2 years ago

Nevermind, I was told to open a PR for iterm2 since that's where the colorschemes for wezterm actually reside.

nekowinston commented 2 years ago

Will you go ahead and open a MR on iTerm2? I'd be happy to review it.

wez commented 2 years ago

I was just looking at this because someone mentioned it on twitter.

I've recently overhauled how wezterm pulls in colorschemes and I can now easily pull in the data using the iterm2 color scheme formatted data from the iterm repo; I have some code ready to commit that will do that. (Previously, we could only use the iterm2 color scheme repo as the source).

Looking through this repo it appears as though the lua code in here sets additional colors. I can't use this repo as the source because it uses executable lua code that might have unexpected side effects and I cannot "risk" evaluating that in places where I might have eg: code signing credentials.

Are the additional colors important for the highest fidelity representation of this color scheme?

If the answer is no then I can commit my pending iterm2 based sync logic. If the answer is yes, could the lua files be rephrased as wezterm toml files and committed here? While the docs don't say it, wezterm's toml files do also support setting all of the things that can go in the colors portion of the wezterm config.

nekowinston commented 2 years ago

👋 Hi there! Thanks a bunch for your lovely work on WezTerm! ❤️

I absolutely understand the hesitancy to include the lua code.

Do you mean the 4 variations defined here, or the indexed colours? The first isn't necessary, we could provide 4 files instead, such as Catppuccin-mocha.toml, Catppuccin-macchiato.toml, etc. The latter, indexed colours, are according to our style guide.

I'd be happy to provide the colourscheme in TOML format, if this helps with including it as a default. 👍

wez commented 2 years ago

This whole block isn't typically part of a color scheme: https://github.com/catppuccin/wezterm/blob/65078e846c8751e9b4837a575deb0745f0c0512f/catppuccin.lua#L152-L184

Indexed colors are documented as supported in https://wezfurlong.org/wezterm/config/appearance.html#defining-your-own-colors

Technically speaking, you could put the rest of those in the block I highlighted in the TOML file as well, but no other scheme does that so far. I've been resisting making an official ruling on whether that is good or not because the color scheme/palette is theoretically a per-pane attribute and I don't know if a scheme should unilaterally apply to the tab bar: it could get weird if two panes have different schemes. I'm willing to give it a go with this scheme and see how things play out though!

wez commented 2 years ago

BTW: I've expanded the colorscheme file to include a metadata section where you can include the scheme name and author. https://wezfurlong.org/wezterm/config/lua/wezterm.color/save_scheme.html shows an example of how that looks at the bottom.

Using the name metadata would allow you to name the scheme something like "Catppuccin Latte" with whatever spaces/capitalization you'd prefer, rather than having the name be derived from the filename.

wez commented 2 years ago

slightly OT: I saw that you're associated with https://farbenfroh.io/faerber. Some of the recent commits to wezterm are in support of similar stuff: extract_colors_from_image and a color object for computing colors.

nekowinston commented 2 years ago

I've been resisting making an official ruling on whether that is good or not because the color scheme/palette is theoretically a per-pane attribute and I don't know if a scheme should unilaterally apply to the tab bar: it could get weird if two panes have different schemes. I'm willing to give it a go with this scheme and see how things play out though!

It's great to hear you're willing to give us a shot! When I initially ported this theme to our new flavours, the main goal was to replicate the Kitty port as closely as possible. I've also been trying to replicate the tab bar in a similar manner, and have thought about including the config for that in our README. wezterm-mocha

That being said, those upcoming TOML files meant for the inclusion, will obviously not include these kinds of more invasive tweaks.

I've expanded the colorscheme file to include a metadata section where you can include the scheme name and author.

Great to know, thanks!

I'll get to work creating the TOML ports then. 🙂

slightly OT: I saw that you're associated with farbenfroh.io/faerber

Very cool, looking forward to trying out those new features in WezTerm! 🎉

wez commented 2 years ago

If you're running the nightly build of wezterm, you could run with your lua based scheme config from this repo, then pop open the debug overlay (CTRL-SHIFT-L) to get a lua repl and then do something like:

> wezterm.colors.save_scheme(catppuccin.select(something), {name="Catppucin Latte", author="someone"}, "/tmp/latte.toml")

to get a first pass at a TOML version without too much sweat

wez commented 2 years ago

Also, as a "pro tip", functions you define in wezterm.lua can also be called from the debug overlay repl

wez commented 2 years ago

Needed a little fix to allow exporting indexed colors; once that builds out (takes about an hour to build for all platforms), you can use a nightly build and:

> wezterm.color.save_scheme(CAT.setup{}, {}, "/tmp/cat.toml")

produces:

[colors]
ansi = [
    '#45475a',
    '#f38ba8',
    '#a6e3a1',
    '#f9e2af',
    '#89b4fa',
    '#f5c2e7',
    '#94e2d5',
    '#bac2de',
]
background = '#1e1e2e'
brights = [
    '#585b70',
    '#f38ba8',
    '#a6e3a1',
    '#f9e2af',
    '#89b4fa',
    '#f5c2e7',
    '#94e2d5',
    '#a6adc8',
]
compose_cursor = '#f2cdcd'
cursor_bg = '#f5e0dc'
cursor_border = '#f5e0dc'
cursor_fg = '#11111b'
foreground = '#cdd6f4'
scrollbar_thumb = '#585b70'
selection_bg = '#585b70'
selection_fg = '#cdd6f4'
split = '#6c7086'
visual_bell = '#313244'

[colors.indexed]
16 = '#fab387'
17 = '#f5e0dc'

[colors.tab_bar]
background = '#1e1e2e'
inactive_tab_edge = '#575757'
inactive_tab_edge_hover = '#363636'

[colors.tab_bar.active_tab]
bg_color = '#585b70'
fg_color = '#cdd6f4'
intensity = 'Normal'
italic = false
strikethrough = false
underline = 'None'

[colors.tab_bar.inactive_tab]
bg_color = '#1e1e2e'
fg_color = '#cdd6f4'
intensity = 'Normal'
italic = false
strikethrough = false
underline = 'None'

[colors.tab_bar.inactive_tab_hover]
bg_color = '#585b70'
fg_color = '#cdd6f4'
intensity = 'Normal'
italic = false
strikethrough = false
underline = 'None'

[colors.tab_bar.new_tab]
bg_color = '#1e1e2e'
fg_color = '#cdd6f4'
intensity = 'Normal'
italic = false
strikethrough = false
underline = 'None'

[colors.tab_bar.new_tab_hover]
bg_color = '#585b70'
fg_color = '#cdd6f4'
intensity = 'Normal'
italic = true
strikethrough = false
underline = 'None'

[metadata]
nekowinston commented 2 years ago

Very lovely. I'll push those TOML files into ./dist and update the repo README accordingly, once I have exported it and checked with our styleguide. 🙂

nekowinston commented 2 years ago

Okay, so I used wezterm.color.save_scheme() to generate the current files in the ./dist directory. I built wezterm from https://github.com/wez/wezterm/commit/73993a60b42d2bd195712e4e3c408c13da79b3ed , and it seems that the TOML version is having trouble picking up [colors.tab_bar], etc.

Here's a screenshot using that build and their respective configs: wezterm-toml-comp The top's config is minimal.lua, the lower one's toml-only.lua.

Aside from the tab bar, the current colours should be the correct ones.

wez commented 2 years ago

Thanks! I fixed a couple of issues in wezterm, so this now works for me and the tab bar colors are respected:

wezterm -n --config use_fancy_tab_bar=false \
  --config 'color_scheme_dirs={"/home/wez/wez-personal/github/catppuccin-wezterm/dist"}' \
  --config 'color_scheme="Catppuccin Frappe"'

I'll work on syncing the files from dist into wezterm's collection of schemes next

wez commented 2 years ago

OK, nightly builds now include these color schemes! https://wezfurlong.org/wezterm/colorschemes/c/index.html#catppuccin-frappe Thanks for being flexible and translating them to toml!

nekowinston commented 2 years ago

Thanks! I've updated the README accordingly. Creating those TOML ports was very pleasant with that new save_scheme function. 👍

wez commented 2 years ago

The way the sync machinery works is:

Regarding the light/dark mode syncing portion of the lua in this repo: nightly builds no longer require a window object to determine the appearance, so the window config reload event is no longer needed; here's the relevant function with a short example:

https://wezfurlong.org/wezterm/config/lua/wezterm.gui/get_appearance.html

if you wanted to test for this in your lua script, you can test whether wezterm.gui is truthy and adjust accordingly