From 3961cfd88e41a70d494cd38fa93426a689bf47eb Mon Sep 17 00:00:00 2001 From: 0xaaaa Date: Fri, 24 Jul 2026 08:24:54 +0000 Subject: [PATCH] fix: remove duplicate word suggestions from multiple dictionaries --- lua/cmp_dictionary/source.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/cmp_dictionary/source.lua b/lua/cmp_dictionary/source.lua index 322cb55..b5ea4c3 100644 --- a/lua/cmp_dictionary/source.lua +++ b/lua/cmp_dictionary/source.lua @@ -88,6 +88,17 @@ function source:complete(request, callback) else items = self.dict:search(req) end + + -- Filter out duplicates that occur when a word appears in multiple dictionaries. + local seen = {} + items = vim.tbl_filter(function(item) + if seen[item.label] then + return false + end + seen[item.label] = true + return true + end, items) + if opts.max_number_items > 0 and #items > opts.max_number_items then items = vim.list_slice(items, 1, opts.max_number_items) end