local function apply_hl(l)
	for group, hl in pairs(l) do
		if hl.bg == nil then
			hl.bg = "NONE"
		end
		vim.api.nvim_set_hl(0, group, hl)
	end
end

---@param c Palette
return function(c, overrides)
	apply_hl({
		SignAdd = { fg = c.green_bright },
		SignChange = { fg = c.blue_bright },
		SignDelete = { fg = c.red },

		ColorColumn = { bg = c.bg1 },
		Conceal = { fg = c.gray, bg = c.bg0 },
		CurSearch = { reverse = true },
		Cursor = { fg = c.raisin0, bg = c.white },
		CursorColumn = { link = "CursorLine" },
		CursorIM = { link = "Cursor" },
		CursorLine = { bg = c.bg1 },
		CursorLineFold = { link = "FoldColumn" },
		CursorLineNr = { fg = c.fg },
		CursorLineSign = { link = "SignColumn" },
		DiffAdd = { bg = c.diff_green },
		DiffChange = { bg = c.diff_blue },
		DiffDelete = { bg = c.diff_red },
		DiffText = { bg = c.diff_diff },
		Directory = { fg = c.pink },
		EndOfBuffer = { fg = c.bg1, bg = c.bg0 },
		ErrorMsg = { fg = c.red },
		FloatBorder = { fg = c.fg, bg = c.bg0 },
		FloatTitle = { link = "Title" },
		FoldColumn = {},
		Folded = { fg = c.fg, bg = c.bg2 },
		IncSearch = { reverse = true },
		LineNr = { fg = c.bg2 },
		LineNrAbove = { link = "LineNr" },
		LineNrBelow = { link = "LineNr" },
		MatchParen = { fg = c.red },
		ModeMsg = { fg = c.pink },
		MoreMsg = { fg = c.red },
		MsgArea = {},
		NonText = { fg = c.bg2 },
		Normal = { fg = c.fg, bg = c.bg0 },
		NormalFloat = { bg = c.bg0 },
		NormalNC = {},
		Pmenu = { bg = c.bg0 },
		PmenuExtra = { link = "Pmenu" },
		PmenuExtraSel = { link = "PmenuSel" },
		PmenuKind = { link = "Pmenu" },
		PmenuKindSel = { link = "PmenuExtraSel" },
		PmenuSbar = { bg = c.gray },
		PmenuSel = { bg = c.visual },
		PmenuThumb = { bg = c.bg2 },
		Question = { fg = c.blue_bright },
		QuickFixLine = { bg = c.visual },
		Search = { fg = c.green_bright, reverse = true },
		SignColumn = {},
		SpecialKey = { fg = c.green_bright },
		StatusLine = { bg = c.bg1 },
		StatusLineNC = { fg = c.gray, bg = c.bg0, italic = true },
		Substitute = { fg = c.raisin0, bg = c.carrot },
		TabLine = { bg = c.bg0 },
		TabLineFill = { bg = c.bg0 },
		TabLineSel = { fg = c.fg, bg = c.bg2 },
		TermCursor = { reverse = true },
		TermCursorNC = { reverse = true },
		Title = { fg = c.carrot },
		Visual = { bg = c.visual },
		WarningMsg = { fg = c.yellow },
		Whitespace = { fg = c.bg2 },
		WildMenu = { fg = c.raisin0, bg = c.yellow },
		WinBar = { link = "StatusLine" },
		WinBarNC = { link = "StatusLineNC" },
		WinSeparator = { fg = c.bg2 },
		diffAdded = { fg = c.green_bright },
		diffChanged = { fg = c.blue_bright },
		diffRemoved = { fg = c.red },
		lCursor = { link = "Cursor" },

		DiagnosticError = { fg = c.red, italic = true },
		DiagnosticHint = { fg = c.gray, italic = true },
		DiagnosticInfo = { fg = c.carrot, italic = true },
		DiagnosticOk = { fg = c.green_bright, italic = true },
		DiagnosticSignError = { fg = c.red },
		DiagnosticSignHint = { fg = c.gray },
		DiagnosticSignInfo = { fg = c.carrot },
		DiagnosticSignOk = { fg = c.green_bright },
		DiagnosticSignWarn = { fg = c.yellow },
		DiagnosticUnnecessary = { link = "DiagnosticHint" },
		DiagnosticVirtualTextError = { fg = c.red, italic = true, bg = c.bg1 },
		DiagnosticVirtualTextHint = { fg = c.gray, italic = true, bg = c.bg1 },
		DiagnosticVirtualTextInfo = { fg = c.carrot, italic = true, bg = c.bg1 },
		DiagnosticVirtualTextOk = { fg = c.green_bright, italic = true, bg = c.bg1 },
		DiagnosticVirtualTextWarn = { fg = c.yellow, italic = true, bg = c.bg1 },
		DiagnosticWarn = { fg = c.yellow, italic = true },

		Boolean = { fg = c.carrot },
		Character = { fg = c.cyan },
		Comment = { fg = c.gray, italic = true },
		Conditional = { link = "Statement" },
		Constant = { fg = c.pink },
		Define = { fg = c.red },
		Delimiter = { fg = c.pink },
		Error = { fg = c.red },
		Exception = { link = "Statement" },
		Float = { link = "Number" },
		Function = { fg = c.cyan },
		Identifier = { fg = c.pink },
		Include = { fg = c.green_bright },
		Keyword = { link = "Statement" },
		Label = { link = "Statement" },
		Macro = { link = "PreProc" },
		Number = { fg = c.carrot },
		Operator = { link = "Statement" },
		PreCondit = { link = "PreProc" },
		PreProc = { fg = c.yellow },
		Repeat = { link = "Statement" },
		Special = { fg = c.green_bright },
		SpecialChar = { link = "Special" },
		Statement = { fg = c.yellow },
		StorageClass = { link = "Type" },
		String = { fg = c.carrot },
		Structure = { link = "Type" },
		Tag = { link = "Special" },
		Todo = { fg = c.red },
		Type = { fg = c.pink },
		Typedef = { link = "Type" },

		["@boolean.json"] = { fg = c.carrot, italic = true },
		["@conceal"] = { link = "Conceal" },
		["@constant.bash"] = { fg = c.green_bright },
		["@constant.go"] = { fg = c.blue_bright },
		["@constructor"] = { fg = c.red },
		["@constructor.lua"] = { fg = c.yellow },
		["@keyword.sql"] = { link = "Identifier" },
		["@label"] = { fg = c.green_bright },
		["@markup.heading"] = { link = "Title" },
		["@module"] = { fg = c.pink, italic = true },
		["@parameter"] = { italic = true },
		["@property.css"] = { fg = c.green_bright },
		["@property.go"] = { fg = c.pink },
		["@property.javascript"] = { fg = c.cyan },
		["@punctuation.bracket"] = { fg = c.yellow },
		["@punctuation.bracket.javascript"] = { fg = c.pink },
		["@string"] = { link = "String" },
		["@tag"] = { fg = c.blue_bright },
		["@tag.attribute"] = { fg = c.yellow },
		["@tag.javascript"] = { fg = c.green_bright },
		["@text.diff.add"] = { link = "diffAdded" },
		["@text.diff.delete"] = { link = "diffRemoved" },
		["@type"] = { fg = c.red },
		["@type.builtin"] = { fg = c.green_bright },
		["@type.builtin.python"] = { fg = c.red },
		["@type.definition"] = { fg = c.red },
		["@type.javascript"] = { fg = c.pink },
		["@type.python"] = { fg = c.red },
		["@variable"] = { link = "Identifier" },
		["@variable.builtin"] = { fg = c.red },

		["@lsp.type.parameter.lua"] = { fg = c.green_bright, italic = true },
		["@lsp.type.parameter"] = { italic = true },

		-- indentblank
		IblIndent = { fg = c.bg1 },
		IblScope = { fg = c.gray },

		-- nvimtree
		NvimTreeFolderName = { fg = c.fg },
		NvimTreeOpenedFolderName = { italic = true },
		NvimTreeGitDirty = { fg = c.carrot },
		NvimTreeGitStaged = { fg = c.blue_bright },
		NvimTreeGitNew = { fg = c.green_bright },
		NvimTreeGitDeleted = { fg = c.red },

		-- neotree
		NeoTreeTitleBar = { fg = c.raisin0, bg = c.fg },

		-- gitgutter
		GitGutterAdd = { link = "SignAdd" },
		GitGutterChange = { link = "SignChange" },
		GitGutterDelete = { link = "SignDelete" },

		-- inline highlights
		GitGutterAddLine = { link = "DiffAdd" },
		GitGutterChangeLine = { link = "DiffChange" },
		GitGutterDeleteLine = { link = "DiffDelete" },
		GitGutterChangeDeleteLine = { link = "DiffDelete" },

		-- gitsigns
		GitSignsAdd = { link = "SignAdd" },
		GitSignsChange = { link = "SignChange" },
		GitSignsDelete = { link = "SignDelete" },
		GitSignsCurrentLineBlame = { fg = c.gray, italic = true },

		-- fugitive
		fugitiveUntrackedHeading = { fg = c.carrot },
		fugitiveUntrackedModifier = { fg = c.red },
		fugitiveStagedHeading = { fg = c.green_bright },
		fugitiveStagedModifier = { fg = c.green_bright },
		fugitiveUnstagedHeading = { fg = c.red },
		fugitiveUnstagedModifier = { fg = c.red },

		-- cmp
		CmpItemKind = { fg = c.green_bright },
		CmpItemKindClass = { link = "Type" },
		CmpItemKindConstant = { link = "Constant" },
		CmpItemKindFunction = { link = "Function" },
		CmpItemKindKeyword = { link = "Keyword" },
		CmpItemKindModule = { link = "Include" },
		CmpItemKindSnippet = { link = "Define" },
		CmpItemKindText = { link = "Comment" },
		CmpItemKindVariable = { link = "Identifier" },

		--treesittercontext
		TreesitterContext = { bg = c.bg1 },

		--telescope
		TelescopeMatching = { fg = c.green_bright, underline = true },

		-- copilot
		CopilotSuggestion = { fg = c.sand, italic = true },
		CmpItemKindCopilot = { fg = c.red },
	})

	apply_hl(overrides)
end
