nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.36k stars 1.7k forks source link

bug: neovim config fails to run setup() on some plugins #4602

Closed jfvillablanca closed 2 months ago

jfvillablanca commented 8 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I use home-manager (with flake; home-manager follows nixpkgs input) to manage my whole neovim config. I haven't updated my flake for quite some time. I ran nix flake lock --update-input nixpkgs --update-input home-manager

• Updated input 'home-manager':
    'github:nix-community/home-manager/ee5673246de0254186e469935909e821b8f4ec15' (2023-07-20)
  → 'github:nix-community/home-manager/6045b68ee725167ed0487f0fb88123202ba61923' (2023-10-24)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/5df4d78d54f7a34e9ea1f84a22b4fd9baebc68d0' (2023-07-20)
  → 'github:nixos/nixpkgs/7c9cc5a6e5d38010801741ac830a3f8fd667a7a0' (2023-10-19)

Opening nvim after switching (sudo nixos-rebuild switch --flake .), the colorscheme did not loaded, then I figured some plugins did not load This is what it looks like when opening the generated init.lua image

What I figured out:

What I ruled out:

This is my neovim/default.nix

{ config, pkgs, ... }:
let
  luaConfig = [
    ./lua/impatient.lua
    ./lua/options.lua
    ./lua/keymaps.lua
    ./lua/autocommands.lua
    ./lua/cmp.lua
    ./lua/lsp/main.lua
  ];
