kickstart.nvim/lua/plugins/copilot.lua

36 lines
898 B
Lua
Raw Normal View History

2024-05-27 23:19:48 +02:00
return {
'zbirenbaum/copilot.lua',
cmd = 'Copilot',
event = 'InsertEnter',
config = function()
2024-06-05 09:22:10 +02:00
local copilot = require 'copilot'
local suggestion = require 'copilot.suggestion'
2024-06-09 23:31:50 +02:00
-- disable copilot by default
2024-06-05 09:22:10 +02:00
copilot.setup {
2024-06-04 19:19:49 +02:00
suggestion = {
2024-06-17 22:39:03 +02:00
enabled = true,
2024-06-09 23:31:50 +02:00
auto_trigger = true,
2024-06-04 19:19:49 +02:00
keymap = {
accept = '<Tab>',
next = '<S-Tab>',
},
},
}
2024-06-05 09:22:10 +02:00
-- Define the tab_complete function globally
_G.tab_complete = function()
if suggestion.is_visible() then
vim.schedule(function()
suggestion.accept()
end)
else
return vim.api.nvim_replace_termcodes('<Tab>', true, true, true)
end
end
-- Map <Tab> to the global tab_complete function
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true, noremap = true, silent = true })
2024-05-27 23:19:48 +02:00
end,
}