fix(copilot): confirm with replace for copilot only

This commit is contained in:
Folke Lemaitre
2023-03-05 17:06:13 +01:00
parent ae9c74d88e
commit 079d3967d0

View File

@ -35,7 +35,24 @@ return {
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local cmp = require("cmp")
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "copilot" } }))
local confirm = opts.mapping["<CR>"]
local confirm_copilot = cmp.mapping.confirm({
select = true,
behavior = cmp.ConfirmBehavior.Replace,
})
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<CR>"] = function(...)
local entry = cmp.get_selected_entry()
if entry and entry.source.name == "copilot" then
return confirm_copilot(...)
end
return confirm(...)
end,
})
end,
},
}