Closed garaiza-93 closed 1 year ago
Can't reproduce it, make sure that the mini config with packer.nvim still causes the issue.
I have this problem too, I install the plugin via lazy.nvim and here is my config:
return {
'kevinhwang91/nvim-ufo',
dependencies = 'kevinhwang91/promise-async',
config = function()
vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
end,
}
I reboot neovim, seems everything's good, checkhealth's good, then I open a python file and type zM, and the following error shows(typing zR shows the same error):
E5108: Error executing lua: ....local/share/nvim/lazy/nvim-ufo/lua/ufo/fold/manager.lua:89: attempt to index field 'buffers' (a nil value)
stack traceback:
....local/share/nvim/lazy/nvim-ufo/lua/ufo/fold/manager.lua:89: in function 'get'
...izhen/.local/share/nvim/lazy/nvim-ufo/lua/ufo/action.lua:107: in function <...izhen/.local/share/nvim/lazy/nvim-ufo/lua/ufo/action.lua:104>
Could anyone pls tell me what should I do?
Don't lazy load.
I added lazy = false,
after dependencies
and before config
, still not working though.
Now I use the following config to fold, which works well, leave it here as a reference:
vim.o.foldenable = true
opt.foldmethod = "expr"
opt.foldexpr = "nvim_treesitter#foldexpr()" --use treesitter to fold
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
-- add following or files opened by telescope cannot be folded
vim.api.nvim_create_autocmd({ "BufEnter" }, { pattern = { "*" }, command = "normal zx", })
I'm having the same issue here. Any news on this @yizhenAllen ?
I'm having the same issue here. Any news on this @yizhenAllen ?
No hah, now I simply use treesitter to fold, you can check my config above if you're interested.
@yizhenAllen I managed to put it to work just now. This was the missing bit that apparently is necessary:
{
"kevinhwang91/nvim-ufo",
dependencies = "kevinhwang91/promise-async",
event = "VeryLazy",
config = function(_, opts)
-- This piece in the config right here
require("ufo").setup(opts)
end
}
@yizhenAllen I managed to put it to work just now. This was the missing bit that apparently is necessary:
{ "kevinhwang91/nvim-ufo", dependencies = "kevinhwang91/promise-async", event = "VeryLazy", config = function(_, opts) -- This piece in the config right here require("ufo").setup(opts) end }
It works pretty well, thank you!
event = "VeryLazy"
is the point rather than lazy = false
Neovim version (nvim -v | head -n1)
NVIM v0.9.0-dev-124-gbd7ca10fd
Operating system/version
Manjaro
How to reproduce the issue
cat mini.lua
PackerSync
, using the above configurationError in packer_compiled: ...site/pack/packer/start/nvim-ufo/lua/ufo/fold/manager.lua:89: attempt to index field 'buffers' (a nil value)
Expected behavior
I expect to be able to open neovim without this confusing error. I say that it is confusing, because after double-checking the source code, I don't think this should be an issue.
Actual behavior
Error in packer_compiled: ...site/pack/packer/start/nvim-ufo/lua/ufo/fold/manager.lua:89: attempt to index field 'buffers' (a nil value)
Note: I am aware that from another issue, using
PackerCompile
followed byPackerUpdate
tends to sidestep this error. However, I am curious as to why usingPackerSync
is an issue.