snacks.nvim icon indicating copy to clipboard operation
snacks.nvim copied to clipboard

feature: add `resumable` picker option

Open wvffle opened this issue 9 months ago • 4 comments

Did you check the docs?

  • [X] I have read all the snacks.nvim docs

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

I'd like to migrate to snacks explorer. One of the things that is bothering me is that after opening and closing (I'm using auto_close), it overrides the last opened picker and Snacks.picker.resume() then opens the explorer.

Describe the solution you'd like

Add an option like resumable = true | false to picker options, so we can filter out pickers that we don't want to override the last opened picker.

Describe alternatives you've considered

none

Additional context

No response

wvffle avatar Mar 08 '25 10:03 wvffle

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 08 '25 02:04 github-actions[bot]

Bad bot.

wvffle avatar Apr 08 '25 07:04 wvffle

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 09 '25 02:05 github-actions[bot]

not stale, ty

barklan avatar May 09 '25 09:05 barklan

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 09 '25 02:06 github-actions[bot]

Very bad bot...

wvffle avatar Jun 09 '25 11:06 wvffle

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 31 '25 02:07 github-actions[bot]

Bad bot!

carlos-algms avatar Jul 31 '25 07:07 carlos-algms

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 01 '25 02:09 github-actions[bot]

Nope

carlos-algms avatar Sep 01 '25 06:09 carlos-algms

I'd like to keep the same picker.explorer() instance every time I call it, with the cursor staying in the same place even if I open and close it multiple times.

oscarmlage avatar Sep 03 '25 11:09 oscarmlage

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Oct 04 '25 02:10 github-actions[bot]

Not, stale, very much still wanted.

carlos-algms avatar Oct 04 '25 08:10 carlos-algms

+1

oscarmlage avatar Oct 04 '25 10:10 oscarmlage

This has been addressed in commit c210439!

Your Request

You wanted a resumable option to prevent certain pickers (like explorer with auto_close) from overriding the last opened picker when using Snacks.picker.resume().

The Solution

The new resume implementation uses a different approach that's more flexible:

1. Per-Source State Storage

Instead of one M.last variable, each picker source now maintains its own resume state:

M.state["files"] = { ... }
M.state["explorer"] = { ... }
M.state["lsp_references"] = { ... }

2. Flexible Resume API

You can now control what to resume at runtime:

-- Resume a specific picker (ignores explorer)
Snacks.picker.resume("files")

-- Resume anything except explorer
Snacks.picker.resume({ exclude = {"explorer"} })

-- Resume only from specific pickers
Snacks.picker.resume({ include = {"files", "grep"} })

-- Resume most recent (current default behavior)
Snacks.picker.resume()

Benefits Over a resumable Flag

  • ✅ No need to configure pickers upfront
  • ✅ Runtime control over what to resume
  • ✅ Can resume any previous picker, not just the last one
  • ✅ Explorer still saves state (useful if you explicitly want to resume it)
  • ✅ More powerful and flexible

Your Use Case

Simply use Snacks.picker.resume({ exclude = {"explorer"} }) or resume specific pickers by name to avoid the explorer override issue.


🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

folke avatar Oct 22 '25 11:10 folke