Skip to content

Conversation

antosha417
Copy link

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

@teto
Copy link
Collaborator

teto commented Jul 7, 2023

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 ?

@antosha417
Copy link
Author

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

@teto
Copy link
Collaborator

teto commented Jul 10, 2023

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 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
Copy link
Collaborator

teto commented Jul 11, 2023

I was going through the PR list and several PRs could use the previous mechanism. I've implemented a quick draft
#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

@NTBBloodbath
Copy link
Member

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

@boltlessengineer
Copy link
Contributor

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

@antosha417
Copy link
Author

@boltlessengineer that is a great news! Thank you

@antosha417 antosha417 deleted the show-spinner-while-runnig-request branch August 22, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants