Struggling with LSP extension - Socket transport type

Hi everyone !

I am currently working on an integration of Godot and GDscript into Nova. I previously worked on SublimeText, but the quality of Nova made me want to switch.

I have already developed the LanguageDefinition extension for GDScript (which I will release once I have signed the dylib) and am currently developing (and struggling with) the Language Server Protocol part.

The configuration seemed simple to me (just a connection to a local TCP port), but I’m having trouble getting it to work.

The LSP configuration on the Godot side just consists of entering a remote host address (127.0.0.1) and a remote port (6005).

On the Nova Extension side, as the official documentation (LanguageClient) indicates, I assigned the value “socket” to the ‘type’ argument of the ServerOptions and added “–socket=6005” to ‘args’. But this doesn’t seem to work, and the error returned in the extension console is not very informative :

Error: The operation couldn’t be completed. (Nova.LanguageClient.LanguageClientError error 0.)

For information, I also tried to enter the port information as follows, without success:
–socket 6005
–port=6005
–port 6005

Here are the parts of my code in question:

// Create the client
        var serverOptions = {
            args: ["--socket=6005"],
            path: "notUsed",
            type: "socket"
        };
        var clientOptions = {
            // The set of document syntaxes for which the server is valid
            syntaxes: ['gdscript'],
            debug: true
        };
        var client = new LanguageClient('godot', 'Godot Language Server', serverOptions, clientOptions);

        try {
            // Start the client
            client.start();

            // Add the client to the subscriptions to be cleaned up
            nova.subscriptions.add(client);
            this.languageClient = client;
        }
        catch (err) {
            // If the .start() method throws, it's likely because the path to the language server is invalid

            if (nova.inDevMode()) {
                console.error(err);
            }
        }

Can you help me answer these questions:

  • Do we agree that in my case I don’t need a server executable and the ‘path’ argument of the ServerOption is not useful to me ?
  • If this is indeed not a problem, do you know how to properly configure the TCP port to connect to Godot ?

Thank you very much in advance and have a good weekend !

Hello again everyone,

I’m posting this follow-up message to share with you my wanderings trying to get my LSP extension for Godot to work with a TCP/IP connection.

Unfortunately, nothing conclusive at the moment, I tried to add the localhost information (127.0.0.1) with the port information, without success.

After some research, I really wonder if this information should be transmitted via the “args” argument of serverOptions which seems to be used more in cases of stdio calling with the executable server.

But I really don’t see where to enter the port information, especially since the official documentation on the LanguageClient is really very strange when it mentions the socket connection part:

When the socket transport type is specified, the subprocess will receive a launch argument --socket whose value is a port on which the client will attempt to connect on the TCP/IP nameserver. The server is responsible for opening a communication channel to listen for connections on this port.

I don’t understand the “the subprocess will receive a launch argument --socket”.
How do I assign a value to it?

I feel like I’ve started to exhaust all the avenues that the documentation and experimentation allowed me to have… :pensive:

I think what it means is that when you use the socket transport type, Nova will automatically add the --socket argument with a port number that it chooses, you don’t specify it manually.

So assuming that you have a LanguageClient initialisation similar to the one in the default template:

var client = new LanguageClient('example-langserver', 'Example Language Server', serverOptions, clientOptions)

If your server options were:

var serverOptions {
    path: /usr/bin/gdscript-server
    type: "stdio"
}

Nova would launch the server like this:

/usr/bin/gdscript-server

But if you used a socket type:

var serverOptions {
    path: /usr/bin/gdscript-server
    type: "socket"
}

Nova would choose a port (call it <port>) and then start the server like this:

/usr/bin/gdscript-server --socket <port>

It would then send commands over that port.

I’ve never used the “socket” type before, so I don’t know for certain, but that’s how I’d interpret the documentation.

Edit: I sent this message after realising the last reply was 21 days ago…

1 Like

Thank you for you answer @JLindop :pray:

We reached a similar conclusion with a colleague.
For the moment, I use Sublime Text which manages the LSP in socket mode and which just requires entering the correct port in a config file and I went with a similar interpretation for Nova. But we think, as you say, it’s Nova who decides the communication port.

Unfortunately, we don’t have a “godot-server”, only the application and we don’t see how to communicate to Godot the listening port rather than the other way around…

I would love to use Nova as an IDE for GDScript game development, but unfortunately it’s starting to require too much effort for us to take the time to configure all that.

Again, thanks for the response though! :smiley:

I took a look at this too as I was also considering using Nova with Godot, but it doesn’t seem possible at this time to connect Nova to the Godot engine’s LSP. My understanding from the docs is that when using the "socket" type connection Nova will choose a port and attempt to run the language server executable at "path" and pass it the --socket <port> flag, with the understanding that the language server should then listen for connections on that port.

This won’t work with Godot since the Godot editor runs the LSP and the port is configured within the Godot editor’s settings, and in any case the editor may already be running and to work Nova should not attempt to start the language server, but would need to only attempt to connect at a port supplied to it.

So if we were able to supply LanguageClient with the address and port, this would work. Otherwise it seems it is not possible or at least would be far more effort than its worth.

// For example
var client = LangaugeClient(
    "...",
    "...",
    {
        "server": "127.0.0.1:6007" // Would need to supply this for Nova
    },
    { ... }
)