keybind fix

This commit is contained in:
jhe 2024-06-05 09:22:10 +02:00
parent 67f33f32a3
commit ef18a80a92
No known key found for this signature in database
GPG key ID: 10FFC60F6B8DC9B7
2 changed files with 22 additions and 4 deletions

View file

@ -3,7 +3,10 @@ return {
cmd = 'Copilot',
event = 'InsertEnter',
config = function()
require('copilot').setup {
local copilot = require 'copilot'
local suggestion = require 'copilot.suggestion'
copilot.setup {
suggestion = {
keymap = {
accept = '<Tab>',
@ -11,6 +14,21 @@ return {
},
},
}
require('copilot.suggestion').toggle_auto_trigger()
-- 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 })
suggestion.toggle_auto_trigger()
end,
}