From 23ba877bb07f17a44af60e341be9f246ece5c133 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 6 Mar 2023 07:37:30 +0100 Subject: [PATCH] feat(copilot): better sorting for cmp sources when using copilot --- lua/lazyvim/plugins/extras/coding/copilot.lua | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 213e4d79..1c024a10 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -36,7 +36,7 @@ return { opts = function(_, opts) local cmp = require("cmp") - opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "copilot" } })) + table.insert(opts.sources, 1, { name = "copilot", group_index = 2 }) local confirm = opts.mapping[""] local confirm_copilot = cmp.mapping.confirm({ @@ -53,6 +53,24 @@ return { return confirm(...) end, }) + opts.sorting = { + priority_weight = 2, + comparators = { + require("copilot_cmp.comparators").prioritize, + + -- Below is the default comparitor list and order for nvim-cmp + cmp.config.compare.offset, + -- cmp.config.compare.scopes, --this is commented in nvim-cmp too + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + } end, }, }