GDQuest / zed-gdscript

Zed support for the GDScript language
MIT License
26 stars 10 forks source link

Automatically restart the language server or try to reconnect when needed #27

Open NathanLovato opened 1 month ago

NathanLovato commented 1 month ago

Currently, when the language server will not connect, because Godot is not launched, or because Godot was closed, there is no information to the user, and the extension will not try to reconnect automatically.

We should see if there are hooks in zed that would allow us to try to reconnect automatically.

A separate improvement would be to inform the user when the server disconnected, although I don't know if Zed currently has a provision for this.

moomerman commented 3 weeks ago

I attempted implementing this by writing a go binary that replaces netcat and has support for reconnecting.

It all seemed to work fine, detecting that Godot had restarted for example and reconnecting except on reconnect it seems that Zed was dropping the connection which caused it to keep restarting all the time.

It seems to work find in terms of reconnecting now, but it looks like the context for the LSP needs to be sent again after reconnecting.

Maybe this won't be possible until Zed extensions support reconnecting directly.

NathanLovato commented 3 weeks ago

Thanks for looking into this! I looked at the API provided by Zed only briefly. To me, this is something that needs to be handled from the code editor: ideally, we would offer to spawn a Godot process directly from Zed if needed, and detect and warn the user when the server disconnects (e.g. because the Godot editor was restarted or closed), all from Zed.

I don't know yet if this is possible.