packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

I can't use packer without sourcing the file

Open fnacarellidev opened this issue 2 years ago • 5 comments

Everytime I need to user packer or any of its commands I need to source the file, then use the command.

fnacarellidev avatar Nov 12 '22 21:11 fnacarellidev

Can you clarify on what you mean by source the file. What file? How have you installed packer? Is it needing to packadd packer?

EdenEast avatar Nov 15 '22 18:11 EdenEast

I have a similar issue. I need to go to my packer.lua file and run :so to get the :Packer commands to appear. It also does not appear when I run :checkhealth but I am not sure if its supposed to.

fedgrant avatar Jan 19 '23 21:01 fedgrant

Where is your plugin.lua file? If it is under your lua folder is it being required correctly? When adding a print statement in that file does it appear when you startup?

EdenEast avatar Jan 19 '23 23:01 EdenEast

I have a packer.lua which is where I initialize packer. I don't have a plugin.lua file. The packer.lua is .config/nvim/lua/fed/packer.lua. When I added the print, it didn't appear on startup. When I required the packer.lua in my init.lua file it appeared, which also resolves the problem. Should I rename the packer.lua file to plugin.lua

fedgrant avatar Jan 20 '23 04:01 fedgrant

I would recommend reading :h runtimepath for details on how vim loads files on startup.

Because your lua file is under the lua folder and not the plugin folder it will not be auto sourced on startup. You have to use lua to require that file. In your init.lua (or any other file that has been already required) you need to have require("fed.packer"). This will require that file and load its contents.

EdenEast avatar Jan 20 '23 05:01 EdenEast