refactor: use actions

This commit is contained in:
Folke Lemaitre 2024-11-11 08:57:18 +01:00
parent 3f404079dc
commit f40a2a1faa
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
7 changed files with 100 additions and 64 deletions

View file

@ -11,7 +11,7 @@ return {
enabled = not vim.g.ai_cmp,
auto_trigger = true,
keymap = {
accept = "<tab>",
accept = false, -- handled by nvim-cmp / blink.cmp
next = "<M-]>",
prev = "<M-[>",
},
@ -22,20 +22,19 @@ return {
help = true,
},
},
config = function(_, opts)
LazyVim.cmp.ai_accept = function()
},
-- add ai_accept action
{
"zbirenbaum/copilot.lua",
opts = function()
LazyVim.cmp.actions.ai_accept = function()
if require("copilot.suggestion").is_visible() then
LazyVim.create_undo()
require("copilot.suggestion").accept()
return ""
return true
end
end
-- tab is handled by nvim-cmp / blink.cmp
local key = opts.suggestion.keymap.accept
if key == "<tab>" then
opts.suggestion.keymap.accept = false
end
require("copilot").setup(opts)
end,
},