catppuccin / nix

❄️ Soothing pastel theme for Nix
https://nix.catppuccin.com/
MIT License
392 stars 54 forks source link

There are breaking changes in upstream tmux #352

Open budimanjojo opened 1 week ago

budimanjojo commented 1 week ago

There are breaking changes in upstream since https://github.com/catppuccin/tmux/releases/tag/v0.4.0

One of the change requires changes in here too. The change in question: The status-left and status-right options are no longer controlled by this plugin.

This means user needs to configure set -g status-left and set -g status-right after loading the plugin. An example on the change (taken from https://github.com/catppuccin/tmux?tab=readme-ov-file#config-1 before and after the release) BEFORE:

set -g @catppuccin_window_right_separator "█ "
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_middle_separator " | "

set -g @catppuccin_window_default_fill "none"

set -g @catppuccin_window_current_fill "all"

set -g @catppuccin_status_modules_right "application session user host date_time"
set -g @catppuccin_status_left_separator "█"
set -g @catppuccin_status_right_separator "█"

set -g @catppuccin_date_time_text "%Y-%m-%d %H:%M:%S"

AFTER:

# Disable catppuccin styling windows.
set -g @catppuccin_window_status_style "none"
set -g @catppuccin_status_left_separator "█"
set -g @catppuccin_status_right_separator "█"

set -g @catppuccin_date_time_text "%Y-%m-%d %H:%M:%S"

# Run catppuccin plugin manually or through tpm
# ...

# Style the windows. See https://man7.org/linux/man-pages/man1/tmux.1.html#STYLES for more details.
set -gF window-status-style "bg=#{@thm_surface_1},fg=#{@thm_fg}"
set -gF window-status-current-style "bg=#{@thm_peach},fg=#{@thm_crust}"

set -g window-status-format " #T | #I "
set -g window-status-current-format " #T | #I "

set -g status-left ""
set -g  status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_user}"
set -ag status-right "#{E:@catppuccin_status_host}"
set -ag status-right "#{E:@catppuccin_status_date_time}"

As you can see, there are section of config that needs to be run after the plugin is being loaded. We can simply let the user do this manually by adding those lines in config.programs.tmux.extraConfig but I prefer having something like config.programs.tmux.catppuccin.extraConfigLate.

{
  options.programs.tmux.catppuccin = ctp.mkCatppuccinOpt { name = "tmux"; } // {
    extraConfig = mkOption {
      type = types.lines;
      description = "Additional configuration for the catppuccin plugin.";
      default = "";
      example = ''
        set -g @catppuccin_status_modules_right "application session user host date_time"
      '';
    };
    extraConfigLate = mkOption {
      type = types.lines;
      description = "Additional configuration for the catppuccin plugin that needs to be loaded after the plugin.";
      default = "";
      example = ''
        set -g status-left ""
     '';
  };

  config.programs.tmux = lib.mkIf enable {
    extraConfig = ''
      ${cfg.extraConfigLate}
    '';
    plugins = [
      {
        inherit plugin;
        extraConfig = concatStrings [
          ''
          set -g @catppuccin_flavor '${cfg.flavor}'
          ''
          cfg.extraConfig
        };
      ];
    }
  ];
}
vdbe commented 1 week ago

You can use programs.tmux.extraConfig for this programs.tmux.catppuccin.extraConfig was added as a way to set options before the plugin was loaded, which was otherwise impossible due to how home-manager creates tmux.conf.

budimanjojo commented 1 week ago

Yes I did mention that user can just use programs.tmux.extraConfig but I prefer having separation between the main config and theme config in the nix file.