godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.52k stars 149 forks source link

Add ability to restart language server from VS Code #504

Closed dawsonc623 closed 9 months ago

dawsonc623 commented 10 months ago

Godot version

4.1.1.stable

VS Code version

1.83.0

Godot Tools VS Code extension version

1.3.1

System information

Windows 11

Problem statement

There are times where it seems like the language server in Godot gets irrecoverably confused, and currently it seems the only recourse is to restart Godot entirely.

Proposed solution

Instead of having to restart the editor entirely, being able to trigger a restart of the language server via command would be more convenient. I realize this may come with a need to update the language server if it does not already implement this capability, so if that is necessary I can open an issue on the Godot repository to do that.

DaelonSuzuka commented 10 months ago

This was just implemented in #488 when using the new "Headless LSP" feature. When in headless mode, the extension will start its own LSP instance in a child process, and thus it is possible to restart it.

dawsonc623 commented 10 months ago

Oh, fancy that. Should we just close this issue then since the capability is already in the code (albeit given that just merged I expect it might be a bit before we see it released)?

Also, in looking at the discussion, a question I had (mostly driven by my lack of knowledge on how Godot works) around if running the language server in headless mode and running the editor on the same project would pose any issues? It seems like the implementation was done with this use case in mind (based on my scanning of the discussion - I could be mistaken), but I am just double-checking for my own understanding's sake.

DaelonSuzuka commented 10 months ago

... running the language server in headless mode and running the editor on the same project would pose any issues?

There's no inherent reason it should be an issue. Godot's file watcher isn't perfect, so it's possible that we'll see an uptick of things like failing to detect external changes to a file, but we've been using this system for a couple weeks now and haven't noticed anything.

Luke9389 commented 2 months ago

For anyone wondering how to do this, go to the Extension Settings in VS Code, and tick the box for Godot Tools > LSP Headless.

To restart the LSP, click the little "Connected" button in the bottom menu bar, and a little window will pop up with a "Restart LSP" button.

Screenshot 2024-06-08 at 11 49 11 AM