Open herrbischoff opened 2 years ago
I'm having this same issue myself, the config function doesn't seem to run but if I remove the wrapping anonymous function my configs work--but when I am bootstrapping a new installation of packer it is unable to pick up from those unwrapped requires
Running into the same issue, the mentioned fix also works for me.
macOS 12.4 21F79 arm64
NVIM v0.7.2
The problem with the mentioned fix--removing the wrapping function to include your config--upon bootstrapping of a brand new installation of packer, I encountered lua module loading errors that blocked packer from being able to load the plugin specification.
Replicating the bootstrapping error:
init.lua
:use {
'neovim/nvim-lspconfig',
config = require('plugin-settings/nvim-lspconfig')
}
$ rm ~/.local/share/nvim/site/pack/ -rf
PackerInstall
In efforts to avoid bootstrapping errors, I opted to instead load my configs from a specified directory (~/.config/nvim/lua/config
) instead of specifying per-module in my packer specification.
-- Load config files in config/
-- adaptation of https://github.com/mrjones2014/load-all.nvim
local ok, scan = pcall(require, 'plenary.scandir')
if ok then
for _, file in ipairs(scan.scan_dir(os.getenv('HOME') .. '/.config/nvim/lua/config', { depth = 0 })) do
dofile(file)
end
end
Even more perplexing is that @wbthomason's dotfiles do not use the function statement at all. Instead they wrap the require
method in double brackets, like [[require('config.cmp')]]
.
If you have a minute, @wbthomason, could you explain why that is and why apparently the documented setup does not work for some people?
Can you try setting a more verbose log level and running PackerCompile
again? If that's producing no file, something is seriously wrong, and I'm unable to reproduce the problem. My setup uses the string method out of convenience, because it lets me tweak the config without recompiling. The function method should work (and does for me), though.
Looking at this a bit more, it's very suspect that PackerCompile
is producing nothing. Where do you include your specifications? The compile step should always either produce a file or fail, so something is amiss.
Have same issue. run
also didn't get executed. config = [[ print("some config") ]]
have no effect too.
nvim --version
:
❯ nvim --version
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
- `git --version` :
❯ git --version git version 2.37.1
<details>
<summary>`packer.nvim.log` after run `PackerSync`</summary>
[DEBUG Sun 31 Jul 2022 01:10:41 AM CST 25905493194528] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:531: packer.sync: requiring modules [DEBUG Sun 31 Jul 2022 01:10:41 AM CST 25905494698943] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:327: Processing plugin specs [DEBUG Sun 31 Jul 2022 01:10:41 AM CST 25905499596680] ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:176: Updating FS state [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905562085581] ...site/pack/packer/start/packer.nvim/lua/packer/update.lua:56: Fixing plugin types [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905562116365] ...site/pack/packer/start/packer.nvim/lua/packer/update.lua:67: Done fixing plugin types [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905562137784] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:22: Starting clean [INFO Sun 31 Jul 2022 01:10:42 AM CST 25905562196629] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:82: Already clean! [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905562435976] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:561: Gathering install tasks [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905562508696] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:564: Gathering update tasks [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905566881237] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:568: Gathering luarocks tasks [DEBUG Sun 31 Jul 2022 01:10:42 AM CST 25905566906352] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:581: Running tasks [DEBUG Sun 31 Jul 2022 01:10:44 AM CST 25907752141086] ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:327: Processing plugin specs [ERROR Sun 31 Jul 2022 01:10:44 AM CST 25907755111950] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:709: invalid value (boolean) at index 16 in table for 'concat'
</details>
@luck07051 in your case you have a bug in your config if you look at the packer logs it shows
[ERROR Sun 31 Jul 2022 01:10:44 AM CST 25907755111950] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:709: invalid value (boolean) at index 16 in table for 'concat'
This is obscure as far as warnings go, but something is incorrect in your plugin specs is the crux of it. I'd start by doing a binary search, i.e. comment out half and see if there is any error if not comment out the other half etc.
also, looking at your config properly, there is a lot of stuff that won't work as you'd expect or hope.
To explain the config
key a little. It is essentially giving packer something to execute at a later time. It's essentially a type of callback in terms of the way it works.
You need to specify the config key as a function or as a string, which will later be executed as lua. Valid examples are
config = function()
require('module').setup()
end
-- INVALID
config = require('module').setup()
The first example is a callback to execute later, the second example is already called and is essentially equivalent to whatever the return value of setup is, which for most plugins will be nil
so your config for all of those plugins is essentially nil
using a string means that you can do config = [[require('plugin').setup()]]
the important difference here is that the string is just a string at this point when you add it so it won't be called (since it's a string). Later packer will try to execute this string as lua code and since it's valid it will then be called at that point.
@akinsho you are right. I fix plug/*
by let those return a function, Packer work properly. Thank you!
Hit this issue as well. I've been trying to setup neorg a few times and quit every time because "it just didn't work". Spent some hours debugging the issue and it looks like packer ignores the config function.
Installation works, all the other config functions from the other 55 plugins work, and there are no errors.
@3rd please read through this issue and try the solution described here, this error sounds most likely to relate specifically to neorg or to how you have set up your config. I use neorg and don't encounter any issues like this with packer, so it is almost certainly a configuration issue.
I am also experiencing this behavior and might have run into a scenario which I hope may assist in debugging.
This declaration (which I essentially copied from @wbthomason's config):
use {
{
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
'telescope-fzf-native.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
wants = {
'popup.nvim',
'plenary.nvim',
'telescope-fzf-native.nvim',
'telescope-ui-select.nvim',
},
config = [[print("hello from telescope config")]],
cmd = 'Telescope',
module = 'telescope',
},
{
'nvim-telescope/telescope-fzf-native.nvim',
run = 'make',
},
{
'nvim-telescope/telescope-ui-select.nvim'
}
}
will not print hello from telescope config
from the telescope.nvim
config
callback.
If I additionally provide a callback to telescope-ui-select.nvim
like so:
use {
{
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
'telescope-fzf-native.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
wants = {
'popup.nvim',
'plenary.nvim',
'telescope-fzf-native.nvim',
'telescope-ui-select.nvim',
},
setup = [[require('config.telescope_setup')]],
config = [[print("hello from telescope config")]],
cmd = 'Telescope',
module = 'telescope',
},
{
'nvim-telescope/telescope-fzf-native.nvim',
run = 'make',
},
{
'nvim-telescope/telescope-ui-select.nvim',
config = function() require('config.telescope') end
}
}
then both config
callbacks will execute (after running :PackerSync
, of course).
I have checked packer.nvim.log
as suggested by @akinsho but no logs are generated.
The telescope's plugin spec has both cmd
and module
. This means that the plugin is optional. The setup
function will execute on start but the config
will only execute when it is loaded. For example since cmd = 'Telescope'
is defined the config
function will execute if you call :Telescope
.
Optional keys are:
after
cmd
ft
keys
event
cond
setup
fn
module
module_pattern
Also since they are optional and need to be loaded they have to be compiled.
The telescope's plugin spec has both
cmd
andmodule
. This means that the plugin is optional. Thesetup
function will execute on start but theconfig
will only execute when it is loaded. For example sincecmd = 'Telescope'
is defined theconfig
function will execute if you call:Telescope
.
Well, thank you, this was very helpful! I removed both keys and it now behaves as I expected.
Sorry for the fuzz, 'twas a classic case of getting into a new ecosystem plus "user can't read documentation properly" ...
nvim --version
:Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/opt/local/share/nvim"
Run :checkhealth for more info
ProductName: macOS ProductVersion: 11.6.7 BuildVersion: 20G630
alacritty 0.10.1 (2844606)
Run
:PackerInstall
and:PackerCompile
.Actual behaviour
The plugin gets installed when running
:PackerInstall
but therequire()
method in the function statement is never executed. I observed the same behavior with simply requiring external config files. Everything within the function statement appears to be silently ignored and never gets executed.:PackerCompile
does not appear to create a corresponding file.However, when I remove the surrounding function statement, everything gets loaded, executed and generally works as expected, with the exception of
:PackerCompile
creating a corresponding file:It's quite possible that I'm overlooking something (obvious?) here but I couldn't think of anything.
Expected behaviour
Execute the functions statements' content as currently documented.
packer files
Plugin specification file(s)
```lua return require('packer').startup(function() use 'wbthomason/packer.nvim' -- packer itself use { 'arcticicestudio/nord-vim' } -- Commenting -- use { 'tomtom/tcomment_vim' } use { 'numToStr/Comment.nvim', config = require('Comment').setup() } use { 'neovim/nvim-lspconfig', config = require('plugin-settings/nvim-lspconfig') } end) ```packer log file
`~/.cache/nvim/packer.nvim.log` does not existpacker compiled file
`packer_compiled.vim` does not exist