From bf82c7d7e186a62078661e03e92d905d3d327ad6 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Wed, 10 Apr 2024 23:58:02 -0400 Subject: [PATCH] remove cmp select --- lua/plugins/cmp.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lua/plugins/cmp.lua diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..b4f37fd --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,30 @@ +return { + "hrsh7th/nvim-cmp", + config = function(_, opts) + local cmp = require "cmp" + opts.mapping[""] = cmp.mapping { + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + else + fallback() + end + end, + s = cmp.mapping.confirm { select = true }, + c = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true }, + } + opts.mapping[""] = cmp.mapping(function(fallback) + -- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item + if cmp.visible() then + local entry = cmp.get_selected_entry() + if not entry then + cmp.select_next_item { behavior = cmp.SelectBehavior.Select } + end + cmp.confirm() + else + fallback() + end + end, { "i", "s", "c" }) + require("cmp").setup(opts) + end, +}