add load on event, change mappings, add dap

This commit is contained in:
fiplox 2023-01-19 17:06:59 +01:00
parent 7da11777fe
commit e1f253fbd9
1 changed files with 22 additions and 3 deletions

View File

@ -11,6 +11,7 @@ local M = {
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'hrsh7th/cmp-calc', 'hrsh7th/cmp-calc',
}, },
event = { 'InsertEnter', 'CmdlineEnter' },
} }
function M.config() function M.config()
@ -27,6 +28,9 @@ function M.config()
end end
cmp.setup { cmp.setup {
enabled = function()
return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' or require('cmp_dap').is_dap_buffer()
end,
view = { view = {
entries = { entries = {
name = 'custom', -- can be "custom", "wildmenu" or "native" name = 'custom', -- can be "custom", "wildmenu" or "native"
@ -120,10 +124,10 @@ function M.config()
mapping = { mapping = {
['<TAB>'] = cmp.mapping(function(fallback) ['<TAB>'] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item { behavior = cmp.SelectBehavior.Insert } cmp.select_next_item()
-- cmp.complete()
else else
cmp.complete() cmp.complete()
cmp.select_next_item { behavior = cmp.SelectBehavior.Insert }
end end
end, { 'i', 's', 'c' }), end, { 'i', 's', 'c' }),
['<S-TAB>'] = cmp.mapping(function(fallback) ['<S-TAB>'] = cmp.mapping(function(fallback)
@ -133,7 +137,16 @@ function M.config()
cmp.complete() cmp.complete()
end end
end, { 'i', 's', 'c' }), end, { 'i', 's', 'c' }),
['<CR>'] = cmp.mapping { i = cmp.mapping.confirm { select = true } }, ['<CR>'] = 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 = { sources = {
{ name = 'cmdline' }, { name = 'cmdline' },
@ -154,6 +167,12 @@ function M.config()
entries = { name = 'wildmenu', separator = ' · ' }, entries = { name = 'wildmenu', separator = ' · ' },
}, },
}) })
cmp.setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, {
sources = {
{ name = 'dap' },
},
})
end end
return M return M