Skip to content
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

yazi switched yank and selected color #604

Closed
Felipe-9 opened this issue Nov 5, 2024 · 4 comments · Fixed by #719
Closed

yazi switched yank and selected color #604

Felipe-9 opened this issue Nov 5, 2024 · 4 comments · Fixed by #719

Comments

@Felipe-9
Copy link

Felipe-9 commented Nov 5, 2024

After applying stylix with catppuccin-mocha for yazi the theme has the highlight colors for a selected item and a yanked item reversed:

image

it can be seen that i yanked two files but and slected one, and yet two items appear green and one yellow.

{ config, lib, pkgs, options, ...}:
{
  options.mystylix.enable =
    lib.mkEnableOption "enable automatic styling";

  config = lib.mkIf config.mystylix.enable {
    stylix = {
      enable = true;
      polarity = "dark";
      base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
    };
    stylix.targets = {
      yazi.enable = true;
    };
    stylix.opacity = {
      applications = 0.9;
      desktop = 0.9;
      popups = 0.9;
      terminal = 0.9;
    };
    stylix.cursor = {
      package = pkgs.bibata-cursors;
      name = "Bibata-Modern-Classic";
    };
    stylix.fonts = {
      sizes = {
        terminal = 20;
        desktop = 14;
        applications = 12;
        popups = 14;
      };
      # monospace = {
      #   package = pkgs.nerdfonts.override {fonts=["FiraCode"];};
      #   name = "FiraCode";
      # };
      sansSerif = {
        package = pkgs.source-sans;
        name = "SourceSans3";
      };
      serif = {
        package = pkgs.source-serif;
        name = "SourceSerif4";
      };
    }; 
  };
}
@danth
Copy link
Owner

danth commented Nov 6, 2024

Are the colours switched in your theme, or is Stylix setting them the wrong way around? This page shows what the colours in a "normal" theme will correspond to.

@Felipe-9
Copy link
Author

how do i check this?

@trueNAHO
Copy link
Collaborator

how do i check this?

Look at the source code or the generated config file.

@Felipe-9
Copy link
Author

Felipe-9 commented Nov 23, 2024

i created a file that would overrite to that same file in the source code:

no changes to how yazi output color (same error)

