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,8 +97,9 @@ 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
if opts.keymap.preset == "super-tab" then -- super-tab
opts.keymap["<Tab>"] = { opts.keymap["<Tab>"] = {
function(cmp) function(cmp)
if cmp.snippet_active() then if cmp.snippet_active() then
@ -114,6 +111,12 @@ return {
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }), LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
"fallback", "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