anuvyklack / pretty-fold.nvim

Foldtext customization in Neovim
Apache License 2.0
441 stars 21 forks source link

[Error] error messages pops up on entering nvim #12

Closed smallpondtom closed 2 years ago

smallpondtom commented 2 years ago

I am getting this error message whenever entering my neovim

Error executing vim.schedule lua callback: ...k/packer/start/pretty-fold.nvim/lua/pretty-fold/util.lua:11: attempt to call field 'notify_once' (a nil value) stack traceback: ...k/packer/start/pretty-fold.nvim/lua/pretty-fold/util.lua:11: in function <...k/packer/start/pretty-fold.nv im/lua/pretty-fold/util.lua:10>

This should be solved by changing

vim.schedule(callback)

at line 11 in util.lua to

---Raise a warning message
---@param msg string
function M.warn(msg)
   vim.schedule_wrap(function()
      vim.notify_once('[pretty-fold.nvim] '..msg, vim.log.levels.WARN)
   end)
end

Since this way it defers callback until the Nvim API is safe to call.

anuvyklack commented 2 years ago

No, you are wrong. vim.schedule_wrap is for another, see :help lua-loop-callbacks.

Can you give a minimal config to reproduce the error?

anuvyklack commented 2 years ago

Can your try

function M.warn(msg)
   vim.schedule(vim.schedule_wrap(function()
      vim.notify_once('[pretty-fold.nvim] '..msg, vim.log.levels.WARN)
   end))
end
smallpondtom commented 2 years ago

Can your try

function M.warn(msg)
   vim.schedule(vim.schedule_wrap(function()
      vim.notify_once('[pretty-fold.nvim] '..msg, vim.log.levels.WARN)
   end))
end

Unfortunately that still throws the same error.

anuvyklack commented 2 years ago

Maybe you don't have notify_once function? Can you check? Try to replace it with notify.

smallpondtom commented 2 years ago

oh you're right. That fixed it. Thanks. By the way, I use Nvim v0.6.1

anuvyklack commented 2 years ago

Fixed in 9075011481e6c48beb4cbb4a3009c421d1a01d3e