jbyuki / one-small-step-for-vimkind

Debug adapter for Neovim plugins
MIT License
409 stars 11 forks source link

Cannot launch with another rpc client #30

Closed axieax closed 1 year ago

axieax commented 1 year ago

Hi, I'm having trouble launching the server when I have another plugin flatten.nvim which connects to the nvim rpc server. Is there a solution to ensure both plugins work at the same time?

E5108: Error executing lua Vim:Error invoking 'nvim_exec_lua' on channel 3:
ch 3 was closed by the client
stack traceback:
        [C]: in function 'rpcrequest'
        ...re/nvim/lazy/one-small-step-for-vimkind/lua/osv/init.lua:134: in function 'launch'
        [string ":lua"]:1: in main chunk
jbyuki commented 1 year ago

To give a small overview of what's happening, one-small-step-for-vimkind (osv) is spawing a embedded instance of neovim to exchange DAP messages, this is required as part of its good operation. The problem is that flatten.nvim seem to exit that instance immediatly. I haven't tested the code so it's just suppositions but I think if an embedded neovim is spawned within neovim without any argument file, flatten.vnim kills it basically. If I'm correct, any plugin using an embedded neovim instance will be unusable with flatten.nvim. Maybe ask them about this. Even if osv spawns an instance with a dummy file, it will be killed. I don't have a good solution right now, I suggest talking to flatten.nvim's creator for solutions.

EDIT: I have added a temporary workaround. It's very hacky so I still suggest talking to flatten's creator. It will basically unset $NVIM when spawning the embedded neovim which will not allow flatten.nvim to know it's embedded. Launch the osv server like this :lua require"osv".launch({port = 8086, flatten_nvim= true}). Let me know if it works, I haven't tested it.

axieax commented 1 year ago

Thanks for the detailed explanation and temporary fix! I'll create an issue under flatten.nvim as well :))

jbyuki commented 1 year ago

Great, I'll make that ugly hack disappear once there is a better solution for it.

axieax commented 1 year ago

Issue should be resolved now on flatten.nvim's side. Currently it requires enabling the nest_if_no_args config option, which isn't the default option yet.