nix-community / nixvim

Configure Neovim with Nix! [maintainers=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.81k stars 281 forks source link

[BUG] Configured colorscheme is not used by default #2446

Open vendion opened 1 month ago

vendion commented 1 month ago
Field Description
Plugin nord
Nixpkgs unstable
Home Manager unstable

Description

Setting the default colorscheme to nord via colorschemes.nord.enable doesn't work, while the colorscheme gets installed and can be switched to by doing :colorscheme nord, the default Neovim colorscheme is used by default.

I have also tested with colorschemes.cyberdream.enable and got the same result.

Minimal, Reproducible Example (MRE)

{
  programs.nixvim = {
    enable = true;

    colorschemes.nord.enable = true;
  };
}
Shyrogan commented 1 week ago

As a temporary fix, you can use the following option

programs.nixvim = {
  extraConfigLuaPost = ''vim.cmd [[ colorscheme nord ]]'';
};

if you want

MattSturgeon commented 6 days ago

This should already be done by mkVimPlugin:

Perhaps the generated lua code is ending up in the wrong part of init.lua and is not having the desired effect :thinking:

mkVimPlugin sets our colorscheme option: https://github.com/nix-community/nixvim/blob/929bb0cd1cffb9917ab14be9cdb3f27efd6f505f/lib/vim-plugin.nix#L115-L117

Our colorscheme option adds the code to extraConfigVim: https://github.com/nix-community/nixvim/blob/929bb0cd1cffb9917ab14be9cdb3f27efd6f505f/modules/colorscheme.nix#L12-L14

Our content option sandwiches extraConfigVim between extraConfigLuaPre and extraConfigLua: https://github.com/nix-community/nixvim/blob/929bb0cd1cffb9917ab14be9cdb3f27efd6f505f/modules/output.nix#L113-L121

You can inspect the final generated lua yourself using nixvim-print-init.

vendion commented 2 days ago

Checking the output of nixvim-print-init I see that the first place colorscheme appears is like so

 143   vim.cmd([[let $BAT_THEME = 'nord'
 144
 145   colorscheme nord
 146   ]])

Which from the line numbers (143-146) happens early on, so is probably the one that is added automatically and thus the one not working. Then the very last line is just vim.cmd([[ colorscheme nord ]]) which I assume is the one I manually added with extraConfigLuaPost.

Aliervo commented 11 hours ago

This might actually be a regression in colorscheme. I just updated my system for the first time a while and I noticed my colors were off. I have been using:

programs.nixvim = {
  enable = true;

  colorscheme = "solarized-flat";
  extraPlugins = [ pkgs.vimPlugins.nvim-solarized-lua ];

  # Rest of config
};

I can check my flake.lock for a potential bisect if it helps.