Replies: 1 comment 9 replies
-
Yes exactly, though "buffer" wouldn't be exactly the word you'd want to use. Something dumber, more microsoftish or vscodish. In fact, you shouldn't even mention Emacs if you want to increase your chances, which I don't think are very high to begin with (I hope I'm wrong!)
No, let's use generic functions. Can you show a transcript that very clearly (to save me time) of a LSP/JSONRPC session (real of fictional -- preferably real) that 1. shows an example of such command that wants to "output" to a buffer and 2. another command that doesn't want to output to a buffer. The best shape for the generic function can be decided then. Or maybe |
Beta Was this translation helpful? Give feedback.
-
Background: Go's LSP server, gopls, replaces a number of tools that were formerly command-line tools such as gorename. 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. Rename has special support in the LSP. But there are 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, as in
compilation-mode
.For example, Gopls today has a command, gopls.run_test, that can be invoked via LSP executeCommand. It runs
go test
on a particular test identified by source line, and sends back the mixed stdout/stderr stream via the LSP progress notification mechanism. Unfortunately, the command is not very useful to eglot users, neither out of the box nor after some elisp hacking, because of the way that eglot currently handles progress messages: it updates the echo area (or optionally the*Messages*
buffer) after each notification. To be clear, this is not a criticism of eglot: this is a perfectly reasonable approach. But I think it would enable new categories of tool integration if there were a way to indicate that the output of certain commands should be handled differently: by streaming the output into a new, visible read-only buffer in compilation-mode, much the same way as thecompile
command streams the output of a subprocess. Initially I imagine that we would have to tell eglot which LSP commands to handle this way, but ideally I would like to make this a core feature of LSP, for example by adding a boolean to executeCommandParams that indicates that the output should be displayed in a buffer. Other editors all have their own UI elements for streaming buffers; for example, VS Code has the Output panel with a selector that chooses among various streams.Proposal: I propose that
eglot-execute
be changed so that certain commands are executed with a different progress notification handler that directs their output to acompilation-mode
buffer. The set of commands would initially be configured by a customizable variable (i.e. client-side), but perhaps eventually it would be inferred from future metadata in the Command or CodeAction action argument (i.e. under the control of the server).Beta Was this translation helpful? Give feedback.
All reactions