fix(blink): allow overriding <Tab> key. Fixes #5095. Closes #5099

This commit is contained in:
Folke Lemaitre
2024-12-15 18:44:24 +01:00
parent 8f113a514c
commit 89314cb2aa

View File

@ -80,10 +80,6 @@ return {
keymap = {
preset = "enter",
["<C-y>"] = { "select_and_accept" },
["<Tab>"] = {
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback",
},
},
},
---@param opts blink.cmp.Config | { sources: { compat: string[] } }
@ -101,19 +97,26 @@ return {
end
end
-- fix super-tab completion
if opts.keymap.preset == "super-tab" then
opts.keymap["<Tab>"] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback",
}
-- add ai_accept to <Tab> key
if not opts.keymap["<Tab>"] then
if opts.keymap.preset == "super-tab" then -- super-tab
opts.keymap["<Tab>"] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback",
}
else -- other presets
opts.keymap["<Tab>"] = {
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback",
}
end
end
--- NOTE: compat with latest version. Currenlty 0.7.6