making nix-colors talk to neovim

making nix-colors talk to neovim

I recently started fiddling around with home-managerifying my neovim config. After moving across most of my stuff I came across the problem of how to hook things up with with nix-colors so that my neovim theme would follow color changes in home-manager.

Luckily, I came across this handy little plugin from the lovely mini.nvim suite of plugins which lets you create your own theme with your custom colors.

Beneath is a little snippet of how you could make it all happen.

{ inputs, pkgs, ... }: {
  imports = [
    inputs.nix-colors.homeManagerModules.default
  ];
  scheme = inputs.nix-colors.schemes.onedark;
  programs.neovim = {
    enable = true;
    plugins = with pkgs.vimPlugins; [
      {
        plugin = mini-nvim;
        config = ''
          lua << END
            require('mini.base16').setup({
              palette = {
                base00 = '#${scheme.colors.base00}',
                base01 = '#${scheme.colors.base01}',   
                base02 = '#${scheme.colors.base02}',    
                base03 = '#${scheme.colors.base03}',    
                base04 = '#${scheme.colors.base04}',    
                base05 = '#${scheme.colors.base05}',
                base06 = '#${scheme.colors.base06}',    
                base07 = '#${scheme.colors.base07}',    
                base08 = '#${scheme.colors.base08}',    
                base09 = '#${scheme.colors.base09}',   
                base0A = '#${scheme.colors.base0A}',    
                base0B = '#${scheme.colors.base0B}',    
                base0C = '#${scheme.colors.base0C}',   
                base0D = '#${scheme.colors.base0D}',
                base0E = '#${scheme.colors.base0E}',
                base0F = '#${scheme.colors.base0F}',    
              },
            })
          END
        '';
      }
    ];
  };
}

Happy theming!