jbyuki / one-small-step-for-vimkind

Debug adapter for Neovim plugins
MIT License
396 stars 10 forks source link

Vimscript function must not be called in a lua loop callback #51

Closed mtrajano closed 2 months ago

mtrajano commented 3 months ago

Got the following error when following the test steps in the help doc. Repro steps (copied from :h osv):

Copy the following in a myscript.lua

  print("start")
  for i=1,10 do
    print(i)
  end
  print("end")
  1. Open a Neovim instance (instance A)
  2. Launch the DAP server with (A) > :lua require"osv".launch({port=8086})
  3. Open another Neovim instance (instance B)
  4. Open myscript.lua (B)
  5. Place a breakpoint on line 2 using (B) > :lua require"dap".toggle_breakpoint()
  6. Connect the DAP client using (B) > :lua require"dap".continue()
  7. Run myscript.lua in the other instance (A) > :luafile myscript.lua
  8. The breakpoint should hit and freeze the instance (B)

Looks like this is the offending line: https://github.com/jbyuki/one-small-step-for-vimkind/blob/main/lua/osv/init.lua#L62

Errors start popping up

Full stacktrace:

Error executing luv callback:
...re/nvim/lazy/one-small-step-for-vimkind/lua/osv/init.lua:62: E5560: Vimscript function must not be called in a lua loop callback
stack traceback:
        [C]: in function 'rpcnotify'
        ...re/nvim/lazy/one-small-step-for-vimkind/lua/osv/init.lua:62: in function 'sendProxyDAP'
        ...re/nvim/lazy/one-small-step-for-vimkind/lua/osv/init.lua:1125: in function '__index'
        vim/_editor.lua: in function <vim/_editor.lua:0>