From 9511cc0fd3307d54c77e6d9d55a0467ccd43e29c Mon Sep 17 00:00:00 2001 From: ayamir Date: Tue, 16 May 2023 20:27:25 +0800 Subject: [PATCH 1/3] feat(cmp): update sort logic. --- lua/modules/configs/completion/cmp.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 07c39c0f4..bd1e6b4e5 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -91,10 +91,13 @@ return function() -- require("cmp_tabnine.compare"), compare.offset, compare.exact, + -- compare.scopes, compare.lsp_scores, + compare.recently_used, + compare.locality, require("cmp-under-comparator").under, compare.kind, - compare.sort_text, + -- compare.sort_text, compare.length, compare.order, }, From 263c72dfef03d949c5713716916300992aa4952e Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 16 May 2023 21:21:32 +0800 Subject: [PATCH 2/3] fixup! feat(cmp): update sort logic --- lua/modules/configs/completion/cmp.lua | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index bd1e6b4e5..07b58a714 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -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 @@ -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"), @@ -93,11 +85,12 @@ return function() compare.exact, -- compare.scopes, compare.lsp_scores, + compare.sort_text, + compare.score, compare.recently_used, - compare.locality, + -- compare.locality, -- This conflicts with `offset` require("cmp-under-comparator").under, compare.kind, - -- compare.sort_text, compare.length, compare.order, }, @@ -113,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({ [""] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Replace }), @@ -147,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" }, From 211e0122a26268d583ef4db6e3411a612ae5a4ac Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 16 May 2023 21:57:15 +0800 Subject: [PATCH 3/3] fixup commit --- lua/modules/configs/completion/cmp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 07b58a714..4331b363b 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -81,14 +81,14 @@ 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, -- This conflicts with `offset` + -- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset` require("cmp-under-comparator").under, compare.kind, compare.length,