0

So I wanted to lazy-load packer on certain commands, mostly just :PackerSync, but including some more. So in my plugins.lua file in ~/.config/nvim/lua, I added opt = true to enable lazy loading, and for certain commands, I added cmd = {'PackerCompile', 'PackerClean', 'PackerInstall', 'PackerUpdate', 'PackerSync', 'PackerStatus', 'PackerLoad'} to start packer on those commands. Also, according to Packer's official GitHub Repository, it told you to add vim.cmd [[packadd packer.nvim]] if you "have packer configured as opt", in which I did, but I followed my own rules in hopes that my code will be more readable, but that will function the same, in which I did first tried vim.cmd [[packadd packer.nvim]] before doing my vim.cmd('packadd packer.nvim'), and it worked pretty much the same. And of course, I didn't forget to add require('plugins') in my init.lua in ~/.config/nvim. So after all that—and by the way I have not installed anything beforehand, so this is a completely clean installation—, I ran :PackerSync, which, when I ran for the first time, worked, meaning it did indeed show up, never mind it hadn't successfully installed a plugin (SnipRun) that I have configured in the plugins.lua file, in which I had multiple attempts trying to installed it by pressing R but failed. I tried again by reopening nvim and running that very command (:PackerSync), but this time, Packer didn't even show up, only a red error message spat in my face:

Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:91: Vim:E492: Not an editor command: PackerSync
Please check your config for correctness

I had no idea what to do, so I just ran the same command a couple more times.

Yeah It still failed, so from research I attempted to reinstall it but the same error appeared again and again, I tried :PackerCompile, but then it didn't recognize that command itself! I believe it may be most possible that something I configured does not do what I expected it to do, and thus causing the error. I greatly appreciate anyone who acknowledges and attempts to mitigate this issue. Thanks!

Jimmy Zeng
  • 37
  • 1
  • 7

0 Answers0