Skip to content

Commit

Permalink
feat(copilot): better sorting for cmp sources when using copilot
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 6, 2023
1 parent 8f3834b commit 23ba877
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lua/lazyvim/plugins/extras/coding/copilot.lua
Expand Up @@ -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["<CR>"]
local confirm_copilot = cmp.mapping.confirm({
Expand All @@ -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,
},
}

0 comments on commit 23ba877

Please sign in to comment.