wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.72k stars 262 forks source link

I can't use packer without sourcing the file #1125

Open fnacarellidev opened 1 year ago

fnacarellidev commented 1 year ago

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

EdenEast commented 1 year ago

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

fedgrant commented 1 year ago

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.

EdenEast commented 1 year ago

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?

fedgrant commented 1 year ago

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

EdenEast commented 1 year ago

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.