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

feat: show pinner while runnig request

Open antosha417 opened this issue 2 years ago • 5 comments

Hey! I really enjoy using this plugin, use it almost every day. Some queries that I run takes long time to complete. And while they are running I don't get any feedback from neovim. Decided to add a little spinner on the line of the request so I can know that the request is running

Took an inspiration of this in https://github.com/hudclark/grpc-nvim . It is similar plugin but for grpc calls

antosha417 avatar Jun 11 '23 09:06 antosha417

I confess I am not a fan of the feature, I dont have a use of it and also the spinner looks like a generic thing you would want for several plugins. Something I've wanted for a while is to provide hooks for users to plug some stuff in. In this case we could fire an event when launching a request and when finishing it. This way you could subscribe to both events to start/stop the spinner. What do you think ?

teto avatar Jul 07 '23 08:07 teto

Hey @teto! I do think that hooks is an awesome idea!

They will allow super easy customisation and spinner definitely can be done with those. So you can close this pr and I'll wait for hooks to be implemented

antosha417 avatar Jul 10 '23 08:07 antosha417

to be clear, I dont have time to implement this but as @NTBBloodbath seems to agree with the idea, I think we could merge a PR implementing that.

Quickly how it could work:

  • fire a User RestNvimStartRequest <ID> event upon run_request ( :h User, the ID could be some hash of the request or an autoincrementing id)
  • fire a User RestNvimStopRequest .

If we want to support cancel events, we could do RestNvimRequest start/stop/cancel id instead to avoid using too many event names. I think such a callback could be useful to time requests too (though that may be less precise than the time reported by curl)

teto avatar Jul 10 '23 10:07 teto

I was going through the PR list and several PRs could use the previous mechanism. I've implemented a quick draft https://github.com/rest-nvim/rest.nvim/pull/214 that can serve as inspiration. @antosha417 would you be willing to test/amend/fork that PR so that you can achieve what you initially wanted with a callback based approach ? Feel free to open a new PR and I can review/merge it

teto avatar Jul 11 '23 14:07 teto

Note for myself: perhaps this can be implemented in future versions using fidget.nvim through luarocks.

NTBBloodbath avatar Mar 05 '24 22:03 NTBBloodbath

Closing this PR due to the v3 release. rest.nvim now supports spinner using fidget.nvim

boltlessengineer avatar Aug 22 '24 04:08 boltlessengineer

@boltlessengineer that is a great news! Thank you

antosha417 avatar Aug 22 '24 10:08 antosha417