From 81851bd6b5967917ce65ef1e135dba6259a0baa2 Mon Sep 17 00:00:00 2001 From: Squibid Date: Tue, 19 Nov 2024 13:20:39 -0600 Subject: refine completion keybinds --- lua/conf/plugins/cmp.lua | 54 +++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) (limited to 'lua/conf/plugins/cmp.lua') diff --git a/lua/conf/plugins/cmp.lua b/lua/conf/plugins/cmp.lua index 5dbb6ed..5d9dac2 100644 --- a/lua/conf/plugins/cmp.lua +++ b/lua/conf/plugins/cmp.lua @@ -7,7 +7,6 @@ end return { 'hrsh7th/nvim-cmp', requires = { - 'danymat/neogen', 'nvim-treesitter/nvim-treesitter', 'lukas-reineke/cmp-under-comparator' -- better results }, @@ -26,7 +25,6 @@ return { 'hrsh7th/nvim-cmp', function() local cmp = require('cmp') local luasnip = require('luasnip') - local neogen = require('neogen') cmp.setup { -- disable when in comments @@ -116,54 +114,30 @@ return { 'hrsh7th/nvim-cmp', -- mappings mapping = cmp.mapping.preset.insert { - [""] = cmp.mapping(function(fallback) - if #cmp.get_entries() == 1 then + [""] = cmp.mapping(function() + if cmp.get_active_entry() then cmp.confirm({ select = true }) - elseif cmp.visible() then + elseif cmp.visible() and not cmp.get_active_entry() then + cmp.select_next_item() + cmp.confirm({ select = true }) + end + end, { "i", "c" }), + + [""] = cmp.mapping(function() + if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - if #cmp.get_entries() == 1 then - cmp.confirm({ select = true }) - end - elseif neogen.jumpable() then - neogen.jump_next() - else - fallback() end - end, { "i", "s" }), + end), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - elseif neogen.jumpable(-1) then - neogen.jump_prev() - else - fallback() end - end, { "i", "s" }), - - [''] = 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 }), - }, + end), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.close(), - [""] = cmp.mapping.abort() + [''] = cmp.mapping.close() } } end -- cgit v1.2.1