stylix icon indicating copy to clipboard operation
stylix copied to clipboard

helix: primary cursor should be differentiated

Open tylernku opened this issue 1 year ago • 4 comments

In helix, you can have multiple cursors operating on different selections in a file. You can cycle between them and remove selections. At any one time, one of the selections is considered to be primary and you can use keybindings to keep or dismiss it.

For example:

Dracula_at_night (Dracula_at_night)

Ayu_dark (Ayu_dark)

Both these themes give the ability to differentiate between primary and secondary selections (with varying subtlety). They both rely on ui.cursor and ui.cursor.primary, and ui.selection and ui.selection.primary being visually distinct.

In stylix's helix config ui.cursor is defined and ui.cursor.primary is not. Also, ui.selection and ui.selection.primary are both defined as base02.

Here's what that looks like with the stylix config:

Stylix (Stylix)

tylernku avatar Dec 19 '24 23:12 tylernku

Thanks for this excellent bug report!

Currently, Stylix delegates Helix' theming to https://github.com/tinted-theming/base16-helix:

https://github.com/danth/stylix/blob/a2d66f25478103ac9b4adc6d6713794f7005221e/modules/helix/hm.nix#L4-L6

Consider patching the upstream theme and then submitting a Stylix PR to update the base16-helix input.

trueNAHO avatar Dec 21 '24 15:12 trueNAHO

I was wondering how to make the effect. If it helps, I found out how to set the things you want! First and foremost, if you want to "patch" the stylix theme with your own mods, you can use the inherit keyword. Here is a potential hm config line you can add:

programs.helix.settings.theme = "my-stylix";
home.file.".config/helix/themes/my-stylix.toml".source = toml.generate "my-stylix.toml" {
  # Get the default values fro the stylix config
  inherits = "stylix";

  # Enter your patches here
  # This will become the cursor of the selections
  "ui.cursor" = {
    fg = "base0B"; # usually it is base0A, but that will be the primary now
    modifiers = [ "reversed" ];
  };
  # This is the color of the primary cursor, i.e., the one you always see
  "ui.cursor.primary" = {
    fg = "base0A";
    modifiers = [ "reversed" ];
  };

  # Similar thing with the selection color
  # Also, you can play with setting the fg to *background*
  # And putting the color in the bg variable ;)

  # This will become the color of the selections
  "ui.selection" = {
    fg = "base03"; # It would be base02, but that is the primary now
  };
  # This is the color of the primary/inline selection where the primary cursor is now
  "ui.selection.primary "= {
    fg = "base02";
  };

  # This one is a bonus: the matching element (like a bracket) will be underlined
  # I somehow lose track which cursor is mine and which is just a highlight...
  "ui.cursor.match" = {
    fg = "base0A";
    modifiers = [ "underlined" ];
  };
};

This will suffice for now, but some of there changes could be implemented upstream too. Maybe I will take a look at it, but since I am not well versed in theming, I am not sure how good the coloring would be 😂

arunoruto avatar Jan 07 '25 00:01 arunoruto

i found a somewhat simpler/neater way to override the default the theme:

programs.helix = {
  # set theme to the one defined below
  settings.theme = lib.mkForce "stylix-custom";
  themes = {
    stylix-custom = {
      # inherits styling and pallet from the default stylix helix theme
      inherits = "stylix";

      # Normal Mode Indicator at the bottom left background base0D with base00 text
      "ui.statusline.normal" = { fg = "base00"; bg = "base0D"; };

      # Makes the active buffer in the bufferline background base0D, foreground font is bold
      "ui.bufferline.active" = { fg = "base00"; bg = "base0D"; modifiers = ["bold"]; };

      # Primary selection is base0D
      "ui.cursor.primary" = { fg = "base0D"; modifiers = ["reversed"]; };

      # Matching brackets/quotes are underlined with color base0A
      "ui.cursor.match" = { fg = "base0A"; underline.style = "line"; };
    };
  };
};

Whenever I have to use home.file (or xdg.configFile) it always feels a little dirty to me lol.

Also, I've been trying to think about what would be a reasonable default to patch the upstream theme with would be, but, given how restrictive the spec is, it's difficult to really know. I pretty much always use Base0D for a primary/highlight color (because in my case it's a nice blue), but semantically i don't think that would be valid for a default.

Also, one thing I really love about stylix as a project is the ability to just override the aspects you don't like of the default theme.

tylernku avatar Jan 25 '25 16:01 tylernku

i found a somewhat simpler/neater way to override the default the theme: Whenever I have to use home.file (or xdg.configFile) it always feels a little dirty to me lol.

Thanks for the tip! I sometimes forget about the theme option 👀

arunoruto avatar Jan 26 '25 20:01 arunoruto

Fixed upstream in https://github.com/tinted-theming/base16-helix/pull/25

MrSom3body avatar Jul 29 '25 15:07 MrSom3body