Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP: Add --lsp-port as a command line argument #81844

Merged

Conversation

ryanabx
Copy link
Contributor

@ryanabx ryanabx commented Sep 18, 2023

Per discussion in godotengine/godot-vscode-plugin#488, and the suggestion by @Calinou in godotengine/godot-vscode-plugin#488 (comment).

Implements an --lsp-port command line argument for Godot. This argument overrides the user's editor setting for network/language_server/remote_port.

The use case for this argument would be for the godot-vscode-plugin to be able to specify the port used for the language server instance spun up by the plugin.

This would potentially solve a few long standing issues with the godot-vscode-plugin, including:

  1. Godot's 3.x LSP port and 4.x LSP port don't match, causing the plugin to have to tell users to explicitly specify the port they have selected in their editor settings. (See Default LSP server port of plugin doesn't match with default port of Godot 4  godot-vscode-plugin#473)
  2. Spinning up multiple workspaces in vscode would cause both to use the same language server.

If the change is accepted, it should be cherry picked to 3.x. I can help with that if need be.

Let me know what things I have to change. Since this is my first time working with main.cpp and further with #ifdef and #ifndef, please pay attention to my use of those and let me know if they are up to standard.

I also added the port to the language server editor print that says --- GDScript language server started ---, changing it to --- GDScript language server started on port "port"---.

If there are places I need to document this change at, let me know as well. :)

@ryanabx ryanabx requested review from a team as code owners September 18, 2023 04:20
@ryanabx ryanabx force-pushed the features/specify-lsp-port branch 2 times, most recently from 02bc169 to 6c252d2 Compare September 18, 2023 04:40
@DaelonSuzuka
Copy link

Just to add some context on the ramifications of this, I expect it be a significant quality-of-life improvement for everybody using VSCode and for many users of other external editors.

  • This will improve the new user experience considerably. A very commonly raised issue is users not understanding that the Godot editor needs to be running for many of the extension features to work.
  • This will allow us to sidestep the port number issue by launching our own LSP process.
  • This is will let us do something that I believe is impossible today: opening two Godot projects in two VSCode windows and getting the correct LSP results in both of them.
  • This will improve the overall stability of the editing experience, because crashes in the LSP won't kill the user's open editor.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Maybe it should simply be named --lsp-port? It's implicit for any command line option that it takes precedence over what's the current default.

main/main.cpp Outdated Show resolved Hide resolved
@anvilfolk
Copy link
Contributor

Do we think that instead of --lsp-port-override it might just be --lsp-port instead? It isn't so much an override as it's specifying a thing that otherwise has a default value, and gets rid of some extra bit of typing :)

@ryanabx ryanabx changed the title Add --lsp-port-override as a command line argument Add --lsp-port as a command line argument Sep 18, 2023
@ryanabx
Copy link
Contributor Author

ryanabx commented Sep 18, 2023

Makes sense to me. Maybe it should simply be named --lsp-port? It's implicit for any command line option that it takes precedence over what's the current default.

Do we think that instead of --lsp-port-override it might just be --lsp-port instead? It isn't so much an override as it's specifying a thing that otherwise has a default value, and gets rid of some extra bit of typing :)

Yep, I like that better. I've changed it in the latest commit!

main/main.cpp Outdated Show resolved Hide resolved
main/main.cpp Outdated Show resolved Hide resolved
@ryanabx
Copy link
Contributor Author

ryanabx commented Sep 18, 2023

Other than potentially gathering more reviews, the PR is ready to go!

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine!

@akien-mga akien-mga merged commit e207595 into godotengine:master Sep 19, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@ryanabx ryanabx deleted the features/specify-lsp-port branch September 19, 2023 19:37
@van800
Copy link
Contributor

van800 commented Jan 11, 2024

I have encountered a complication with this feature. It seems to depend on the order of arguments.
This would work:
/Applications/Godot_mono_4.3dev1.app/Contents/MacOS/Godot --lsp-port 6010 --path /Users/user/Godot43vdev1 --editor
And this would not:
/Applications/Godot_mono_4.3dev1.app/Contents/MacOS/Godot --path /Users/user/Godot43vdev1 --editor --lsp-port=6010

@akien-mga
Copy link
Member

@van800 The difference seems to be that you use --lsp-port=6010 (with =) in the second one. Godot doesn't support this format for passing argument values, it expects the value to be the next word.

@van800
Copy link
Contributor

van800 commented Jan 11, 2024

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants