Description
[Originally proposed here, but this is a more appropriate place.]
Background: Go's LSP server, gopls, replaces a number of analysis and testing tools that were command-line tools that reported textual output. An LSP server has many advantages: it has a hot in-memory cache, it can operate correctly on unsaved editor buffers, and it is of course tightly integrated into the editor. There remain a large variety of analysis tools we would like to build as features of gopls that need only the loosest of integration: at a minimum, the ability to stream text output to a terminal-like viewer, so that file:line:column line prefixes are marked up as source links that, when clicked, navigate the user's editor.
For example, Gopls today has a CodeLens command, go.test, that can be invoked via LSP executeCommand. It causes the server to execute the Go test identified by the selected source line and sends back the mixed stdout/stderr stream via the LSP progress notification mechanism. Unfortunately, the command is not very useful because of the variety of ways in which this output stream is handled by clients; many display only the most recent notification in some kind of current status bar.
It would enable new categories of tool integration with low effort if there were a way to indicate that the output of a command such as go.test should be handled differently: by streaming the output into a new, visible read-only textual buffer, much the same way VS Code's Output panel displays other streams such as the LSP server log or the LSP server's standard output.
Proposal: I propose that we add an option to executeCommandParams to indicate that the output of the progress stream for this command should be displayed in the client's canonical style of streaming output buffer. The option could be a string providing the name of the output window:
interface executeCommandParams {
stream?: string; // if nonempty, the command's progress notifications should be directed to an output window of this name.
}