integrate GitHub Copilot

This commit is contained in:
Oliver Ladner 2024-03-07 10:41:04 +01:00
commit 0d7a6429ed
5 changed files with 81 additions and 1 deletions

View file

@ -0,0 +1,54 @@
-- Fully featured & enhanced replacement for copilot.vim complete with API for
-- interacting with Github Copilot
-- https://github.com/zbirenbaum/copilot.lua
return {
"zbirenbaum/copilot.lua",
lazy = true,
event = "InsertEnter",
config = function()
local copilot = require("copilot")
copilot.setup({
panel = {
enabled = false,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4,
},
},
suggestion = {
enabled = false,
auto_trigger = false,
debounce = 75,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
yaml = false,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = "node", -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
}

View file

@ -0,0 +1,10 @@
-- transforms https://github.com/zbirenbaum/copilot.lua into a cmp source.
-- https://github.com/zbirenbaum/copilot-cmp
return {
"zbirenbaum/copilot-cmp",
lazy = false,
--event = "InsertEnter",
config = function()
require("copilot_cmp").setup()
end,
}

View file

@ -33,6 +33,13 @@ return {
cmp.setup({
formatting = lsp_zero.cmp_format(),
sources = {
{ name = "copilot" },
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer" },
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
@ -43,6 +50,14 @@ return {
["<C-f>"] = cmp_action.luasnip_jump_forward(),
["<C-b>"] = cmp_action.luasnip_jump_backward(),
}),
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
completion = {
border = { "", "", "", "", "", "", "", "" },
},
},
})
end,
},