local c = {
  none = "NONE",

  black = "#282828",
  red = "#cc241d",
  green = "#98971a",
  yellow = "#d79921",
  blue = "#458588",
  magenta = "#b16286",
  cyan = "#689d6a",
  white = "#a89984",

  bright_black = "#3c3836",
  bright_red = "#fb4934",
  bright_green = "#b8bb26",
  bright_yellow = "#fabd2f",
  bright_blue = "#83a598",
  bright_magenta = "#d3869b",
  bright_cyan = "#8ec07c",
  bright_white = "#ebdbb2",
}

local groups = {
  --See :h highlight-groups
  Boolean = { fg = c.bright_magenta },
  Character = { fg = c.bright_magenta },
  ColorColumn = { fg = c.none, bg = c.black },
  Comment = { fg = c.white, italic = true },
  Conceal = { fg = c.magenta },
  Conditional = { fg = c.magenta },
  Constant = { fg = c.magenta },
  Cursor = { fg = c.black, bg = c.bright_white },
  CursorColumn = { link = "CursorLine" },
  CursorIM = { link = "Cursor" },
  CursorLine = { fg = c.none, bg = c.bright_black },
  CursorLineNr = { fg = c.bright_white, bg = c.black, bold = true },
  Debug = { fg = c.bright_red },
  Define = { fg = c.cyan },
  Delimiter = { fg = c.yellow },
  DiffAdd = { fg = c.bright_green, bg = c.black },
  DiffChange = { fg = c.cyan, bg = c.black },
  DiffDelete = { fg = c.bright_red, bg = c.black },
  DiffText = { fg = c.bright_yellow, bg = c.black, reverse = true },
  Directory = { fg = c.bright_green, bold = true },
  EndOfBuffer = { fg = c.bright_black },
  Error = { fg = c.bright_red, bg = c.black, bold = true, reverse = true },
  ErrorMsg = { fg = c.black, bg = c.bright_red, bold = true },
  Exception = { fg = c.bright_red },
  Float = { fg = c.bright_magenta },
  FoldColumn = { fg = c.bright_black, bg = c.black },
  Folded = { fg = c.bright_black },
  Function = { fg = c.bright_green, bold = true },
  Identifier = { fg = c.bright_blue },
  Ignore = { link = "Conceal" },
  IncSearch = { fg = c.black, bg = c.white },
  Include = { fg = c.cyan },
  Keyword = { fg = c.bright_red },
  Label = { fg = c.bright_red },
  LineNr = { fg = c.white },
  Macro = { fg = c.cyan },
  MatchParen = { fg = c.none, bg = c.white, bold = true, underline = true },
  ModeMsg = { fg = c.bright_yellow, bold = true },
  MoreMsg = { fg = c.bright_yellow, bold = true },
  NonText = { fg = c.bright_black },
  Normal = { fg = c.bright_white, bg = c.black },
  NormalFloat = { link = "Normal" },
  Number = { fg = c.bright_magenta },
  Operator = { fg = c.cyan },
  Pmenu = { fg = c.bright_white, bg = c.bright_black },
  PmenuExtra = { fg = c.white, bg = c.bright_black },
  PmenuExtraSel = { fg = c.bright_black, bg = c.bright_blue },
  PmenuKind = { fg = c.bright_red, bg = c.bright_black },
  PmenuKindSel = { fg = c.bright_blue, bg = c.bright_blue },
  PmenuMatch = { fg = c.magenta, bg = c.bright_black },
  PmenuMatchSel = { fg = c.magenta, bg = c.bright_blue, bold = true },
  PmenuSbar = { fg = c.none, bg = c.bright_black },
  PmenuSel = { fg = c.black, bg = c.white, bold = true },
  PmenuThumb = { fg = c.none, bg = c.white },
  PreCondit = { fg = c.cyan },
  PreProc = { fg = c.cyan },
  Question = { fg = c.yellow, bold = true },
  QuickFixLine = { fg = c.cyan, bg = c.black, reverse = true },
  Repeat = { fg = c.bright_red },
  Search = { fg = c.black, bg = c.white },
  SignColumn = { fg = c.bright_black, bg = c.black },
  SnippetTabstop = { link = "Normal" },
  Special = { fg = c.yellow },
  SpecialChar = { fg = c.bright_red },
  SpecialComment = { fg = c.bright_red, italic = true },
  SpecialKey = { fg = c.bright_black },
  SpellBad = { fg = c.bright_red, underline = true },
  SpellCap = { fg = c.bright_blue, underline = true },
  SpellLocal = { fg = c.cyan, underline = true },
  SpellRare = { fg = c.bright_magenta, underline = true },
  Statement = { fg = c.bright_red },
  StatusLine = { fg = c.black, bg = c.bright_white },
  StatusLineNC = { link = "StatusLine" },
  StorageClass = { fg = c.yellow },
  String = { fg = c.bright_green },
  Structure = { fg = c.magenta },
  TabLine = { fg = c.white, bg = c.black },
  TabLineFill = { fg = c.bright_white, bg = c.black },
  TabLineSel = { fg = c.bright_white, bg = c.black, bold = true },
  Title = { fg = c.bright_green, bold = true },
  Todo = { fg = c.black, bg = c.white, bold = true },
  ToolbarButton = { fg = c.bright_white, bg = c.bright_black, bold = true },
  ToolbarLine = { fg = c.none },
  Type = { fg = c.bright_yellow },
  Typedef = { fg = c.bright_yellow },
  Underlined = { fg = c.bright_blue, underline = true },
  VertSplit = { fg = c.bright_black, bg = c.black },
  Visual = { fg = c.black, bg = c.white },
  WarningMsg = { fg = c.bright_yellow, bold = true },
  WildMenu = { fg = c.bright_blue, bg = c.white, bold = true },
  WinBar = { fg = c.bright_white, bg = c.black },
  WinBarNC = { fg = c.white, bg = c.black },

  --See :h diagnostic-highlights
  DiagnosticError = { fg = c.red },
  DiagnosticWarn = { fg = c.yellow },
  DiagnosticInfo = { fg = c.blue },
  DiagnosticHint = { fg = c.cyan },

  --See :h lsp-highlights
  LspInlayHint = { fg = c.white },

  --See :h treesitter-highlight-groups
  ["@boolean"] = { link = "Boolean" },
  ["@character"] = { link = "Character" },
  ["@character.special"] = { link = "SpecialChar" },
  ["@comment"] = { link = "Comment" },
  ["@conditional"] = { link = "Conditional" },
  ["@constant"] = { link = "Constant" },
  ["@constant.builtin"] = { link = "Special" },
  ["@constant.macro"] = { link = "Define" },
  ["@constructor"] = { link = "Special" },
  ["@debug"] = { link = "Debug" },
  ["@define"] = { link = "Define" },
  ["@exception"] = { link = "Exception" },
  ["@field"] = { link = "Identifier" },
  ["@float"] = { link = "Float" },
  ["@function"] = { link = "Function" },
  ["@function.builtin"] = { link = "Special" },
  ["@function.macro"] = { link = "Macro" },
  ["@include"] = { link = "Include" },
  ["@keyword"] = { link = "Keyword" },
  ["@label"] = { link = "Label" },
  ["@macro"] = { link = "Macro" },
  ["@method"] = { link = "Function" },
  ["@namespace"] = { link = "Identifier" },
  ["@number"] = { link = "Number" },
  ["@operator"] = { link = "Operator" },
  ["@parameter"] = { link = "Identifier" },
  ["@preproc"] = { link = "PreProc" },
  ["@property"] = { link = "Identifier" },
  ["@punctuation"] = { link = "Delimiter" },
  ["@repeat"] = { link = "Repeat" },
  ["@storageclass"] = { link = "StorageClass" },
  ["@string"] = { link = "String" },
  ["@string.escape"] = { link = "SpecialChar" },
  ["@string.special"] = { link = "SpecialChar" },
  ["@structure"] = { link = "Structure" },
  ["@tag"] = { link = "Tag" },
  ["@text.literal"] = { link = "Comment" },
  ["@text.reference"] = { link = "Identifier" },
  ["@text.title"] = { link = "Title" },
  ["@text.todo"] = { link = "Todo" },
  ["@text.underline"] = { link = "Underlined" },
  ["@text.uri"] = { link = "Underlined" },
  ["@type"] = { link = "Type" },
  ["@type.definition"] = { link = "Typedef" },
  ["@variable"] = { fg = c.bright_white },
  ["@keyword.function"] = { fg = c.bright_cyan },

  --See :h lsp-semantic-highlight
  ["@lsp.type.class"] = { link = "Structure" },
  ["@lsp.type.decorator"] = { link = "Function" },
  ["@lsp.type.enum"] = { link = "Constant" },
  ["@lsp.type.enumMember"] = { link = "Constant" },
  ["@lsp.type.function"] = { link = "Function" },
  ["@lsp.type.interface"] = { link = "Structure" },
  ["@lsp.type.macro"] = { link = "Macro" },
  ["@lsp.type.method"] = { link = "Function" },
  ["@lsp.type.namespace"] = { link = "Structure" },
  ["@lsp.type.parameter"] = { link = "Identifier" },
  ["@lsp.type.property"] = { link = "Identifier" },
  ["@lsp.type.struct"] = { link = "Structure" },
  ["@lsp.type.type"] = { link = "Type" },
  ["@lsp.type.typeParameter"] = { link = "TypeDef" },
  ["@lsp.type.variable"] = { link = "@variable" },

  --See telescope.nvim/plugin/telescope.lua
  TelescopeSelection = { link = "CursorLine" },
  TelescopeSelectionCaret = { link = "TelescopeSelection" },
  TelescopeMultiSelection = { link = "Type", default = true },
  TelescopeMultiIcon = { link = "TelescopePromptPrefix", default = true },
  TelescopePromptPrefix = { fg = c.bright_white },

  --See :h gitsigns-highlight-groups
  GitSignsAdd = { link = "DiffAdd" },
  GitSignsChange = { link = "DiffChange" },
  GitSignsDelete = { link = "DiffDelete" },

  -- See :h neogit_highlights
  NeogitChangeAdded = { fg = c.bright_green, bold = true, italic = true },
  NeogitChangeDeleted = { fg = c.bright_red, bold = true, italic = true },
  NeogitChangeModified = { fg = c.cyan, bold = true, italic = true },
  NeogitDiffAdd = { link = "DiffAdd" },
  NeogitDiffAddCursor = { fg = c.black, bg = c.bright_green },
  NeogitDiffAddHighlight = { link = "DiffAdd" },
  NeogitDiffDelete = { link = "DiffDelete" },
  NeogitDiffDeleteCursor = { fg = c.black, bg = c.bright_red },
  NeogitDiffDeleteHighlight = { link = "DiffDelete" },
}

for group, opts in pairs(groups) do
  vim.api.nvim_set_hl(0, group, opts)
end
