This commit is contained in:
commit
c8d8155af5
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue