refactor(cmp): move comparator config to cmp spec
This commit is contained in:
@ -44,6 +44,7 @@ return {
|
|||||||
opts = function()
|
opts = function()
|
||||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
local defaults = require("cmp.config.default")()
|
||||||
return {
|
return {
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = "menu,menuone,noinsert",
|
completeopt = "menu,menuone,noinsert",
|
||||||
@ -86,6 +87,7 @@ return {
|
|||||||
hl_group = "CmpGhostText",
|
hl_group = "CmpGhostText",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
sorting = defaults.sorting,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
@ -70,28 +70,9 @@ return {
|
|||||||
},
|
},
|
||||||
---@param opts cmp.ConfigSchema
|
---@param opts cmp.ConfigSchema
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
local cmp = require("cmp")
|
|
||||||
|
|
||||||
table.insert(opts.sources, 1, { name = "copilot", group_index = 2 })
|
table.insert(opts.sources, 1, { name = "copilot", group_index = 2 })
|
||||||
|
opts.sorting = opts.sorting or require("cmp.config.default")().sorting
|
||||||
opts.sorting = {
|
table.insert(opts.sorting.comparators, 1, require("copilot_cmp.comparators").prioritize)
|
||||||
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,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user