From e1f253fbd9659e291739db7fb0264817e5e6eb05 Mon Sep 17 00:00:00 2001 From: fiplox Date: Thu, 19 Jan 2023 17:06:59 +0100 Subject: [PATCH] add load on event, change mappings, add dap --- lua/plugins/cmp.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 728f2d6..257257d 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -11,6 +11,7 @@ local M = { 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', }, + event = { 'InsertEnter', 'CmdlineEnter' }, } function M.config() @@ -27,6 +28,9 @@ function M.config() end cmp.setup { + enabled = function() + return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' or require('cmp_dap').is_dap_buffer() + end, view = { entries = { name = 'custom', -- can be "custom", "wildmenu" or "native" @@ -120,10 +124,10 @@ function M.config() mapping = { [''] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_next_item { behavior = cmp.SelectBehavior.Insert } + cmp.select_next_item() + -- cmp.complete() else cmp.complete() - cmp.select_next_item { behavior = cmp.SelectBehavior.Insert } end end, { 'i', 's', 'c' }), [''] = cmp.mapping(function(fallback) @@ -133,7 +137,16 @@ function M.config() cmp.complete() end end, { 'i', 's', 'c' }), - [''] = cmp.mapping { i = cmp.mapping.confirm { select = true } }, + [''] = cmp.mapping { + i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, + c = function(fallback) + if cmp.visible() then + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + else + fallback() + end + end, + }, }, sources = { { name = 'cmdline' }, @@ -154,6 +167,12 @@ function M.config() entries = { name = 'wildmenu', separator = ' ยท ' }, }, }) + + cmp.setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { + sources = { + { name = 'dap' }, + }, + }) end return M