Skip to content

Commit

Permalink
feat(cmp): deduplicate results from nvim-lsp (#1321)
Browse files Browse the repository at this point in the history
Signed-off-by: Jint-lzxy <[email protected]>
  • Loading branch information
Jint-lzxy authored Jul 9, 2024
1 parent ba1ab45 commit f83d276
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ return function()
vim_item.kind =
string.format(" %s %s", lspkind_icons[vim_item.kind] or icons.cmp.undefined, vim_item.kind or "")

-- set up labels for completion entries
vim_item.menu = setmetatable({
cmp_tabnine = "[TN]",
copilot = "[CPLT]",
Expand All @@ -109,12 +110,18 @@ return function()
end,
})[entry.source.name]

-- cut down long results
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, 80)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. "..."
end

-- deduplicate results from nvim_lsp
if entry.source.name == "nvim_lsp" then
vim_item.dup = 0
end

return vim_item
end,
},
Expand Down

0 comments on commit f83d276

Please sign in to comment.