arminveres / md-pdf.nvim

Preview markdown files and convert to PDF inside Neovim!
59 stars 4 forks source link

error: nvim_echo must not be called in a lua loop callback #8

Open avsej opened 5 months ago

avsej commented 5 months ago

I've configured using defaults from readme. Neovim version: https://github.com/neovim/neovim/commit/beca82721

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'
        .../site/pack/packer/start/md-pdf.nvim/lua/md-pdf/utils.lua:17: in function 'log_info'
        ...m/site/pack/packer/start/md-pdf.nvim/lua/md-pdf/init.lua:61: in function 'print_out'
        ...m/site/pack/packer/start/md-pdf.nvim/lua/md-pdf/init.lua:108: in function <...m/site/pack/packer/start/md-pdf.nvim/lua/md-pdf/init.lua:98>
arminveres commented 5 months ago

Hi, that's weird, I am on nightly and I have not encountered this error. Did you build Neovim from scratch on that commit? Could you post your nvim --version?

powerblo commented 5 months ago

Hey, I've encountered the same error, here's my nvim version.

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
vlimki commented 4 months ago

Same error here, on nvim v0.10.0-dev-1390+gf1775da07

arminveres commented 4 months ago

Since I am unable to reproduce, I can not really fix it properly, but I created a branch and would ask you to try to examine it, then we'll see if it's fixed! add the following line to the lazy setup:

branch = "fix/echo-loop"

Thanks!

vlimki commented 4 months ago

Hey, thanks for the quick response! Unfortunately, it did not fix it for me.

I tried to do some inspection myself and commenting out the line in utils.lua:

function M.log_info(str)
    -- vim.notify(str)
end

fixed it for me. Works great now! Not sure what's happening under the hood, but this is the error I get when the line is not commented out: image

arminveres commented 3 months ago

Hi there, I updated, force pushed, to the fix/echo-loop branch, could someone check, if the issue persists? I wrapped the vim.notify call into a pcall therefore if there is an error, it is suppressed. @vlimki @avsej @powerblo

brennenputh commented 4 weeks ago

Just attempted the fix/echo-loop branch, chiming in to say that the fix works perfectly for me.

powerblo commented 1 week ago

fix/echo-loop works well with nvim v0.10.0. Thanks a lot!