This commit is contained in:
commit
c8d8155af5
|
@ -3,7 +3,10 @@ return {
|
||||||
cmd = 'Copilot',
|
cmd = 'Copilot',
|
||||||
event = 'InsertEnter',
|
event = 'InsertEnter',
|
||||||
config = function()
|
config = function()
|
||||||
require('copilot').setup {
|
local copilot = require 'copilot'
|
||||||
|
local suggestion = require 'copilot.suggestion'
|
||||||
|
|
||||||
|
copilot.setup {
|
||||||
suggestion = {
|
suggestion = {
|
||||||
keymap = {
|
keymap = {
|
||||||
accept = '<Tab>',
|
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,
|
end,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue