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

Cache never invalidates when changing config or updating the plugin #253

Closed
oxalica opened this issue Nov 25, 2022 · 4 comments · Fixed by #254 or #257
Closed

Cache never invalidates when changing config or updating the plugin #253

oxalica opened this issue Nov 25, 2022 · 4 comments · Fixed by #254 or #257
Labels
bug Something isn't working

Comments

@oxalica
Copy link
Contributor

oxalica commented Nov 25, 2022

Description

Currently we relies on mtime, which never work with content-address-like system like Nix. It resets mtime of all sources and programs and relies purely on hashes to be pure and deterministic.

local cur_stat = (user_stat and user_stat.mtime.sec or 0) + (nf_git_stat and nf_git_stat.mtime.sec or 0)
if not user_stat or last_stat ~= tostring(cur_stat) then

We should better ONLY use hash of config, plugin version, and nvim version to determine cache validity. Note that this is still kind of fragile, since the Lua version, user patches for the plugin or nvim, and a lot of other things cannot be taking into account.

Personally, I'd rather to have an option to disable the fragile cache. It's already fast to setup without any "compiled" cache.

Behavior

Expected behavior

  1. Have ability to disable the cache.
  2. Use ONLY hash to track cache validity rather than mtime.

Additional info / context

I'm on NixOS and using Nix to manage all plugins.

NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld
@oxalica oxalica added the bug Something isn't working label Nov 25, 2022
@EdenEast
Copy link
Owner

I had an idea to fix this but have not got around to it. Thinking of going the workflow route.

@oxalica
Copy link
Contributor Author

oxalica commented Nov 26, 2022

#254 cannot fully resolve the environment or configuration change issue (vimrc is also in nix store).

I'd still ask for an option to fully disable the cache. Currently I have to

vim.fn.delete(vim.fn.stdpath("cache") .. "/nightfox/stat")
require("nightfox").setup {}

@EdenEast
Copy link
Owner

I created a PR that hashes the file name as well as the mine time. This will handle files in the /nix/store. Let me know if this PR resolves you issue with the nix store.

@rewhile
Copy link
Collaborator

rewhile commented Nov 27, 2022

@EdenEast Can you review catppuccin/nvim#352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants