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 263 forks source link

Behavior of passing a function to `config` does not match using `.config/nvim/after/plugin/foo.lua` #1178

Open starptr opened 1 year ago

starptr commented 1 year ago

Steps to reproduce

Use the which-key plugin. When configuring, place

local wk = require("which-key")
wk.setup()
wk.register(mappings, opts)

in packer.nvim's config field first as a function, then inside the config after directory.

Actual behaviour

Which-key doesn't work when using packer's config field.

Expected behaviour

Which-key should work, or packer.nvim should document why the config field has a different behavior.

packer files

Plugin specification file(s) Post or link your plugin specification files here, if you aren't able to provide a minimal reproducer
packer log file Post the contents of ~/.cache/nvim/packer.nvim.log here
packer compiled file Post the contents of `packer_compiled.vim` here
MithicSpirit commented 1 year ago

Similar issue using https://github.com/airblade/vim-rooter. Doing vim.cmd('echo g:rooter_patterns') in after/plugin works fine, but doing it either as a string or inside a function for the config gives me an error that the variable is not yet initialized.