luckasRanarison / nvim-devdocs

Neovim DevDocs integration
MIT License
265 stars 19 forks source link

`:DevdocsFetch` raise error `E5560: nvim_echo must not be called in a lua loop callback` #2

Closed mars90226 closed 1 year ago

mars90226 commented 1 year ago

First, thanks for this plugin! I cannot count how many time I need to switch between neovim & browser to docs.

This bug is that when executing :DevdocsFetch, neovim raise E5560: nvim_echo must not be called in a lua loop callback with the following stack traceback:

Fetching DevDocs registery...
Error executing luv callback:
vim/_editor.lua:0: E5560: nvim_echo must not be called in a lua loop callback
stack traceback:
    [C]: in function 'nvim_echo'
    vim/_editor.lua: in function 'notify'
    ...share/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/notify.lua:3: in function 'log'
    ...e/nvim/lazy/nvim-devdocs/lua/nvim-devdocs/operations.lua:28: in function '_user_on_exit'
    .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:239: in function '_shutdown'
    .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:46: in function <.../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:37>

I think the problem is using vim.notify() when hit-enter-prompt is active. This problem may not occur when using noice.nvim because it changes vim.notify()'s implementation. I can temporarily fix it by wrapping vim.notify() with vim.schedule_wrap(), but I'm not sure if it's the correct fix.

luckasRanarison commented 1 year ago

Thanks for giving my plugin a try :), you're correct vim functions can't be called inside a lua callback but I didn't realize it because I am using noice lol. I think wrapping notify functions is the only solution, thanks for the report! I'll fix it right away.

luckasRanarison commented 1 year ago

87be468 should fix it.

mars90226 commented 1 year ago

I can confirm the bug is fixed, thanks!