Repository navigation
De-duplicate results in Snacks.picker.lsp_references #2590
|
Hi there 👋 I've basically have the same problem as described in this issue: #1807 When using And quite often there are duplicated results - each from different LSP. I wanted to somehow filter the results to remove duplicates. Tried this using custom filter function ( Example:
LSP-b results:
(filter function execution) Picker opens with results combined:
Is there any way to execute some other callback when picker opens with all of the items? I've also tried using
on_show = function(picker)
picker.finder.items = remove_similar_items_efficient(picker.finder.items)
picker.list.items = remove_similar_items_efficient(picker.list.items)
picker:refresh()
picker:update({ force = true })
end,Would appreciate any help, thanks! |
Replies: 1 comment 2 replies
|
Should be doable, not tested properly: ---@module 'snacsk'
---@class snacks.Picker
---@field seen table<string, boolean?>
return {
"folke/snacks.nvim",
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
picker = {
sources = {
lsp_references = {
finder = function(opts, ctx)
ctx.picker.seen = {}
return require("snacks.picker.source.lsp").references(opts, ctx)
end,
transform = function(item, ctx)
-- vim.print(item)
local seen = ctx.picker.seen
local id = vim.inspect({ item.text }) -- NOTE: Change
if seen[id] then
return false
end
seen[id] = true
return true
end,
},
},
},
},
} |
Should be doable, not tested properly: