fidget.nvim icon indicating copy to clipboard operation
fidget.nvim copied to clipboard

feat: Show fidget when we request any action to the LSP server

Open lucax88x opened this issue 3 years ago • 8 comments
trafficstars

Instead of just registering to the progress handler, would be possible to show for every / some actions that we send to the LSP server?

For example:

  • if I request to rename a class in typescript it can take 500ms, show fidget for this time
  • if I request some imports, can take up to 2s and sometimes even timeouts, show fidget for this time

I have no idea if LSP or neovim-lsp provide such handlers, so I'm just asking for the feasibility, I would even implement this if I have some directions.

lucax88x avatar Feb 06 '22 20:02 lucax88x

typically that's the task of the LSP server to report progress, that what's the event for. Best bet is probably creating a PR to the LSP servers repo that implements it

The only way I can imagine this working would be to override the LSP handlers for each command, and generating the progress while calling the original server.

syphar avatar Feb 07 '22 07:02 syphar

I'll try to document myself if the progress handler can be used for reporting "wait" operations, but I don't think so at first glance.

Unfortunately, due to https://github.com/neovim/neovim/issues/15848 I guess we cannot use handlers for this.

So, I guess the only way to do this properly is to create a custom function when we requests code actions and call the fidget.

Sad. I'll try to do something.

lucax88x avatar Feb 07 '22 08:02 lucax88x

Yeah, to my knowledge there's no way to tell which tasks an LSP server should notify clients about. There's also no way to distinguish between which tasks were caused by an explicit user request and which were caused by the editor (especially if, e.g., the editor is configured to autoformat on save).

One workaround that could work is to give users greater flexibility over what tasks are and aren't shown; someone requested a similar feature on Reddit. So while I won't be able to figure out what progress to display a priori, users will be able to specify, for each language server, which tasks should be shown. Then you could only show tasks whose title corresponds to tasks you're interested, e.g., formatting or importing.

j-hui avatar Feb 08 '22 05:02 j-hui

Interesting, how you would do that? I mean on the LSP side, would you listen with handlers? I'm asking because for example, the one I'm interested and it's probably the slowest (codeAction) does not have handlers anymore.

I could give some help in the implementation, in case.

lucax88x avatar Feb 08 '22 07:02 lucax88x

The best (clean) way is still to create a PR to the actual language server to just report the progress with the LSP APIs.

syphar avatar Feb 08 '22 07:02 syphar

Unfortunately I have to agree, any other implementation, even if cool, would be just a workaround.

lucax88x avatar Feb 08 '22 07:02 lucax88x

Interesting, how you would do that? I mean on the LSP side, would you listen with handlers?

The same way I do now; if the LSP server isn't sending progress notifications then there's nothing I can really do.

(What I was proposing is essentially a filter on existing notifications)

j-hui avatar Feb 08 '22 14:02 j-hui

FYI: #55 allows you to specify a custom task formatter which you can use to filter out specific notifications (but I know that's not exactly what @lucax88x is asking for here).

j-hui avatar Mar 20 '22 02:03 j-hui

Closing; please re-open if we can clarify what the feature should be/how it would work.

j-hui avatar Nov 10 '23 04:11 j-hui