wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.98k stars 806 forks source link

Custom color scheme not recognised unless defined inside `config` table in `wezterm.lua` #6421

Closed prateektade closed 15 hours ago

prateektade commented 2 days ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

I am using Gentoo on WSL inside WezTerm

WezTerm version

20241119-101432-4050072d

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

I wanted to define tab bar colors for the pre-installed Rosé Pine colorscheme (set using `config.color_scheme = 'rose-pine').

I started with the wezterm.color.get_builtin_schemes() function, following the example on this page. The colors got disturbed completely.

Then I removed those lines of code, created a separate TOML file with all the colors including the added tab bar colors, defined the path using config.color_scheme_dirs and then set the name inside the TOML file as the value for config.color_scheme. That disturbed the colors again, same as earlier.

To Reproduce

No response

Configuration

local wezterm = require 'wezterm'

local config = {}

if wezterm.config_builder then
  config = wezterm.config_builder()
end

local rose_pine_main = wezterm.color.get_builtin_schemes()['rose-pine']

rose_pine_main = {
  tab_bar = {
    background = 'hsl: 249 22 12',
    inactive_tab_edge = 'hsl: 249 12 47',
    active_tab = {
      bg_color = 'hsl: 248 25 18',
      fg_color = 'hsl: 245 50 91',
    },
    inactive_tab = {
      bg_color = 'hsl: 249 22 12',
      fg_color = 'hsl: 249 12 47',
    },
    inactive_tab_hover = {
      bg_color = 'hsl: 248 25 18',
      fg_color = 'hsl: 245 50 91',
    },
    new_tab = {
      bg_color = 'hsl: 249 22 12',
      fg_color = 'hsl: 249 12 47',
    },
    new_tab_hover = {
      bg_color = 'hsl: 248 25 18',
      fg_color = 'hsl: 245 50 91',
    },
  },
}

return {
  color_scheme_dirs = '/home/prateektade' -- created the rose-pine-main.toml file here
  color_schemes = {
    ['rose-pine'] = rose_pine_main,
  },
  color_scheme = 'rose-pine',
  --tried to set the colorscheme defined in the rose-pine-main.toml as follows
  --color_scheme = 'rose-pine-main',
}

Expected Behavior

No response

Logs

No response

Anything else?

No response

bew commented 1 day ago

Hmm when you do:

rose_pine_main = {
  tab_bar = {
    ....
  }
}

You basically reset the rose_pine_main variable that you got from the first line, to ONLY have what you specified here.

If you only want to overwrite the tab bar settings you'd need to write it like this:

rose_pine_main.tab_bar = {
  ....
}

This will reset the rose_pine_main.tab_bar but leave all the other colors from the colorscheme config intact.

prateektade commented 1 day ago

@bew Makes sense! Tried this and it works! Thank you.

What might be the issue with the colors from the toml config file not getting applied? The name doesn't clash with an existing color scheme name. I specified all the colors too.

bew commented 1 day ago

What might be the issue with the colors from the toml config file not getting applied? The name doesn't clash with an existing color scheme name. I specified all the colors too.

Did you check the logs output from wezterm? (when run from another terminal) There might be useful information to help you debug this

prateektade commented 15 hours ago

Yes, I got an error saying that read Your configuration specifies color_scheme="rose-pine-toml" but that scheme was not found. It only recognised the file when I placed it in the %HOME%/.config/wezterm/colors directory. The color_scheme_dirs config option doesn't work I guess.

bew commented 15 hours ago

Ah according to the docs it should be a list (not sure why it didn't tell you the type was incorrect)

Try setting it with:

config.color_scheme_dirs = { '/home/prateektade' }
config.color_scheme = 'rose-pine-toml'
-- ...
return config