Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lua/cmp_dictionary/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down