godotengine / godot-csharp-vscode

Debugger and utilities for working with Godot C# projects in VSCode
https://marketplace.visualstudio.com/items?itemName=neikeq.godot-csharp-vscode
MIT License
149 stars 27 forks source link

Code completion of the generic type parameter in GetNode #16

Open atadi96 opened 3 years ago

atadi96 commented 3 years ago

Hello,

I've had the pleasure of trying the extension, and enjoyed the code completion of the node name string in GetNode(...). However, typing out the generic type parameter for GetNode still feels tedious to me, so I thought that the code completion could be extended with that information. I think this would also benefit the majority of the users.

For example in the current case if you type as far as GetNode<AnimatedSprite>( then code completion will give you options like e.g. "MainCharacterSprite", "CollisionShape2D".

The code completion could be extended so that typing GetNode would yield the following completion options for the scene from the previous example: GetNode<AnimatedSprite>("MainCharacterSprite"), GetNode<CollisionShape2D>("CollisionShape2D").

Is it possible to provide this richer code completion from the extension?

atadi96 commented 3 years ago

I hoped that I could help implementing this functionality, I tracked down the code completion request to this line of code. https://github.com/godotengine/godot-csharp-vscode/blob/d6cb2f0c05f4bb17616c81d7934b5b6c77d00ebb/src/completion-provider.ts#L103 which as I see calls into a socket connection of localhost:port where port is loaded from projectDir/.mono/metadata/ide_messaging_meta.txt which is the connection for what the code calls "Godot Ide Server". I tried looking up "Godot Ide Server" in this repo and the godotengine repo but I haven't found any obvious traces of it anywhere. If someone would please guide me to the Godot Ide Server source, I'd see if I can contribute to this feature.

Thanks for reading the issue and any help in advance!

neikeq commented 3 years ago

This is hard with the way the extension implements code completion right now. We use regex to toggle suggestions and we have no semantic information, so what we can do is very limited.

I would like to make our Roslyn completion providers work as NuGet packages to use them in VSCode, but this is currently blocked by a few issues. First one I link in godotengine/godot-csharp-visualstudio#18. Second one is that OmniSharp's VSCode completion provider is only triggered by . and characters. We need it to be triggered by (, ", and , as well, otherwise it won't show up for node paths (unless you trigger suggestions manually via the shortcut).