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

bug(picker) LSP pickers fails to resume

Open carlos-algms opened this issue 9 months ago • 4 comments

Did you check docs and existing issues?

  • [x] I have read all the snacks.nvim docs
  • [x] I have updated the plugin to the latest version before submitting this issue
  • [x] I have searched the existing issues of snacks.nvim
  • [x] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.4

Operating system/version

MacOs

Describe the bug

When trying to resume an LSP picker, the error is shown:

No results found for lsp_references

Steps To Reproduce

  1. Go to a variable, or any symbol
  2. run :Snacks.picker.lsp_references()
  3. Select an item or close the picker
  4. Move the cursor to an empty line
  5. run: Snacks.picker.resume()
  6. The error is shown, and an empty picker is displayed

Expected Behavior

I would expect the picker to resume and show the same results, regardless of the cursor position.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

carlos-algms avatar Mar 15 '25 22:03 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 Apr 18 '25 02:04 github-actions[bot]

bad bot

carlos-algms avatar Apr 19 '25 13:04 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 May 20 '25 02:05 github-actions[bot]

not stale.

carlos-algms avatar May 20 '25 07:05 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 Jun 20 '25 02:06 github-actions[bot]

Bad bot! Not stale.

carlos-algms avatar Jun 20 '25 07:06 carlos-algms

This is a problem for me too. After moving the cursor, a resume does not always work.

Case:

  • Have cursor on a function name. Use lua Snakcs.picker.lsp_references() method to find references.
  • Cancel the picker, mopve the cursor away from the function name.
  • Use lua Snacks.picker.resume() to resume
  • There is now an empty LSP References
  • Move back to the function identifier
  • Again, use lua Snacks.picker.resume() to view the again populated LSP References list

Can it be that resume still uses the cursor for context?

KaspervdHeijden avatar Jul 17 '25 07:07 KaspervdHeijden

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 Aug 17 '25 02:08 github-actions[bot]

not stale.

carlos-algms avatar Aug 17 '25 11:08 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 18 '25 02:09 github-actions[bot]

Not stale.

carlos-algms avatar Sep 18 '25 07:09 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 Oct 19 '25 02:10 github-actions[bot]

not stale.

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

This has been fixed in commit c210439!

The Problem

LSP pickers failed to resume when the cursor moved away from the original symbol because they needed to re-query the LSP server, which returned different/empty results from the new cursor position.

The Solution

The new resume implementation now caches LSP picker results (resume.lua:21):

items = source:find("^lsp_") and picker.finder.items or nil

When resuming, the cached items are used instead of re-querying:

if state.items then
  state.opts.finder = function()
    return state.items
  end
end

Result

You can now:

  1. Run :lua Snacks.picker.lsp_references() on a symbol
  2. Select an item or close the picker
  3. Move the cursor anywhere (even an empty line)
  4. Run :lua Snacks.picker.resume() or :lua Snacks.picker.resume("lsp_references")
  5. ✅ The picker resumes with the original cached results

This works for all LSP pickers: lsp_references, lsp_definitions, lsp_implementations, lsp_symbols, etc.


🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

folke avatar Oct 22 '25 11:10 folke