nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

Usage with Nix-colors

Open jhilker98 opened this issue 3 years ago • 4 comments
trafficstars

I'm currently using nix-colors for managing my color schemes, and I have been trying to use the vim colorscheme function that nix-colors provides in order to use it. However, whenever I use it in my config for nixvim, I get the same error of error: colorscheme gruvbox-dark-hard not found. What do I need to do to fix this?

jhilker98 avatar Aug 26 '22 16:08 jhilker98

If you're using an official base16 theme, you can do :

{ config, lib, ... }:
{
  programs.nixvim = {
    colorschemes.base16 = {
      enable = true;
      useTruecolor = true;
      colorscheme = lib.toLower config.colorScheme.name;
    };
  };
}

For a more robust solution, it would be possible to package nvim-base16 and create a colorscheme based on it, since it directly takes the individual colors as arguments. I'll probably do that at some point if I find the time.

dwarfmaster avatar Sep 08 '22 16:09 dwarfmaster

Thanks!

jhilker98 avatar Sep 08 '22 16:09 jhilker98

I'll probably open a PR at some point, but for the moment you can copy this to set it up. Another advantage is that you can just set lualine theme to base16 and it just works with this plugin.

dwarfmaster avatar Sep 17 '22 09:09 dwarfmaster

alright, I'll try that.

jhilker98 avatar Sep 17 '22 13:09 jhilker98

Is it relevant to add this feature to nixvim ? If so, I guess I could easily port the implementation of @dwarfmaster or look for another solution. Else, we might close this issue.

GaetanLepage avatar Apr 22 '23 12:04 GaetanLepage

I will go ahead and close it - so far the implementation that @dwarfmaster has is working for me.

jhilker98 avatar Apr 22 '23 17:04 jhilker98

Ok good ! Feel free to come back if you think that something is missing :)

GaetanLepage avatar Apr 22 '23 17:04 GaetanLepage

If you're using an official base16 theme, you can do :

{ config, lib, ... }:
{
  programs.nixvim = {
    colorschemes.base16 = {
      enable = true;
      useTruecolor = true;
      colorscheme = lib.toLower config.colorScheme.name;
    };
  };
}

For a more robust solution, it would be possible to package nvim-base16 and create a colorscheme based on it, since it directly takes the individual colors as arguments. I'll probably do that at some point if I find the time.

@dwarfmaster Does this also work for a custom Base16 setup, when i copy your code, it gives me an infinite recursion error.

waot avatar Jun 23 '23 06:06 waot

I had also noticed infinite recursion with that setup, even when using an official colorscheme (gruvbox-dark-hard in my case).

jhilker98 avatar Jun 23 '23 15:06 jhilker98

@jhilker98, I tested the following setup and it works fine:

{ config, lib, ... }:
{
  programs.nixvim = {
    colorschemes.base16 = {
      enable = true;
      useTruecolor = true;
      colorscheme = "gruvbox-dark-hard";
    };
  };
}

Do you still encounter this issue ?

GaetanLepage avatar Jul 18 '23 07:07 GaetanLepage

Yes, I was able to get it working now. Not totally sure what changed, but it works. :)

jhilker98 avatar Jul 18 '23 15:07 jhilker98

If you're using an official base16 theme, you can do :

{ config, lib, ... }:
{
  programs.nixvim = {
    colorschemes.base16 = {
      enable = true;
      useTruecolor = true;
      colorscheme = lib.toLower config.colorScheme.name;
    };
  };
}

For a more robust solution, it would be possible to package nvim-base16 and create a colorscheme based on it, since it directly takes the individual colors as arguments. I'll probably do that at some point if I find the time.

@dwarfmaster Does this also work for a custom Base16 setup, when i copy your code, it gives me an infinite recursion error.

I am now using something based on nvim-base16 that supports custom colors, see here. Note that I am not using nix-colors anymore but stylix, however the code should be easy to adapt.

dwarfmaster avatar Aug 08 '23 13:08 dwarfmaster

@dwarfmaster we switched to using nvim-base16 for the backend of colorschemes.base16. When #504 will be merged, your setup can become:

programs.nixvim = {
  colorschemes.base16 = {
    enable = true;
    colorscheme = colors.scheme-slug;
    customColorScheme = {
      base00 = "#${colors.base00}";
      base01 = "#${colors.base01}";
      base02 = "#${colors.base02}";
      base03 = "#${colors.base03}";
      base04 = "#${colors.base04}";
      base05 = "#${colors.base05}";
      base06 = "#${colors.base06}";
      base07 = "#${colors.base07}";
      base08 = "#${colors.base08}";
      base09 = "#${colors.base09}";
      base0A = "#${colors.base0A}";
      base0B = "#${colors.base0B}";
      base0C = "#${colors.base0C}";
      base0D = "#${colors.base0D}";
      base0E = "#${colors.base0E}";
      base0F = "#${colors.base0F}";
    };
  };
};

GaetanLepage avatar Aug 08 '23 17:08 GaetanLepage