Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use cache for outdated rocks and trigger on more events #5

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

mrcjkb
Copy link
Member

@mrcjkb mrcjkb commented Aug 5, 2024

No description provided.

Copy link

github-actions bot commented Aug 5, 2024

Review Checklist

Does this PR follow the Contribution Guidelines? Following is a partial checklist:

Proper conventional commit scoping:

  • For example, fix(context): some bugfix

  • Pull request title has the appropriate conventional commit prefix.

If applicable:

  • Tested
    • Tests have been added.
    • Tested manually (Steps to reproduce in PR description).
  • Updated documentation.
  • Updated CHANGELOG.md

@mrcjkb mrcjkb requested a review from vhyrro August 5, 2024 22:37
@mrcjkb mrcjkb marked this pull request as draft August 5, 2024 22:42
@mrcjkb mrcjkb marked this pull request as ready for review August 5, 2024 22:43
Base automatically changed from fix-selector to main August 6, 2024 16:27
Comment on lines 3 to 13
local cache_populated = false

require("rocks-edit.api").register(function(toml, diagnostic)
nio.run(function()
local updates = require("rocks.state").outdated_rocks()
local updates = require("rocks.api").try_get_cached_outdated_rocks()
--- HACK: internal API! Rocks.nvim should provide an option to fall back to a
--- luarocks query if the cache is not populated.
if not cache_populated and #updates == 0 then
updates = require("rocks.state").outdated_rocks()
cache_populated = true
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hacky and should be replaced with a rocks.nvim API (see commend).
Also, we need a user event that triggers a refresh when the cache has been updated.

@mrcjkb
Copy link
Member Author

mrcjkb commented Sep 16, 2024

I've ended up adding a bit more to this than initially planned:

@mrcjkb
Copy link
Member Author

mrcjkb commented Sep 26, 2024

@vhyrro this one is ready :)

@vhyrro vhyrro merged commit 866b876 into main Sep 27, 2024
5 checks passed
@mrcjkb mrcjkb deleted the use-cache branch September 27, 2024 11:13
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.

[bug] diagnostic state can be overwritten by older diagnostics
2 participants