diff --git a/neovim/lua/plugins/completion.lua b/neovim/lua/plugins/completion.lua index 6e1f5df..be18116 100644 --- a/neovim/lua/plugins/completion.lua +++ b/neovim/lua/plugins/completion.lua @@ -19,9 +19,11 @@ function M.config_cmp() { name = "buffer" }, { name = "spell" }, }, - mapping = { - [""] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }), + mapping = cmp.mapping.preset.insert({ + -- Scroll docs with readline back - forward + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + -- Expand snippets with Tab [""] = cmp.mapping(function(fallback) if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() @@ -29,19 +31,17 @@ function M.config_cmp() fallback() end end), + -- Start and cycle completions with C-Space [""] = cmp.mapping(function() if cmp.visible() then cmp.select_next_item() else cmp.complete() end - end, { "i", "c" }), - [""] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), + end), + -- Confirm completion with Enter [""] = cmp.mapping.confirm({ select = true }), - }, + }), }) -- Add a plug mapping to use in C-Space binding