From 9a715c6e6c568cfce48e0249c81e24ebf4648474 Mon Sep 17 00:00:00 2001 From: JackJ30 Date: Wed, 28 May 2025 20:23:13 -0400 Subject: improve cmp keybinds --- .config/nvim/lua/user/plugins/cmp.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.config/nvim/lua/user/plugins/cmp.lua b/.config/nvim/lua/user/plugins/cmp.lua index a7afe9f..f515e17 100644 --- a/.config/nvim/lua/user/plugins/cmp.lua +++ b/.config/nvim/lua/user/plugins/cmp.lua @@ -9,6 +9,7 @@ return { }, opts = function() local cmp = require('cmp') + local select_opts = {behavior = cmp.SelectBehavior.Select} return { snippet = { @@ -16,12 +17,19 @@ return { require('luasnip').lsp_expand(args.body) end, }, - mapping = cmp.mapping.preset.insert(), + mapping = { + [''] = cmp.mapping.select_prev_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({select = true}), + }, sources = cmp.config.sources({ - { name = 'nvim_lsp', max_item_count = 5 }, - { name = "luasnip", max_item_count = 5 }, + { name = 'nvim_lsp', max_item_count = 5, keyword_length = 1 }, + { name = "luasnip", max_item_count = 5, keyword_length = 2 }, }, { - { name = 'buffer', max_item_count = 2 }, + { name = 'buffer', max_item_count = 2, keyword_length = 3 }, }, { { name = 'path', max_item_count = 2 }, }), -- cgit v1.2.3