updating libraries 💥
This commit is contained in:
@@ -50,16 +50,8 @@ end, { desc = "Copilot: Refresh panel" })
|
|||||||
keymap.set("n", "<M-CR>", ":Copilot panel<CR>", { desc = "Copilot: Open panel" })
|
keymap.set("n", "<M-CR>", ":Copilot panel<CR>", { desc = "Copilot: Open panel" })
|
||||||
|
|
||||||
-- Copilot suggestion keymaps (insert mode)
|
-- Copilot suggestion keymaps (insert mode)
|
||||||
keymap.set("i", "<Tab>", function()
|
-- Note: Tab mapping is handled in nvim-cmp.lua to avoid conflicts
|
||||||
local suggestion = get_copilot_suggestion()
|
-- Tab is reserved exclusively for Copilot inline suggestions
|
||||||
if suggestion and suggestion.is_visible() then
|
|
||||||
suggestion.accept()
|
|
||||||
else
|
|
||||||
-- Feed Tab through so nvim-cmp can handle it for completion menu/snippets
|
|
||||||
-- Use 't' flag to avoid remapping, 'n' flag for normal mode keycodes
|
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "nt")
|
|
||||||
end
|
|
||||||
end, { desc = "Copilot: Accept suggestion" })
|
|
||||||
|
|
||||||
keymap.set("i", "<leader>]", function()
|
keymap.set("i", "<leader>]", function()
|
||||||
local suggestion = get_copilot_suggestion()
|
local suggestion = get_copilot_suggestion()
|
||||||
|
|||||||
@@ -47,32 +47,26 @@ return {
|
|||||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
-- Tab for completion menu and snippet expansion
|
-- Tab is reserved for Copilot inline suggestions ONLY
|
||||||
-- Note: Copilot suggestion acceptance is handled in keymaps/copilot.lua
|
-- Use <C-j>/<C-k> to navigate cmp menu, <CR> to confirm
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
-- Handle nvim-cmp completion menu
|
-- Check for Copilot inline suggestion first (highest priority)
|
||||||
if cmp.visible() then
|
local copilot_ok, copilot_suggestion = pcall(require, "copilot.suggestion")
|
||||||
local entry = cmp.get_selected_entry()
|
if copilot_ok and copilot_suggestion.is_visible() then
|
||||||
-- If Copilot suggestion is available and selected, accept it
|
copilot_suggestion.accept()
|
||||||
if entry and entry.source.name == "copilot" then
|
return
|
||||||
cmp.confirm({ select = true })
|
end
|
||||||
else
|
-- If no Copilot suggestion, handle snippet jumping
|
||||||
-- Confirm the current selection
|
if luasnip.expand_or_jumpable() then
|
||||||
cmp.confirm({ select = true })
|
|
||||||
end
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
-- Expand snippet or jump to next placeholder
|
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
-- Fallback to default Tab behavior
|
-- Default Tab behavior (insert tab character)
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
-- Shift-Tab to go back in snippets
|
-- Shift-Tab to go back in snippets
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if luasnip.jumpable(-1) then
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
|
|||||||
Reference in New Issue
Block a user