Closed tonyalaribe closed 2 years ago
The documentation simply says that you can return a result and an error, the latter being "code and message", which is a little too thin. I interpret this to imply that different implementations might handle the "error" differently...
But if you had to implement such a functionality, how would you do it?
The ability to perform an action a line of code and edit the current document to include the result of the action into the page.
On Sun, Jun 26, 2022, 00:06 Tal Liron @.***> wrote:
The documentation https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#workspace_executeCommand simply says that you can return a result and an error, the latter being "code and message", which is a little too thin. I interpret this to imply that different implementations might handle the "error" differently...
— Reply to this email directly, view it on GitHub https://github.com/tliron/glsp/issues/11#issuecomment-1166369183, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSCVASKLDSH6T5IW2I4GEDVQ57H5ANCNFSM5Z23QXGA . You are receiving this because you authored the thread.Message ID: @.***>
I have never done so myself. Perhaps other users can chime in with advice?
I implemented diagnostics with glsp, you can take a look here: https://github.com/mickael-menu/zk/blob/68e6b70eaefdf8344065fcec39d5419dc80d6a02/internal/adapter/lsp/server.go#L556
I refresh them when receiving TextDocumentDidOpen
and TextDocumentDidChange
, with a custom throttle of one second with TextDocumentDidChange
, to wait for the user to be idle before refreshing the diagnostics (this is the delay bool
parameter with NeedsRefreshDiagnostics
).
It looks like this in Neovim:
I didn't use the code
parameter but the message
and severity
ones.
Hi, first of all, thanks for the tremendous amount of work you put into this library.
I'm implementing an LSP for a doctest library which I wrote (https://github.com/apitoolkit/doctests), and the way it should work is such that a user can add golang expressions into their comments, and they can execute those expressions like an inline repl. But the documentation of LSPs has been tough so far. Including on the official lsp spec website. So maybe you can help me better.
I've been able to implement this functionality in 2 ways already, but each way doesn't completely give me what I would like or expect.
I implement the
TextDocumentCodeLens
which triggers code commands. But the problem is that in theWorkspaceExecuteCommand
handler, the return type is just an interface, so I'm completely clueless about how to update the document i'm in like with code actions. So I end up editing the file on disk in the execute command function, but then the user has to reload the file from disk to see the changes i made, or risk making more changes and overwritting the files on disk.Is there a type/data that i can return from executeCommand, to make it edit the current text document instead of by passing the editor to directly edit the file on disk?