Remove manual dup filter
This commit is contained in:
@@ -63,11 +63,10 @@ core.ghost_text = function(e)
|
|||||||
ctx.cursor.row - 1,
|
ctx.cursor.row - 1,
|
||||||
ctx.cursor.col - 1,
|
ctx.cursor.col - 1,
|
||||||
{
|
{
|
||||||
right_gravity = true,
|
|
||||||
virt_text = { { text, 'Comment' } },
|
virt_text = { { text, 'Comment' } },
|
||||||
virt_text_pos = 'overlay',
|
virt_text_pos = 'overlay',
|
||||||
virt_text_win_col = ctx.cursor.col - 1,
|
virt_text_win_col = ctx.cursor.col - 1,
|
||||||
hl_mode = 'blend',
|
hl_mode = 'combine',
|
||||||
priority = 0,
|
priority = 0,
|
||||||
ephemeral = true,
|
ephemeral = true,
|
||||||
}
|
}
|
||||||
@@ -81,6 +80,7 @@ core.sources = {}
|
|||||||
---@type cmp.Context
|
---@type cmp.Context
|
||||||
core.context = context.new()
|
core.context = context.new()
|
||||||
|
|
||||||
|
|
||||||
---Register source
|
---Register source
|
||||||
---@param s cmp.Source
|
---@param s cmp.Source
|
||||||
core.register_source = function(s)
|
core.register_source = function(s)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ local check = require('cmp.utils.check')
|
|||||||
---@field public on_select fun(e: cmp.Entry)
|
---@field public on_select fun(e: cmp.Entry)
|
||||||
---@field public items vim.CompletedItem[]
|
---@field public items vim.CompletedItem[]
|
||||||
---@field public entries cmp.Entry[]
|
---@field public entries cmp.Entry[]
|
||||||
---@field public entry_map table<number, cmp.Entry>
|
|
||||||
---@field public selected_entry cmp.Entry|nil
|
---@field public selected_entry cmp.Entry|nil
|
||||||
---@field public context cmp.Context
|
---@field public context cmp.Context
|
||||||
---@field public resolve_dedup fun(callback: function)
|
---@field public resolve_dedup fun(callback: function)
|
||||||
@@ -59,7 +58,6 @@ menu.reset = function(self)
|
|||||||
self.offset = nil
|
self.offset = nil
|
||||||
self.items = {}
|
self.items = {}
|
||||||
self.entries = {}
|
self.entries = {}
|
||||||
self.entry_map = {}
|
|
||||||
self.context = nil
|
self.context = nil
|
||||||
self.preselect = 0
|
self.preselect = 0
|
||||||
self:close()
|
self:close()
|
||||||
@@ -71,7 +69,6 @@ end
|
|||||||
---@return cmp.Menu
|
---@return cmp.Menu
|
||||||
menu.update = check.wrap(function(self, ctx, sources)
|
menu.update = check.wrap(function(self, ctx, sources)
|
||||||
local entries = {}
|
local entries = {}
|
||||||
local entry_map = {}
|
|
||||||
|
|
||||||
-- check the source triggered by character
|
-- check the source triggered by character
|
||||||
local has_triggered_by_symbol_source = false
|
local has_triggered_by_symbol_source = false
|
||||||
@@ -95,7 +92,6 @@ menu.update = check.wrap(function(self, ctx, sources)
|
|||||||
for _, e in ipairs(s:get_entries(ctx)) do
|
for _, e in ipairs(s:get_entries(ctx)) do
|
||||||
e.score = e.score + priority
|
e.score = e.score + priority
|
||||||
table.insert(entries, e)
|
table.insert(entries, e)
|
||||||
entry_map[e.id] = e
|
|
||||||
offset = math.min(offset, e:get_offset())
|
offset = math.min(offset, e:get_offset())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -114,25 +110,18 @@ menu.update = check.wrap(function(self, ctx, sources)
|
|||||||
|
|
||||||
-- create vim items.
|
-- create vim items.
|
||||||
local items = {}
|
local items = {}
|
||||||
local abbrs = {}
|
|
||||||
local preselect = 0
|
local preselect = 0
|
||||||
for _, e in ipairs(entries) do
|
for i, e in ipairs(entries) do
|
||||||
local item = e:get_vim_item(offset)
|
|
||||||
if not abbrs[item.abbr] or item.dup == 1 then
|
|
||||||
table.insert(items, item)
|
|
||||||
abbrs[item.abbr] = true
|
|
||||||
|
|
||||||
if preselect == 0 and e.completion_item.preselect and config.get().preselect ~= types.cmp.PreselectMode.None then
|
if preselect == 0 and e.completion_item.preselect and config.get().preselect ~= types.cmp.PreselectMode.None then
|
||||||
preselect = #items
|
preselect = i
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
table.insert(items, e:get_vim_item(offset))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- save recent pum state.
|
-- save recent pum state.
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
self.items = items
|
self.items = items
|
||||||
self.entries = entries
|
self.entries = entries
|
||||||
self.entry_map = entry_map
|
|
||||||
self.preselect = preselect
|
self.preselect = preselect
|
||||||
self.context = ctx
|
self.context = ctx
|
||||||
self:show()
|
self:show()
|
||||||
|
|||||||
Reference in New Issue
Block a user