otavioschwanck / arrow.nvim

Bookmark your files, separated by project, and quickly navigate through them.
Other
482 stars 23 forks source link

[Bug] persist buffer-local bookmarks on lazy load #55

Closed bassamsdata closed 5 months ago

bassamsdata commented 5 months ago

Hello, thanks for the plugin!

I'm wondering if there's a way to persist buffer-local bookmarks across Neovim instances. I'd like to implement this but not sure where to begin. Any guidance, @xzbdmw, would be greatly appreciated.

xzbdmw commented 5 months ago

It is now persisted by filename, what do you mean by neovim instances? like clear them when quit?

bassamsdata commented 5 months ago

Thanks for the prompt reply. Currently, when I quit Neovim and reopen the file, all local buffers bookmarks are gone. Is there a way to keep them like the the usual arrow global items/files.

xzbdmw commented 5 months ago

Maybe it is a bug, the location is a json file in ~/.cache/nvim/arrow/, can you check it? Here is related code.

bassamsdata commented 5 months ago

thanks.

yes, I believe there's a bug here. When I lazy load the plugin based on keys (meaning opening the filename before the plugin), all the local-buffer bookmarks disappear, no matter what I do.

But when I lazy load based on event = "BufReadPost" or lazy = false, for example, it works fine and the buffer-bookmarks persist.

I had this in my config:

{
  "otavioschwanck/arrow.nvim",
  cmd = "Arrow open",
  keys = {
    { "<tab>" },
    { "," },
  },
}

Another thing I noticed is that there isn't just one JSON file in the .cache/nvim/arrow directory. For every file I save bookmarks for, there's a corresponding file with no extension, but it's a JSON file. Below is a screenshot of the directory; I only have two files bookmarked.

Screenshot 2024-04-23 at 5 06 16 PM
xzbdmw commented 5 months ago

meaning opening the filename before the plugin

That’s the problem. We don’t load files while lazy loading, so the initial state will be empty table, then after you open menu, we sync that empty state to disk that overwrites the original one.