Skip to content
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

feat(cmp): reimplement comparators for completion entries #746

Merged
merged 3 commits into from
May 16, 2023
Merged
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
25 changes: 12 additions & 13 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ return function()
}
end

local cmp_window = require("cmp.utils.window")

cmp_window.info_ = cmp_window.info
cmp_window.info = function(self)
local info = self:info_()
info.scrollable = false
return info
end

local compare = require("cmp.config.compare")
compare.lsp_scores = function(entry1, entry2)
local diff
Expand Down Expand Up @@ -71,13 +62,14 @@ return function()
end

local cmp = require("cmp")

cmp.setup({
preselect = cmp.PreselectMode.Item,
window = {
completion = {
border = border("Normal"),
max_width = 80,
max_height = 20,
scrollbar = false,
},
documentation = {
border = border("CmpDocBorder"),
Expand All @@ -89,12 +81,16 @@ return function()
require("copilot_cmp.comparators").prioritize,
require("copilot_cmp.comparators").score,
-- require("cmp_tabnine.compare"),
compare.offset,
compare.offset, -- Items closer to cursor will have lower priority
compare.exact,
-- compare.scopes,
compare.lsp_scores,
compare.sort_text,
compare.score,
compare.recently_used,
-- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset`
require("cmp-under-comparator").under,
compare.kind,
compare.sort_text,
compare.length,
compare.order,
},
Expand All @@ -110,6 +106,9 @@ return function()
return kind
end,
},
matching = {
disallow_partial_fuzzy_matching = false,
},
-- You can set mappings if you want
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Replace }),
Expand Down Expand Up @@ -144,7 +143,7 @@ return function()
},
-- You should specify your *installed* sources.
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lsp", max_item_count = 350 },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
Expand Down