in
{
  # yes I should move this to programs.neovim.extraPackages (I just realized recently)
  home.packages = with pkgs; [
    gcc

    # Formatters
    nodePackages_latest.prettier # webdev
    stylua                                                              # lua
    shfmt                                                               # sh
    nixpkgs-fmt                                                         # nix
    rustfmt                                                             # rust
    python310Packages.black                                             # python

    # Linters
    statix                                                              # nix
    shellcheck                                                          # sh
    python310Packages.flake8                                            # python

    # Language Servers
    nodePackages_latest.bash-language-server                            # sh
    nil                                                                 # nix
    gopls                                                               # go
    sumneko-lua-language-server                                         # lua
    rust-analyzer                                                       # rust
    haskellPackages.haskell-language-server                             # haskell
    python311Packages.python-lsp-server                                 # python

    nodePackages_latest."@tailwindcss/language-server"                  # tailwind
    nodePackages_latest."@prisma/language-server"                       # prisma
    nodePackages_latest.typescript-language-server                      # js-related grammars
    nodePackages_latest.vscode-langservers-extracted                    # html, css, json, eslint
    nodePackages_latest.volar                                           # vue
    # emmet-ls                                                            # html snippets
  ];

  xdg.configFile."nvim/lua/lsp" = {
    source = ./lua/lsp;
    recursive = true;
  };

  programs.neovim = {
    enable = true;
    package = pkgs.neovim-nightly;
    defaultEditor = true;
    vimAlias = true;
    withNodeJs = true;
    withPython3 = true;
    withRuby = true;

    extraLuaConfig =
      builtins.concatStringsSep "\n"
        (map builtins.readFile luaConfig);

    plugins = with pkgs.vimPlugins; [
      plenary-nvim
      impatient-nvim
      nvim-web-devicons

      # nvim-tree
      {
        plugin = nvim-tree-lua;
        type = "lua";
        config = builtins.readFile ./lua/nvim-tree.lua;
      }
      # lualine
      {
        plugin = lualine-nvim;
        type = "lua";
        config = builtins.readFile ./lua/lualine.lua;
      }
      # toggleterm
      {
        plugin = toggleterm-nvim;
        type = "lua";
        config = builtins.readFile ./lua/toggleterm.lua;
      }
      # indent-blankline
      {
        plugin = indent-blankline-nvim;
        type = "lua";
        config = builtins.readFile ./lua/indentline.lua;
      }
      # autopairs
      {
        plugin = nvim-autopairs;
        type = "lua";
        config = builtins.readFile ./lua/autopairs.lua;
      }
      # nvim-surround
      {
        plugin = nvim-surround;
        type = "lua";
        config = builtins.readFile ./lua/nvim-surround.lua;
      }
      # treesj
      {
        plugin = treesj;
        type = "lua";
        config = builtins.readFile ./lua/treesj.lua;
      }
      # persistence-nvim
      {
        plugin = persistence-nvim;
        type = "lua";
        config = ''
          require("persistence").setup()
        '';
      }
      # which-key
      {
        plugin = which-key-nvim;
        type = "lua";
        config = builtins.readFile ./lua/whichkey.lua;
      }

      # Cmp
      nvim-cmp
      cmp-buffer
      cmp-path
      cmp_luasnip
      cmp-nvim-lsp
      cmp-nvim-lua

      # Snippets
      luasnip
      friendly-snippets

      # LSP
      # nvim-lspconfig
      {
        plugin = nvim-lspconfig;
        type = "lua";
        config = ''
          require('lspconfig').nil_ls.setup({
              cmd = { "${pkgs.nil}/bin/nil" }
          })
          require('lspconfig').lua_ls.setup({
              cmd = { "${pkgs.lua-language-server}/bin/lua-language-server" }
          })
        '';
      }
      # typescript-nvim
      {
        plugin = typescript-nvim;
        type = "lua";
        config = builtins.readFile ./lua/typescript-nvim.lua;
      }
      # crates.nvim
      {
        plugin = crates-nvim;
        type = "lua";
        config = builtins.readFile ./lua/crates.nvim.lua;
      }
      # null-ls
      {
        plugin = null-ls-nvim;
        type = "lua";
        config = builtins.readFile ./lua/null-ls.lua;
      }
      # refactoring
      {
        plugin = refactoring-nvim;
        type = "lua";
        config = builtins.readFile ./lua/refactoring.lua;
      }

      # Telescope
      {
        plugin = telescope-nvim;
        type = "lua";
        config = builtins.readFile ./lua/telescope.lua;
      }

      # Treesitter
      {
        plugin = nvim-treesitter.withAllGrammars;
        type = "lua";
        config = builtins.readFile ./lua/treesitter.lua;
      }

      # telescope-manix
      telescope-manix

      # gitsigns
      {
        plugin = gitsigns-nvim;
        type = "lua";
        config = builtins.readFile ./lua/gitsigns.lua;
      }
      # comment-nvim
      {
        plugin = comment-nvim;
        type = "lua";
        config = builtins.readFile ./lua/comment.lua;
      }

      # nvim-ts-context-commentstring 
      #   config is integrated with treesitter and comment-nvim
      nvim-ts-context-commentstring

      # nvim-ts-autotag
      {
        plugin = nvim-ts-autotag;
        type = "lua";
        config = builtins.readFile ./lua/nvim-ts-autotag.lua;
      }

      # trouble-nvim
      {
        plugin = trouble-nvim;
        type = "lua";
        config = builtins.readFile ./lua/trouble.lua;
      }
      # todo-comments
      {
        plugin = todo-comments-nvim;
        type = "lua";
        config = builtins.readFile ./lua/todo-comments.lua;
      }
      # leap
      {
        plugin = leap-nvim;
        type = "lua";
        config = builtins.readFile ./lua/leap.lua;
      }
      # wilder
      {
        plugin = wilder-nvim;
        type = "lua";
        config = builtins.readFile ./lua/wilder.lua;
      }
      {
        plugin = markdown-preview-nvim;
        type = "lua";
        config = builtins.readFile ./lua/markdownpreview.lua;
      }
      # zen mode
      {
        plugin = zen-mode-nvim;
        type = "lua";
        config = builtins.readFile ./lua/zen-mode.lua;
      }
      # twilight-nvim
      {
        plugin = twilight-nvim;
        type = "lua";
        config = builtins.readFile ./lua/twilight.lua;
      }
      # nvim-highlight-colors
      {
        plugin = nvim-highlight-colors;
        type = "lua";
        config = builtins.readFile ./lua/nvim-highlight-colors.lua;
      }
      # nvim-lastplace
      {
        plugin = nvim-lastplace;
        type = "lua";
        config = builtins.readFile ./lua/nvim-lastplace.lua;
      }
      # kmonad-vim (kbd syntax highlighting)
      kmonad-vim

      # Colorschemes
      {
        plugin = kanagawa-nvim;
        # plugin = tokyonight-nvim;
        # plugin = rose-pine;
        type = "lua";
        config = builtins.readFile ./lua/colorschemes/kanagawa.lua + ''
          local status_ok, _ = pcall(vim.cmd, "colorscheme " .. "kanagawa")
          if not status_ok then
              return
          end
        '' + builtins.readFile ./lua/colorschemes/setbgtotransparent.lua;
      }
    ];
  };
}

This is probably not a bug but a breaking change that I missed to patch on my config (?)

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.38, NixOS, 23.11 (Tapir), 23.11.20230720.5df4d78`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
stale[bot] commented 2 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.