From 2f6b0ba33c231d4fa07f5086d3140aed1a78b499 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 1 Apr 2024 19:00:40 +0100 Subject: [PATCH] Add more cmp preset mappigns * `` to trigger the complteion menu without a substring prefix * ``/` to scroll down/up in a completion item's documentation --- lua/plugins/completions.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index 108f68d..57aab3b 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -89,11 +89,19 @@ return { require('luasnip').lsp_expand(args.body) end }, + mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), + -- Open completion menu/confirm completion + [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ select = true }), + -- Select completion from menu + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + -- Scroll documentation of selected completion item + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.scroll_docs(-4), }), + sources = { { name = 'luasnip' }, { name = 'nvim_lsp' },