nixos-configs/common/home/neovim/plugins/cmp.lua

51 lines
1.1 KiB
Lua
Raw Normal View History

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
cmp.event:on(
2024-08-07 10:41:41 -04:00
'confirm_done',
cmp_autopairs.on_confirm_done()
);
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)
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)
if cmp.visible() then
cmp.select_prev_item();
2024-08-07 10:41:41 -04:00
else
fallback();
end;
end, {
'i',
's',
}),
},
});