local Plugin = {'hrsh7th/nvim-cmp'}

Plugin.dependencies = {
	{'hrsh7th/cmp-nvim-lsp'},
	{'hrsh7th/cmp-path'},
	{'hrsh7th/cmp-buffer'},
	{'onsails/lspkind.nvim'}
}

function Plugin.config()
	local cmp = require('cmp')
	local lspkind = require('lspkind')

	cmp.setup({
		-- preselect = cmp.PreselectMode.None,
		mapping = {
			["<C-p>"] = cmp.mapping.select_prev_item(),
			["<C-n>"] = cmp.mapping.select_next_item(),
			-- Add tab support
			["<S-Tab>"] = cmp.mapping.select_prev_item(),
			["<Tab>"] = cmp.mapping.select_next_item(),
			["<C-d>"] = cmp.mapping.scroll_docs(-4),
			["<C-f>"] = cmp.mapping.scroll_docs(4),
			["<C-Space>"] = cmp.mapping.complete(),
			["<C-e>"] = cmp.mapping.close(),
			["<CR>"] = cmp.mapping.confirm({
				behavior = cmp.ConfirmBehavior.Insert,
				select = true,
			})
		},
		formatting = {
			 format = lspkind.cmp_format {
					with_text = true,
					menu = {
						 buffer   = "[buf]",
						 nvim_lsp = "[LSP]",
						 path     = "[path]",
					},
			 },
		},
		sources = {
			{ name = "nvim_lsp" },
			{ name = "path" },
			{ name = "buffer" },
		}
	})

end

return Plugin