yazi/theme.nix
# Based on the official catppuccin themes https://github.com/yazi-rs/themes
{
  config,
  lib,
  ...
}: {
  options.stylix.targets.yazi = {
    enable = config.lib.stylix.mkEnableTarget "Yazi" true;
  };

  config = lib.mkIf (config.stylix.enable && config.stylix.targets.yazi.enable) {
    programs.yazi.theme = with config.lib.stylix.colors.withHashtag; let
      mkFg = fg: {inherit fg;};
      mkBg = bg: {inherit bg;};
      mkBoth = fg: bg: {inherit fg bg;};
      mkSame = c: (mkBoth c c);
    in {
      manager = rec {
        # Reusing bat themes, since it's suggested in the stying guide
        # https://yazi-rs.github.io/docs/configuration/theme#manager
        syntect_theme = config.lib.stylix.colors {
          template = ../bat/base16-stylix.mustache;
          extension = ".tmTheme";
        };

        cwd = mkFg base0C;
        hovered = (mkBoth base05 base03) // {bold = true;};
        preview_hovered = hovered;
        find_keyword = (mkFg base0B) // {bold = true;};
        find_position = mkFg base05;
        marker_selected = mkSame base0B;
        marker_copied = mkSame base0A;
        marker_cut = mkSame base08;
        tab_active = mkBoth base00 base0D;
        tab_inactive = mkBoth base05 base01;
        border_style = mkFg base04;
      };

      status = {
        separator_style = mkSame base01;
        mode_normal = (mkBoth base00 base0D) // {bold = true;};
        mode_select = (mkBoth base00 base0B) // {bold = true;};
        mode_unset = (mkBoth base00 base0F) // {bold = true;};
        progress_label = mkBoth base05 base00;
        progress_normal = mkBoth base05 base00;
        progress_error = mkBoth base08 base00;
        permissions_t = mkFg base0D;
        permissions_r = mkFg base0A;
        permissions_w = mkFg base08;
        permissions_x = mkFg base0B;
        permissions_s = mkFg base0C;
      };

      select = {
        border = mkFg base0D;
        active = mkFg base0E;
        inactive = mkFg base05;
      };

      input = {
        border = mkFg base0D;
        title = mkFg base05;
        value = mkFg base05;
        selected = mkBg base03;
      };

      completion = {
        border = mkFg base0D;
        active = mkBoth base0E base03;
        inactive = mkFg base05;
      };

      tasks = {
        border = mkFg base0D;
        title = mkFg base05;
        hovered = mkBoth base05 base03;
      };

      which = {
        mask = mkBg base02;
        cand = mkFg base0C;
        rest = mkFg base0F;
        desc = mkFg base05;
        separator_style = mkFg base04;
      };

      help = {
        on = mkFg base0E;
        run = mkFg base0C;
        desc = mkFg base05;
        hovered = mkBoth base05 base03;
        footer = mkFg base05;
      };

      # https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml
      filetype.rules = let
        mkRule = mime: fg: {inherit mime fg;};
      in [
        (mkRule "image/*" base0C)
        (mkRule "video/*" base0A)
        (mkRule "audio/*" base0A)

        (mkRule "application/zip" base0E)
        (mkRule "application/gzip" base0E)
        (mkRule "application/x-tar" base0E)
        (mkRule "application/x-bzip" base0E)
        (mkRule "application/x-bzip2" base0E)
        (mkRule "application/x-7z-compressed" base0E)
        (mkRule "application/x-rar" base0E)
        (mkRule "application/xz" base0E)

        (mkRule "application/doc" base0B)
        (mkRule "application/pdf" base0B)
        (mkRule "application/rtf" base0B)
        (mkRule "application/vnd.*" base0B)

        ((mkRule "inode/directory" base0D) // {bold = true;})
        (mkRule "*" base05)
      ];
    };
  };
}

trueNAHO pushed a commit that referenced this issue Jan 3, 2025
…719)

Add a testbed and resolve the 0.4.0 breaking changes [2] [3] [4].

Migrate the highlight colors to mnemonics with the following script to
improve readability and simplify the process of reusing upstream
templates [4]:

    colors_base=(
      "base08" "base09" "base0A" "base0B" "base0C" "base0D" "base0E"
      "base0F"
    )

    colors_name=(
      "red" "orange" "yellow" "green" "cyan" "blue" "magenta" "brown"
    )

    for i in "${!colors_base[@]}"; do
      sed \
        --in-place \
        "s/${colors_base[i]}/${colors_name[i]}/g" \
        modules/yazi/hm.nix
    done

[1]: sxyazi/yazi#1772
[2]: sxyazi/yazi#1927
[3]: sxyazi/yazi#1953
[4]: https://github.com/yazi-rs/flavors/blob/main/scripts/catppuccin/template.toml

Closes: #604
Closes: #683
Link: #719

Reviewed-by: NAHO <[email protected]>
pinarruiz pushed a commit to pinarruiz/stylix that referenced this issue Jan 4, 2025
…anth#719)

Add a testbed and resolve the 0.4.0 breaking changes [2] [3] [4].

Migrate the highlight colors to mnemonics with the following script to
improve readability and simplify the process of reusing upstream
templates [4]:

    colors_base=(
      "base08" "base09" "base0A" "base0B" "base0C" "base0D" "base0E"
      "base0F"
    )

    colors_name=(
      "red" "orange" "yellow" "green" "cyan" "blue" "magenta" "brown"
    )

    for i in "${!colors_base[@]}"; do
      sed \
        --in-place \
        "s/${colors_base[i]}/${colors_name[i]}/g" \
        modules/yazi/hm.nix
    done

[1]: sxyazi/yazi#1772
[2]: sxyazi/yazi#1927
[3]: sxyazi/yazi#1953
[4]: https://github.com/yazi-rs/flavors/blob/main/scripts/catppuccin/template.toml

Closes: danth#604
Closes: danth#683
Link: danth#719

Reviewed-by: NAHO <[email protected]>
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 a pull request may close this issue.

3 participants