Skip to content

Commit 826207a

Browse files
committed
docs: update supertab recipe to faithfully implement supertab functionality
1 parent 25af260 commit 826207a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lua/recipes.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ return {
2626

2727
local cmp = require("cmp")
2828

29+
opts.preselect = cmp.PreselectMode.None
30+
opts.completion = {
31+
completeopt = "menu,menuone,noinsert,noselect",
32+
}
33+
2934
opts.mapping = vim.tbl_extend("force", opts.mapping, {
3035
["<Tab>"] = cmp.mapping(function(fallback)
3136
if cmp.visible() then
@@ -52,6 +57,17 @@ return {
5257
fallback()
5358
end
5459
end, { "i", "s" }),
60+
["<CR>"] = cmp.mapping({
61+
i = function(fallback)
62+
if cmp.visible() and cmp.get_active_entry() then
63+
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
64+
else
65+
fallback()
66+
end
67+
end,
68+
s = cmp.mapping.confirm({ select = true }),
69+
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
70+
}),
5571
})
5672
end,
5773
},

0 commit comments

Comments
 (0)