Feature Request: Logging LSP Messages

When debugging issues for LSP extensions I find myself spending most of my time just trying to understand what messages are being sent between the Nova client and the LSP server. It would be helpful if Nova provided a way to log all messages being sent or received. Alternatively if Nova provided an API to access the messages it would allow the community to build better LSP debugging tools.

I think a couple of extension devs have mentioned how they do this, and they maybe linked to their repo, but I suppose I’ll paste a snippet for posterity. Generally, you use a shell command with tee to capture inputs and outputs to log files. Here’s (essentially) what I use in my start method to create serverOptions for the language client constructor:

let path = '/path/to/server/binary';
let serverOptions = {
  path: path,
};
if (nova.inDevMode()) {
  serverOptions = {
    path: '/bin/bash',
    args: [
      '-c',
      `tee "${nova.extension.path}/../logs/nova-client.log" | ${path} | tee "${nova.extension.path}/../logs/lang-server.log"`,
    ],
  };
}

Logs are captured (only during local development) to a folder at the same level as the folder for my extension bundle (so they don’t get published with the extension).

There’s certainly room for Nova to improve their extension dev tooling, but this approach is something you can start using right away to log server messages.

1 Like

If you use the debug option in the clientOptions, you’ll get a fair bit.

Many LSPs (all three I’ve experience with) have the ability to send log messages to the client as well, by using a command line to increase verbosity. Be aware that I’ve seen that behave poorly if your LSP is actually noisy.