cbochs / grapple.nvim

Neovim plugin for tagging important files
MIT License
545 stars 20 forks source link

feature: clean tags based on branches when branches get removed #154

Closed carlesba closed 5 months ago

carlesba commented 6 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I tend to work with git_branch scope. I create new branches and clean them later however, I'm afraid of Grapple accumulating tags for branches that will not longer exist anymore.

Describe the solution you'd like

I'd like Grapple to clean those tags for branches that are not longer available if possible. Otherwise give me an option to clean those scopes that are not longer useful.

Describe alternatives you've considered

If I knew where grapple stores this info, I would go and clean those manually.

Additional context

Basically, the flow I'm using is:

I'm missing a quick way to transfer files between scopes and cleaning old unused scopes.

carlesba commented 6 months ago

additional idea, probably easier to implement.

Keep track on the last time a scope has been accessed and add a new panel where we can see this and remove scopes manually.

cbochs commented 5 months ago

Hi @carlesba, I think the feature you are looking for is :Grapple prune[^1].

-- Prune using the default time limit
require("grapple").prune()

-- Prune longer than 30 days
require("grapple").prune({ limit = "30d" })

The default limit can be configured in the settings[^2], like:

require("grapple").setup({
    ---Time limit used for pruning unused scope (IDs). If a scope's save file
    ---modified time exceeds this limit, then it will be deleted when a prune
    ---requested. Can be an integer (in seconds) or a string time limit
    ---(e.g. "30d" or "2h" or "15m")
    ---@type integer | string
    prune = "30d",
})

Also, you can manually delete any scope ID with :Grapple reset[^3], or after "showing all" in the Loaded Scopes window with g. (to show all), and X with your cursor over the scope you want to delete[^4].

[^1]: Grapple API: Grapple.prune or :h grapple.nvim-usage [^2]: Settings or :h grapple.nvim-settings [^3]: Grapple API: Grapple.reset or :h grapple.nvim-usage [^4]: Loaded Scopes Window or :h grapple.nvim-grapple-windows

cbochs commented 5 months ago

I'm missing a quick way to transfer files between scopes and cleaning old unused scopes.

There's not a perfect solution for this right now. However, one solution would be to copy all the tags in one scope with yip, go to the other scope and paste them with p.

cbochs commented 5 months ago

Last note!

If I knew where grapple stores this info, I would go and clean those manually.

This is documented in the Settings (:h grapple.nvim-settings) as settings.save_path. I wouldn't recommend deleting them manually, but I thought I would just point this out in case you're curious.

carlesba commented 5 months ago

awesome! Thank you very much for your details response! Loved this.

carlesba commented 5 months ago

Additionally, now that I discovered prune. Could we add scope to the options? So we can prune only by latest modification in a specific scope.

Thanks again.

cbochs commented 5 months ago

Happy to help!

Additionally, now that I discovered prune. Could we add scope to the options? So we can prune only by latest modification in a specific scope.

Right now, it is not possible to infer the scope from a given scope ID. Which means given a list of scope IDs it's not possible to determine which ones came from a given scope.

It would be possible to embed this information in the file, but then every file would have to be loaded/parsed in order to run a prune.

I'll keep this suggestion in mind, but for now I'll say it's not planned.