refactor: remove copilot

This commit is contained in:
Dinesh Salunke 2025-01-03 20:07:55 +05:30
parent 0758db6327
commit e087408b1f
2 changed files with 1 additions and 61 deletions

View File

@ -1,57 +0,0 @@
-- Copilot.
return {
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
opts = {
-- I don't find the panel useful.
panel = { enabled = false },
suggestion = {
auto_trigger = true,
-- Use alt to interact with Copilot.
keymap = {
-- Disable the built-in mapping, we'll configure it in nvim-cmp.
accept = false,
accept_word = "<M-w>",
accept_line = "<M-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "/",
},
},
filetypes = { markdown = true, lua = true, python = true, typescript = true, javascript = true },
},
config = function(_, opts)
local cmp = require("cmp")
local copilot = require("copilot.suggestion")
local luasnip = require("luasnip")
require("copilot").setup(opts)
local function set_trigger(trigger)
vim.b.copilot_suggestion_auto_trigger = trigger
vim.b.copilot_suggestion_hidden = not trigger
end
-- Hide suggestions when the completion menu is open.
cmp.event:on("menu_opened", function()
if copilot.is_visible() then
copilot.dismiss()
end
set_trigger(false)
end)
-- Disable suggestions when inside a snippet.
cmp.event:on("menu_closed", function()
set_trigger(not luasnip.expand_or_locally_jumpable())
end)
vim.api.nvim_create_autocmd("User", {
pattern = { "LuasnipInsertNodeEnter", "LuasnipInsertNodeLeave" },
callback = function()
set_trigger(not luasnip.expand_or_locally_jumpable())
end,
})
end,
},
}

View File

@ -73,10 +73,7 @@ return {
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }), ["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
local copilot = require("copilot.suggestion") if cmp.visible() then
if copilot.is_visible() then
copilot.accept_line()
elseif cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()