2

I am trying to figure out what the trace setting in the Language Server Protocol does. So according to the specification:

The initial trace setting. If omitted trace is disabled ('off').

But that doesn't tell me much. It is embedded within the InitializeParams interface:

interface InitializeParams {
    /**
     * The process Id of the parent process that started
     * the server. Is null if the process has not been started by another process.
     * If the parent process is not alive then the server should exit (see exit notification) its process.
     */
    processId: number | null;

    /**
     * The rootPath of the workspace. Is null
     * if no folder is open.
     *
     * @deprecated in favour of rootUri.
     */
    rootPath?: string | null;

    /**
     * The rootUri of the workspace. Is null if no
     * folder is open. If both `rootPath` and `rootUri` are set
     * `rootUri` wins.
     */
    rootUri: DocumentUri | null;

    /**
     * User provided initialization options.
     */
    initializationOptions?: any;

    /**
     * The capabilities provided by the client (editor or tool)
     */
    capabilities: ClientCapabilities;

    /**
     * The initial trace setting. If omitted trace is disabled ('off').
     */
    trace?: 'off' | 'messages' | 'verbose';

    /**
     * The workspace folders configured in the client when the server starts.
     * This property is only available if the client supports workspace folders.
     * It can be `null` if the client supports workspace folders but none are
     * configured.
     *
     * Since 3.6.0
     */
    workspaceFolders?: WorkspaceFolder[] | null;
}

I tried it out locally with a test language server, but whatever value I put into (off, messages, verbose), nothing really changes.

What does it actually do?

Socrates
  • 8,724
  • 25
  • 66
  • 113

1 Answers1

1

I've been experimenting with Microsoft's examples ( https://github.com/Microsoft/vscode-extension-samples). In their lsp-sample you can change the value of trace via the settings ui: settings UI and the result is that it prints out the raw JSON-RPC messages: traced messages I haven't gone into this in much detail, but I assume that setting 'trace: verbose' on the client side sets the value in the InitializeParams to pass over to the server, so it can add its own trace lines. Not a definitive answer but hopefully you can see where trace output is supposed to appear.

Peter Hull
  • 6,683
  • 4
  • 39
  • 48