keybind fix
This commit is contained in:
parent
67f33f32a3
commit
ef18a80a92
4
init.lua
4
init.lua
|
@ -684,9 +684,9 @@ require('lazy').setup({
|
||||||
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
-- Select the [n]ext item
|
-- Select the [n]ext item
|
||||||
['<S-CR>'] = cmp.mapping.select_next_item(),
|
['<S-j>'] = cmp.mapping.select_next_item(),
|
||||||
-- Select the [p]revious item
|
-- Select the [p]revious item
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
['<S-k>'] = cmp.mapping.select_prev_item(),
|
||||||
|
|
||||||
-- Scroll the documentation window [b]ack / [f]orward
|
-- Scroll the documentation window [b]ack / [f]orward
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
|
|
@ -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