local status, cmp = pcall(require, 'cmp')
if (not status) then return end

local status_ls, ls = pcall(require, 'luasnip')

cmp.setup {
	snippet = {
		expand = function(args)
			if (status_ls) then
				ls.lsp_expand(args.body)
			end
		end,
	},
	mapping = cmp.mapping.preset.insert {
		['<C-d>'] = cmp.mapping.scroll_docs( -4),
		['<C-f>'] = cmp.mapping.scroll_docs(4),
		['<C-Space>'] = cmp.mapping.complete {},
		['<CR>'] = cmp.mapping.confirm {
			behavior = cmp.ConfirmBehavior.Replace,
			select = true,
		},
	},
	sources = {
		{ name = 'nvim_lsp' },
		{ name = 'luasnip' },
	}
}
