Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
feat(cmp): reimplement comparators for completion entries (ayamir#746)
Browse files Browse the repository at this point in the history
* feat(cmp): update sort logic.

* fixup! feat(cmp): update sort logic

* fixup commit

---------

Co-authored-by: Jint-lzxy <[email protected]>
(cherry picked from commit a860c4b)
  • Loading branch information
ayamir authored and boomker committed May 19, 2023
1 parent 6731dc7 commit faab394
Showing 1 changed file with 12 additions and 13 deletions.
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

0 comments on commit faab394

Please sign in to comment.