-
-
Notifications
You must be signed in to change notification settings - Fork 854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSP references results deduplication #3328
Comments
Is angularls and ts_ls intended to be used at the same time on the same buffers? Trying to think what the best way of handling this is. Curious how |
If you do |
Hey @jamestrew. Yeah, I get two: That's the behavior I was getting before this latest update with telescope as well. The
So the short version is, |
Looks like neovim is merging references (and generally handling multiple clients for various lsp handlers similar to how telescope has started doing this) now. It doesn't look like there's any de-duping logic there. I'm curious if they will add it and if so what the implementation will be. |
Looks like this issue is still present on the latest neovim build, even after neovim/neovim#30722. Here's a workaround: local function filterDuplicates(array)
local uniqueArray = {}
for _, tableA in ipairs(array) do
local isDuplicate = false
for _, tableB in ipairs(uniqueArray) do
if vim.deep_equal(tableA, tableB) then
isDuplicate = true
break
end
end
if not isDuplicate then
table.insert(uniqueArray, tableA)
end
end
return uniqueArray
end
local function on_list(options)
options.items = filterDuplicates(options.items)
vim.fn.setqflist({}, ' ', options)
vim.cmd('botright copen')
end
-- Usage
vim.lsp.buf.references(nil, { on_list = on_list }) Bonus: a related issue with this scenario is |
Is your feature request related to a problem? Please describe.
After #3211, now I'm seeing duplicate results in my lsp references results:
It looks like this was a known issue when the feature was added. From the PR description:
Unfortunately in my usecase I do need a way to dedup the list :). I'm using both
angularls
andts_ls
, and they often return the same locations. This is normally just an annoyance, but in my workflow I tend to send telescope results to the qf list andcdo
some bulk updates. I now worry I'm gonna start messing things by updating the same location(s) twice.Describe the solution you'd like
It'd be useful to have an option to remove duplicates from the results (probably enabled by default, even). Or just remove them. I doubt anyone needs duplicates in their list but, who knows :).
Describe alternatives you've considered
This my not-so-great quick solution for now. I'm sure there is a better way to generate a unique key for a location than just stringifying it ;)
The text was updated successfully, but these errors were encountered: