local is_on_glibc = require("util.checks").is_on_glibc

---@type LazySpec
return {
	-- credits: https://github.com/AstroNvim/astrocommunity/blob/6f3ce1b6349a29975cbd1af8427f7a52aaef936d/lua/astrocommunity/completion/codeium-vim/init.lua
	"Exafunction/codeium.vim",
	event = "User AstroFile",
	cond = not vim.g.codeium_native_plugin and is_on_glibc(),
	dependencies = {
		"AstroNvim/astrocore",
		---@type AstroCoreOpts
		opts = {
			mappings = {
				i = {
					["<C-g>"] = {
						function()
							return vim.fn["codeium#Accept"]()
						end,
						desc = "Codeium accept completion",
						expr = true,
					},
					["<c-n>"] = {
						function()
							return vim.fn["codeium#CycleCompletions"](1)
						end,
						desc = "Codeium next suggestion",
						expr = true,
					},
					["<c-p>"] = {
						function()
							return vim.fn["codeium#CycleCompletions"](-1)
						end,
						desc = "Codeium previous suggestion",
						expr = true,
					},
					["<c-x>"] = {
						function()
							return vim.fn["codeium#Clear"]()
						end,
						desc = "Codeium clear completions",
						expr = true,
					},
				},
				n = {
					["<Leader>uA"] = {
						function()
							if vim.g.codeium_enabled == true then
								vim.cmd("CodeiumDisable")
							else
								vim.cmd("CodeiumEnable")
							end
						end,
						desc = "Toggle Codeium active",
						expr = true,
					},
				},
			},
		},
	},
}
