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
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

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