nix-community / home-manager

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

Neovim settings duplication #2133

Closed ghost closed 2 years ago

ghost commented 3 years ago

Issue description

I'm on nixos unstable, updated today.

I noticed that my startup time is longer than I'm used to. I run vim with startuptime to troubleshoot. I see many duplicated entries.

005.922  000.270  000.270: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
007.287  002.944  002.674: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/synload.vim
018.550  009.908  009.908: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/filetype.vim
019.896  016.986  004.135: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syntax.vim
024.455  000.170  000.170: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
027.394  000.135  000.135: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
035.290  012.724  012.419: sourcing /nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir/pack/home-manager/start/gruvbox/colors/gruvbox.vim
040.101  000.293  000.293: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
043.990  000.265  000.265: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
051.493  013.521  012.963: sourcing /nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir/pack/home-manager/start/gruvbox/colors/gruvbox.vim
052.155  000.460  000.460: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/nosyntax.vim
058.217  000.293  000.293: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
062.056  000.275  000.275: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
069.619  013.540  012.973: sourcing /nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir/pack/home-manager/start/gruvbox/colors/gruvbox.vim
069.715  016.234  002.693: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/synload.vim
069.751  018.094  001.400: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syntax.vim
074.651  000.311  000.311: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
078.478  000.266  000.266: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
085.915  013.431  012.854: sourcing /nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir/pack/home-manager/start/gruvbox/colors/gruvbox.vim
090.705  000.294  000.294: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
094.576  000.266  000.266: sourcing /nix/store/cgqrja3zqwzq5yrwl3cv2w2qc8w3gak1-neovim-unwrapped-0.4.4/share/nvim/runtime/syntax/syncolor.vim
101.986  013.389  012.828: sourcing /nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir/pack/home-manager/start/gruvbox/colors/gruvbox.vim
102.061  099.741  011.597: sourcing /nix/store/c8vdrnrj47yjrm2ky0jwxin5d7ddcvbf-init.vim
102.066  000.035: sourcing vimrc file(s)

I see that in my configuration I have duplicated entries:

" configuration generated by NIX
set nocompatible

set packpath^=/nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir
set runtimepath^=/nix/store/6rpq1qaxl4qkd0mh05svlkbmna6l4cr4-vim-pack-dir

+-- 67 lines: Settings ·································································································
+-- 20 lines: Plugins ··································································································
+-- 32 lines: Mappings ·································································································
+-- 67 lines: Settings ·································································································
+-- 20 lines: Plugins ··································································································
+-- 32 lines: Mappings ·································································································

Technical details

$ nix-shell -p nix-info --run "nix-info -m" these paths will be fetched (0.05 MiB download, 0.28 MiB unpacked): /nix/store/lp90qhw19dcp79cnlicjg09llgh7dzsz-bash-interactive-4.4-p23-dev copying path '/nix/store/lp90qhw19dcp79cnlicjg09llgh7dzsz-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...

mixedCase commented 3 years ago

So I'm not crazy. This is also happening to me, also running 21.11.

programs.neovim = {
  enable = true;
  extraConfig = ''
    luafile "/home/mixedcase/.config/nvim/init.lua";
  '';
};

results in this .config/nvim/init.vim:

" configuration generated by NIX
set nocompatible

set packpath^=/nix/store/kkfrhcjnwx7170iyqmf7rp0rycf8xhj1-vim-pack-dir
set runtimepath^=/nix/store/kkfrhcjnwx7170iyqmf7rp0rycf8xhj1-vim-pack-dir

luafile "/home/mixedcase/.config/init.lua";
luafile "/home/mixedcase/.config/init.lua";
mixedCase commented 3 years ago

@yourfavouriteuncle For whatever it's worth, I just realized I could workaround this with relative ease, hope it helps in the meantime:

extraConfig = ''
  if !exists("homemanagerbug")
    let homemanagerbug = "yes"
    luafile /home/mixedcase/.config/nvim/init.lua
  endif
'';
berbiche commented 3 years ago

cc: @teto

teto commented 3 years ago

the following patch should fix it.

diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix
index c63f04e1..12377ab4 100644
--- a/modules/programs/neovim.nix
+++ b/modules/programs/neovim.nix
@@ -51,7 +51,7 @@ let
         (map (x: if x ? plugin && x.optional == true then x.plugin else null)
           cfg.plugins);
     };
-    customRC = pkgs.lib.concatMapStrings pluginConfig cfg.plugins + cfg.extraConfig;
+    # customRC = pkgs.lib.concatMapStrings pluginConfig cfg.plugins + cfg.extraConfig;
   };

   extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
stale[bot] commented 3 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close 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

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, 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.

mixedCase commented 3 years ago

Still valid as of 7d9ba15214004c979d2c8733f8be12ce6502cf8a (latest commit for release-21.05)

teto commented 3 years ago

@mixedCase does the above snippet work for you ?

mixedCase commented 3 years ago

No idea how to apply your patch without a lot of work to tell you the truth. I get home-manager with fetchGit like this:

  home-manager = builtins.fetchGit {
    url = "https://github.com/nix-community/home-manager.git";
    rev = "7d9ba15214004c979d2c8733f8be12ce6502cf8a";
    ref = "release-21.05";
  };

How can I apply your patch on top without making a whole 'nother repo?

teto commented 3 years ago

I think the best it to fork the project, then patch it . You dont have to necessarily push the changes to your fork, you can reference a local clone. This way you are ready next time you want to contribute ;)

stale[bot] commented 2 years ago

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close 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

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, 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.

mixedCase commented 2 years ago

This is still relevant.

mixedCase commented 2 years ago

I don't know what happened in the last 3 months but I can no longer reproduce this using rev a8d00f5c038cf7ec54e7dac9c57b171c1217f008

Seems fixed to me!

sumnerevans commented 2 years ago

I'm going to close then. If you run into it again, we can reopen.