Skip to content

Refactor color scheme handling and key bindings initialization #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AnthonySmithDev
Copy link

@AnthonySmithDev AnthonySmithDev commented May 10, 2025

Description:
This PR introduces several improvements to the plugin's initialization logic:

  1. Color Scheme Fixes

    • Previously, if users only set config.color_scheme without config.colors, the plugin would ignore the scheme and fall back to default colors.
    • Now, if config.color_scheme is defined, it properly loads the built-in scheme instead of defaulting.
    • This ensures users who rely on color_scheme (a common Wezterm setting) get the correct colors without needing to manually define config.colors.
  2. Optional Default Keybinds

    • Before, the plugin automatically added default keybindings (like ALT+n, ALT+u, ALT+c) even if users didn’t want them.
    • Now, keybind initialization is moved into a separate set_default_keys(config) function, which must be called explicitly.
    • This gives users full control—they can:
      • Skip calling it to avoid default keybinds entirely.
      • Call it once to apply defaults.
      • Modify the keys afterward if they want partial overrides.

Why This Matters

  • Fixes silent color issues – Users who only set color_scheme (very common) no longer get unexpected default colors.
  • More flexible keybinds – Users can now opt-in to defaults instead of having them forced.

Migration Notes

  • No changes needed if you already define config.colors manually.
  • If you want the old default keybinds, add set_default_keys(config) after applying the plugin.
  • If you don’t want default keybinds, do nothing—they won’t be added automatically anymore.

- Move key binding logic from apply_to_config to set_default_keys
- Expose set_default_keys in module exports
- Use builtin scheme if specified
- Fallback to default colors if no scheme
- Simplify nil check syntax
Copy link
Owner

@MLFlexer MLFlexer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution!
I think these are some great changes, the only thing I'm missing for this PR is to add the set_default_keys function to the documentation in the README, maybe in the preset section.

Once that is in, then It can be merged 😄

- Add missing set_default_keys instruction
@AnthonySmithDev AnthonySmithDev requested a review from MLFlexer May 12, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants