Vim :help slow to load

I’ve noticed that accessing help files (e.g. :help) in vim is very slow – one or two seconds to load a help file – much slower than when doing so in a vim that wasn’t installed through nix.

Has anyone else noticed this? Any idea why it is so?

I’m on NixOS and using vim_configurable, though I’m not sure that introduced additional slowness.

I’m using a similar setup to you, NixOS, vim_configurable, though I’m using it through home-manager and can’t say I’m experiencing any issues with help load time. Trying base vim doc, as well as from some of the plugins I use.

Perhaps you could elaborate a bit more on your configuration. Do you have a very large set of plugins? Maybe it’s related to your hardware or perhaps filesystem.

One other thought that comes to mind is back when I used pathogen to load plugins there was a step to compile or generate the help doc. I don’t think it applies exactly to this situation, but maybe it comes up faster on a second access to the doc?

I’ve gradually moved most of my configuration out of vimrc and into a bunch of plugins. All told, looks like I’ve got 47 plugins, so maybe that’s related.

The config is at https://github.com/ivanbrennan/nixbox/blob/602c43c8d30f69d0c74f9e5946644944033fdf13/overlays/vim/default.nix

If I’ve followed the trail correctly it looks like you’re using vim-plug in the customRC file you’re using. It probably works but it might be on contention with the plugin load style that vim_configurable uses. As it builds a custom path of and adds that to the packpath and runtimepath at the top of the vimrc it generates. Just a guess but that could be the cause of the slowness as maybe there are duplicates of some of your plugins in the runtime.

As someone who used to load a lot more plugins, vim plugins can definitely add up. Are the 2 vims (nix and non-nix) running the same configuration?

Ah, that’s not in the revision of my vimrc I’m currently using. I ditched vim-plug a while back. My current vimrc is very nearly empty:

(and I don’t have a ~/.vim/vimrc.local)

So the same set of plugins loaded with the Vim8 plugin loading style outside of NixOS does not have the issue with the help files coming up?

I’d also maybe check to see if it’s a particular plugin that causes the issue, maybe biset them, loading half of them and see if you have the issue with both halves, and narrow it down from there.

The last thing I can think of is if you look at the vim executable it’s actually a shell script that runs the binary with the custom vimrc file that it generates, but it loads the plugins before the customRC values are used. Maybe that will provide a clue for you. Mine starts with (some whitespace removed for bevity):

" configuration generated by NIX
set nocompatible

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

filetype indent plugin on | syn on

My customRC follows that. So you might wish to put those vars you’re setting in the beforePlugins option instead of customRC. The pack dir contains all my plugins plus vim-sensible which is added by home-manager.

Not sure I’m helping much with the specific slowness issue here, but maybe knowing some more of the internals will help you figure it out.

Thanks, I really appreciate the help regardless! I don’t currently have access to a non-NixOS machine to reconfirm that the same set of plugins don’t cause the same issue on a non-nix vim, but I’ll try what you’ve suggested, starting with the bisect.