2024-07-28 02:54:34 -04:00
|
|
|
local cmp = require('cmp');
|
2024-08-07 10:41:41 -04:00
|
|
|
local cmp_autopairs = require('nvim-autopairs.completion.cmp');
|
2024-08-02 00:08:30 -04:00
|
|
|
|
2024-07-28 02:54:34 -04:00
|
|
|
cmp.event:on(
|
2024-08-07 10:41:41 -04:00
|
|
|
'confirm_done',
|
|
|
|
cmp_autopairs.on_confirm_done()
|
|
|
|
);
|
2024-07-28 02:54:34 -04:00
|
|
|
|
|
|
|
cmp.setup({
|
|
|
|
sources = {
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'buffer' },
|
|
|
|
{ name = 'path' },
|
|
|
|
},
|
|
|
|
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
vim.fn['vsnip#anonymous'](args.body);
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
mapping = {
|
2024-08-02 00:08:30 -04:00
|
|
|
-- Confirm selection
|
2024-08-07 10:41:41 -04:00
|
|
|
['<Right>'] = cmp.mapping.confirm({ select = true }),
|
2024-08-02 00:08:30 -04:00
|
|
|
|
|
|
|
-- Next selection
|
|
|
|
['<Down>'] = cmp.mapping(function(fallback)
|
2024-07-28 02:54:34 -04:00
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item();
|
|
|
|
else
|
|
|
|
fallback();
|
|
|
|
end;
|
|
|
|
end, {
|
|
|
|
'i',
|
|
|
|
's',
|
|
|
|
}),
|
|
|
|
|
2024-08-02 00:08:30 -04:00
|
|
|
-- Previous selection
|
2024-08-07 10:41:41 -04:00
|
|
|
['<Up>'] = cmp.mapping(function(fallback)
|
2024-07-28 02:54:34 -04:00
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item();
|
2024-08-07 10:41:41 -04:00
|
|
|
else
|
|
|
|
fallback();
|
2024-07-28 02:54:34 -04:00
|
|
|
end;
|
|
|
|
end, {
|
|
|
|
'i',
|
|
|
|
's',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|