--- @class HighlightDefinition
--- @field fg string?
--- @field bg string?
--- @field sp string?
--- @field blend integer?
--- @field bold boolean?
--- @field standout boolean?
--- @field underline boolean?
--- @field undercurl boolean?
--- @field underdouble boolean?
--- @field underdotted boolean?
--- @field strikethrough boolean?
--- @field italic boolean?
--- @field reverse boolean?
--- @field nocombine boolean?

--- @class ItalicConfig
--- @field strings boolean
--- @field comments boolean
--- @field operators boolean
--- @field folds boolean
--- @field emphasis boolean

--- @class NeofusionConfig
--- @field terminal_colors boolean?
--- @field undercurl boolean?
--- @field underline boolean?
--- @field bold boolean?
--- @field italic ItalicConfig?
--- @field strikethrough boolean?
--- @field invert_selection boolean?
--- @field invert_signs boolean?
--- @field invert_tabline boolean?
--- @field invert_intend_guides boolean?
--- @field inverse boolean?
--- @field overrides table<string, HighlightDefinition>?
--- @field palette_overrides table<string, string>?

local Neofusion = {}

Neofusion.config = {
  terminal_colors = true,
  undercurl = true,
  underline = true,
  bold = true,
  italic = {
    strings = true,
    emphasis = true,
    comments = true,
    operators = false,
    folds = true,
  },
  strikethrough = true,
  invert_selection = false,
  invert_signs = false,
  invert_tabline = false,
  invert_intend_guides = false,
  inverse = true,
  contrast = "",
  palette_overrides = {},
  overrides = {},
  dim_inactive = false,
  transparent_mode = false,
}

Neofusion.palette = require("neofusion.palette")

local function get_colors()
  local palette = Neofusion.palette
  local config = Neofusion.config

  for color, hex in pairs(config.palette_overrides) do
    palette[color] = hex
  end

  local color_groups = {
    bg0 = palette.dark0,
    bg1 = palette.dark1,
    bg2 = palette.dark2,
    bg3 = palette.dark3,
    bg4 = palette.dark4,
    fg0 = palette.light0,
    fg1 = palette.light1,
    fg2 = palette.light2,
    fg3 = palette.light3,
    fg4 = palette.light4,
    red = palette.bright_red,
    green = palette.bright_green,
    yellow = palette.bright_yellow,
    blue = palette.bright_blue,
    purple = palette.bright_purple,
    aqua = palette.bright_aqua,
    orange = palette.bright_orange,
    neutral_red = palette.neutral_red,
    neutral_green = palette.neutral_green,
    neutral_yellow = palette.neutral_yellow,
    neutral_blue = palette.neutral_blue,
    neutral_purple = palette.neutral_purple,
    neutral_aqua = palette.neutral_aqua,
    dark_red = palette.dark_red,
    dark_green = palette.dark_green,
    dark_aqua = palette.dark_aqua,
    gray = palette.gray,
  }

  return color_groups
end

local function get_groups()
  local colors = get_colors()
  local config = Neofusion.config

  if config.terminal_colors then
    local term_colors = {
      colors.bg0,
      colors.neutral_red,
      colors.neutral_green,
      colors.neutral_yellow,
      colors.neutral_blue,
      colors.neutral_purple,
      colors.neutral_aqua,
      colors.fg4,
      colors.gray,
      colors.red,
      colors.green,
      colors.yellow,
      colors.blue,
      colors.purple,
      colors.aqua,
      colors.fg1,
    }

    for index, color in ipairs(term_colors) do
      vim.g["terminal_color_" .. index - 1] = color
    end
  end

  local groups = {
    -- definition
    NeofusionFg0 = { fg = colors.fg0 },
    NeofusionFg1 = { fg = colors.fg1 },
    NeofusionFg2 = { fg = colors.fg2 },
    NeofusionFg3 = { fg = colors.fg3 },
    NeofusionFg4 = { fg = colors.fg4 },
    NeofusionGray = { fg = colors.gray },
    NeofusionBg0 = { fg = colors.bg0 },
    NeofusionBg1 = { fg = colors.bg1 },
    NeofusionBg2 = { fg = colors.bg2 },
    NeofusionBg3 = { fg = colors.bg3 },
    NeofusionBg4 = { fg = colors.bg4 },
    NeofusionRed = { fg = colors.red },
    NeofusionRedBold = { fg = colors.red, bold = config.bold },
    NeofusionGreen = { fg = colors.green },
    NeofusionGreenBold = { fg = colors.green, bold = config.bold },
    NeofusionYellow = { fg = colors.yellow },
    NeofusionYellowBold = { fg = colors.yellow, bold = config.bold },
    NeofusionBlue = { fg = colors.blue },
    NeofusionBlueBold = { fg = colors.blue, bold = config.bold },
    NeofusionPurple = { fg = colors.purple },
    NeofusionPurpleBold = { fg = colors.purple, bold = config.bold },
    NeofusionAqua = { fg = colors.aqua },
    NeofusionNeutralAqua = { fg = colors.neutral_aqua },
    NeofusionAquaBold = { fg = colors.aqua, bold = config.bold },
    NeofusionOrange = { fg = colors.orange },
    NeofusionOrangeBold = { fg = colors.orange, bold = config.bold },
    NeofusionRedSign = config.transparent_mode and { fg = colors.red, reverse = config.invert_signs }
        or { fg = colors.red, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionGreenSign = config.transparent_mode and { fg = colors.green, reverse = config.invert_signs }
        or { fg = colors.green, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionYellowSign = config.transparent_mode and { fg = colors.yellow, reverse = config.invert_signs }
        or { fg = colors.yellow, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionBlueSign = config.transparent_mode and { fg = colors.blue, reverse = config.invert_signs }
        or { fg = colors.blue, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionPurpleSign = config.transparent_mode and { fg = colors.purple, reverse = config.invert_signs }
        or { fg = colors.purple, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionAquaSign = config.transparent_mode and { fg = colors.aqua, reverse = config.invert_signs }
        or { fg = colors.aqua, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionOrangeSign = config.transparent_mode and { fg = colors.orange, reverse = config.invert_signs }
        or { fg = colors.orange, bg = colors.bg0, reverse = config.invert_signs },
    NeofusionRedUnderline = { undercurl = config.undercurl, sp = colors.red },
    NeofusionGreenUnderline = { undercurl = config.undercurl, sp = colors.green },
    NeofusionYellowUnderline = { undercurl = config.undercurl, sp = colors.yellow },
    NeofusionBlueUnderline = { undercurl = config.undercurl, sp = colors.blue },
    NeofusionPurpleUnderline = { undercurl = config.undercurl, sp = colors.purple },
    NeofusionAquaUnderline = { undercurl = config.undercurl, sp = colors.aqua },
    NeofusionOrangeUnderline = { undercurl = config.undercurl, sp = colors.orange },

    --
    Normal = config.transparent_mode and { fg = colors.fg1, bg = nil } or { fg = colors.fg1, bg = colors.bg0 },
    NormalFloat = config.transparent_mode and { fg = colors.fg1, bg = nil } or { fg = colors.fg1, bg = colors.bg0 },
    NormalNC = config.dim_inactive and { fg = colors.fg0, bg = colors.bg1 } or { link = "Normal" },
    CursorLine = { bg = colors.bg1 },
    CursorColumn = { link = "CursorLine" },
    TabLineFill = { fg = colors.bg4, bg = colors.bg1, reverse = config.invert_tabline },
    TabLineSel = { fg = colors.green, bg = colors.bg1, reverse = config.invert_tabline },
    TabLine = { link = "TabLineFill" },
    MatchParen = { bg = colors.bg3, bold = config.bold },
    ColorColumn = { bg = colors.bg1 },
    Conceal = { fg = colors.blue },
    CursorLineNr = { fg = colors.yellow, bg = colors.bg1 },
    CursorLineBG = { bg = colors.bg1 },
    SagaVirtLine = { fg = colors.gray },
    NonText = { link = "NeofusionBg2" },
    SpecialKey = { link = "NeofusionFg4" },
    Visual = { bg = colors.bg3, reverse = config.invert_selection },
    VisualNOS = { link = "Visual" },
    Search = { fg = colors.yellow, bg = colors.bg0, reverse = config.inverse },
    IncSearch = { fg = colors.orange, bg = colors.bg0, reverse = config.inverse },
    CurSearch = { link = "IncSearch" },
    QuickFixLine = { link = "NeofusionPurple" },
    Underlined = { fg = colors.blue, underline = config.underline },
    StatusLine = { fg = colors.bg2, bg = colors.fg1, reverse = config.inverse },
    StatusLineNC = { fg = colors.bg1, bg = colors.fg4, reverse = config.inverse },
    WinBar = { fg = colors.fg4, bg = nil },
    WinBarNC = { fg = colors.fg3, bg = nil },
    WinSeparator = config.transparent_mode and { fg = colors.bg3, bg = nil } or { fg = colors.bg3, bg = colors.bg0 },
    WildMenu = { fg = colors.blue, bg = colors.bg2, bold = config.bold },
    Directory = { link = "NeofusionBlueBold" },
    Title = { link = "NeofusionGreenBold" },
    ErrorMsg = { fg = colors.bg0, bg = colors.red, bold = config.bold },
    MoreMsg = { link = "NeofusionYellowBold" },
    ModeMsg = { link = "NeofusionYellowBold" },
    Question = { link = "NeofusionOrangeBold" },
    WarningMsg = { link = "NeofusionRedBold" },
    LineNr = { fg = colors.bg4 },
    SignColumn = config.transparent_mode and { bg = nil } or { bg = colors.bg0 },
    Folded = { fg = colors.gray, bg = colors.bg1, italic = config.italic.folds },
    FoldColumn = config.transparent_mode and { fg = colors.gray, bg = nil } or { fg = colors.gray, bg = colors.bg1 },
    Cursor = { reverse = config.inverse },
    vCursor = { link = "Cursor" },
    iCursor = { link = "Cursor" },
    lCursor = { link = "Cursor" },
    Special = { link = "NeofusionOrange" },
    Comment = { fg = colors.gray, italic = config.italic.comments },
    Todo = { fg = colors.bg0, bg = colors.yellow, bold = config.bold, italic = config.italic.comments },
    Done = { fg = colors.orange, bold = config.bold, italic = config.italic.comments },
    Error = { fg = colors.red, bold = config.bold, reverse = config.inverse },
    Statement = { link = "NeofusionRed" },
    Conditional = { link = "NeofusionRed" },
    Repeat = { link = "NeofusionRed" },
    Label = { link = "NeofusionRed" },
    Exception = { link = "NeofusionRed" },
    Operator = { fg = colors.orange, italic = config.italic.operators },
    Keyword = { link = "NeofusionRed" },
    Identifier = { link = "NeofusionNeutralAqua" },
    Function = { link = "NeofusionGreenBold" },
    PreProc = { link = "NeofusionAqua" },
    Include = { link = "NeofusionAqua" },
    Define = { link = "NeofusionAqua" },
    Macro = { link = "NeofusionAqua" },
    PreCondit = { link = "NeofusionAqua" },
    Constant = { link = "NeofusionPurple" },
    Character = { link = "NeofusionPurple" },
    String = { fg = colors.green, italic = config.italic.strings },
    Boolean = { link = "NeofusionPurple" },
    Number = { link = "NeofusionPurple" },
    Float = { link = "NeofusionPurple" },
    Type = { link = "NeofusionYellow" },
    StorageClass = { link = "NeofusionOrange" },
    Structure = { link = "NeofusionAqua" },
    Typedef = { link = "NeofusionYellow" },
    Pmenu = { fg = colors.fg1, bg = colors.bg2 },
    PmenuSel = { fg = colors.bg2, bg = colors.blue, bold = config.bold },
    PmenuSbar = { bg = colors.bg2 },
    PmenuThumb = { bg = colors.bg4 },
    DiffDelete = { bg = colors.dark_red },
    DiffAdd = { bg = colors.dark_green },
    DiffChange = { bg = colors.dark_aqua },
    DiffText = { bg = colors.yellow, fg = colors.bg0 },
    SpellCap = { link = "NeofusionBlueUnderline" },
    SpellBad = { link = "NeofusionRedUnderline" },
    SpellLocal = { link = "NeofusionAquaUnderline" },
    SpellRare = { link = "NeofusionPurpleUnderline" },
    Whitespace = { fg = colors.bg2 },
    Delimiter = { link = "NeofusionOrange" },
    EndOfBuffer = { link = "NonText" },
    DiagnosticError = { link = "NeofusionRed" },
    DiagnosticSignError = { link = "NeofusionRedSign" },
    DiagnosticUnderlineError = { link = "NeofusionRedUnderline" },
    DiagnosticWarn = { link = "NeofusionYellow" },
    DiagnosticSignWarn = { link = "NeofusionYellowSign" },
    DiagnosticUnderlineWarn = { link = "NeofusionYellowUnderline" },
    DiagnosticInfo = { link = "NeofusionGreen" },
    DiagnosticSignInfo = { link = "NeofusionBlueSign" },
    DiagnosticUnderlineInfo = { link = "NeofusionBlueUnderline" },
    DiagnosticHint = { link = "NeofusionAqua" },
    DiagnosticSignHint = { link = "NeofusionAquaSign" },
    DiagnosticUnderlineHint = { link = "NeofusionAquaUnderline" },
    DiagnosticFloatingError = { link = "NeofusionRed" },
    DiagnosticFloatingWarn = { link = "NeofusionOrange" },
    DiagnosticFloatingInfo = { link = "NeofusionBlue" },
    DiagnosticFloatingHint = { link = "NeofusionAqua" },
    DiagnosticVirtualTextError = { link = "NeofusionRed" },
    DiagnosticVirtualTextWarn = { link = "NeofusionYellow" },
    DiagnosticVirtualTextInfo = { link = "NeofusionBlue" },
    DiagnosticVirtualTextHint = { link = "NeofusionAqua" },
    DiagnosticOk = { link = "NeofusionGreenSign" },
    LspReferenceRead = { link = "NeofusionYellowBold" },
    LspReferenceText = { link = "NeofusionYellowBold" },
    LspReferenceWrite = { link = "NeofusionOrangeBold" },
    LspCodeLens = { link = "NeofusionGray" },
    LspSignatureActiveParameter = { link = "Search" },
    gitcommitSelectedFile = { link = "NeofusionGreen" },
    gitcommitDiscardedFile = { link = "NeofusionRed" },
    GitSignsAdd = { link = "NeofusionGreen" },
    GitSignsChange = { link = "NeofusionAqua" },
    GitSignsDelete = { link = "NeofusionRed" },
    NvimTreeSymlink = { fg = colors.neutral_aqua },
    NvimTreeRootFolder = { fg = colors.neutral_purple, bold = true },
    NvimTreeFolderIcon = { fg = colors.neutral_blue, bold = true },
    NvimTreeFileIcon = { fg = colors.light2 },
    NvimTreeExecFile = { fg = colors.neutral_green, bold = true },
    NvimTreeOpenedFile = { fg = colors.bright_red, bold = true },
    NvimTreeSpecialFile = { fg = colors.neutral_yellow, bold = true, underline = true },
    NvimTreeImageFile = { fg = colors.neutral_purple },
    NvimTreeIndentMarker = { fg = colors.dark3 },
    NvimTreeGitDirty = { fg = colors.neutral_yellow },
    NvimTreeGitStaged = { fg = colors.neutral_yellow },
    NvimTreeGitMerge = { fg = colors.neutral_purple },
    NvimTreeGitRenamed = { fg = colors.neutral_purple },
    NvimTreeGitNew = { fg = colors.neutral_yellow },
    NvimTreeGitDeleted = { fg = colors.neutral_red },
    NvimTreeWindowPicker = { bg = colors.aqua },
    TelescopePromptCounter = { fg = colors.red },
    debugPC = { link = "DiffAdd" },
    debugBreakpoint = { link = "NeofusionRedSign" },
    StartifyBracket = { link = "NeofusionFg3" },
    StartifyFile = { link = "NeofusionFg1" },
    StartifyNumber = { link = "NeofusionBlue" },
    StartifyPath = { link = "NeofusionGray" },
    StartifySlash = { link = "NeofusionGray" },
    StartifySection = { link = "NeofusionYellow" },
    StartifySpecial = { link = "NeofusionBg2" },
    StartifyHeader = { link = "NeofusionOrange" },
    StartifyFooter = { link = "NeofusionBg2" },
    StartifyVar = { link = "StartifyPath" },
    StartifySelect = { link = "Title" },
    DirvishPathTail = { link = "NeofusionAqua" },
    DirvishArg = { link = "NeofusionYellow" },
    netrwDir = { link = "NeofusionAqua" },
    netrwClassify = { link = "NeofusionAqua" },
    netrwLink = { link = "NeofusionGray" },
    netrwSymLink = { link = "NeofusionFg1" },
    netrwExe = { link = "NeofusionYellow" },
    netrwComment = { link = "NeofusionGray" },
    netrwList = { link = "NeofusionBlue" },
    netrwHelpCmd = { link = "NeofusionAqua" },
    netrwCmdSep = { link = "NeofusionFg3" },
    netrwVersion = { link = "NeofusionGreen" },
    NERDTreeDir = { link = "NeofusionAqua" },
    NERDTreeDirSlash = { link = "NeofusionAqua" },
    NERDTreeOpenable = { link = "NeofusionOrange" },
    NERDTreeClosable = { link = "NeofusionOrange" },
    NERDTreeFile = { link = "NeofusionFg1" },
    NERDTreeExecFile = { link = "NeofusionYellow" },
    NERDTreeUp = { link = "NeofusionGray" },
    NERDTreeCWD = { link = "NeofusionGreen" },
    NERDTreeHelp = { link = "NeofusionFg1" },
    NERDTreeToggleOn = { link = "NeofusionGreen" },
    NERDTreeToggleOff = { link = "NeofusionRed" },
    CocErrorSign = { link = "NeofusionRedSign" },
    CocWarningSign = { link = "NeofusionOrangeSign" },
    CocInfoSign = { link = "NeofusionBlueSign" },
    CocHintSign = { link = "NeofusionAquaSign" },
    CocErrorFloat = { link = "NeofusionRed" },
    CocWarningFloat = { link = "NeofusionOrange" },
    CocInfoFloat = { link = "NeofusionBlue" },
    CocHintFloat = { link = "NeofusionAqua" },
    CocDiagnosticsError = { link = "NeofusionRed" },
    CocDiagnosticsWarning = { link = "NeofusionOrange" },
    CocDiagnosticsInfo = { link = "NeofusionBlue" },
    CocDiagnosticsHint = { link = "NeofusionAqua" },
    CocSelectedText = { link = "NeofusionRed" },
    CocMenuSel = { link = "PmenuSel" },
    CocCodeLens = { link = "NeofusionGray" },
    CocErrorHighlight = { link = "NeofusionRedUnderline" },
    CocWarningHighlight = { link = "NeofusionOrangeUnderline" },
    CocInfoHighlight = { link = "NeofusionBlueUnderline" },
    CocHintHighlight = { link = "NeofusionAquaUnderline" },
    TelescopeNormal = { link = "NeofusionFg1" },
    TelescopeSelection = { link = "NeofusionOrangeBold" },
    TelescopeSelectionCaret = { link = "NeofusionRed" },
    TelescopeMultiSelection = { link = "NeofusionGray" },
    TelescopeBorder = { link = "TelescopeNormal" },
    TelescopePromptBorder = { link = "TelescopeNormal" },
    TelescopeResultsBorder = { link = "TelescopeNormal" },
    TelescopePreviewBorder = { link = "TelescopeNormal" },
    TelescopeMatching = { link = "NeofusionBlue" },
    TelescopePromptPrefix = { link = "NeofusionRed" },
    TelescopePrompt = { link = "TelescopeNormal" },
    CmpItemAbbr = { link = "NeofusionFg0" },
    CmpItemAbbrDeprecated = { link = "NeofusionFg1" },
    CmpItemAbbrMatch = { link = "NeofusionBlueBold" },
    CmpItemAbbrMatchFuzzy = { link = "NeofusionBlueUnderline" },
    CmpItemMenu = { link = "NeofusionGray" },
    CmpItemKindText = { link = "NeofusionOrange" },
    CmpItemKindVariable = { link = "NeofusionOrange" },
    CmpItemKindMethod = { link = "NeofusionBlue" },
    CmpItemKindFunction = { link = "NeofusionBlue" },
    CmpItemKindConstructor = { link = "NeofusionYellow" },
    CmpItemKindUnit = { link = "NeofusionBlue" },
    CmpItemKindField = { link = "NeofusionBlue" },
    CmpItemKindClass = { link = "NeofusionYellow" },
    CmpItemKindInterface = { link = "NeofusionYellow" },
    CmpItemKindModule = { link = "NeofusionBlue" },
    CmpItemKindProperty = { link = "NeofusionBlue" },
    CmpItemKindValue = { link = "NeofusionOrange" },
    CmpItemKindEnum = { link = "NeofusionYellow" },
    CmpItemKindOperator = { link = "NeofusionYellow" },
    CmpItemKindKeyword = { link = "NeofusionPurple" },
    CmpItemKindEvent = { link = "NeofusionPurple" },
    CmpItemKindReference = { link = "NeofusionPurple" },
    CmpItemKindColor = { link = "NeofusionPurple" },
    CmpItemKindSnippet = { link = "NeofusionGreen" },
    CmpItemKindFile = { link = "NeofusionBlue" },
    CmpItemKindFolder = { link = "NeofusionBlue" },
    CmpItemKindEnumMember = { link = "NeofusionAqua" },
    CmpItemKindConstant = { link = "NeofusionOrange" },
    CmpItemKindStruct = { link = "NeofusionYellow" },
    CmpItemKindTypeParameter = { link = "NeofusionYellow" },
    diffAdded = { link = "DiffAdd" },
    diffRemoved = { link = "DiffDelete" },
    diffChanged = { link = "DiffChange" },
    diffFile = { link = "NeofusionOrange" },
    diffNewFile = { link = "NeofusionYellow" },
    diffOldFile = { link = "NeofusionOrange" },
    diffLine = { link = "NeofusionBlue" },
    diffIndexLine = { link = "diffChanged" },
    NavicIconsFile = { link = "NeofusionBlue" },
    NavicIconsModule = { link = "NeofusionOrange" },
    NavicIconsNamespace = { link = "NeofusionBlue" },
    NavicIconsPackage = { link = "NeofusionAqua" },
    NavicIconsClass = { link = "NeofusionYellow" },
    NavicIconsMethod = { link = "NeofusionBlue" },
    NavicIconsProperty = { link = "NeofusionAqua" },
    NavicIconsField = { link = "NeofusionPurple" },
    NavicIconsConstructor = { link = "NeofusionBlue" },
    NavicIconsEnum = { link = "NeofusionPurple" },
    NavicIconsInterface = { link = "NeofusionGreen" },
    NavicIconsFunction = { link = "NeofusionBlue" },
    NavicIconsVariable = { link = "NeofusionPurple" },
    NavicIconsConstant = { link = "NeofusionOrange" },
    NavicIconsString = { link = "NeofusionGreen" },
    NavicIconsNumber = { link = "NeofusionOrange" },
    NavicIconsBoolean = { link = "NeofusionOrange" },
    NavicIconsArray = { link = "NeofusionOrange" },
    NavicIconsObject = { link = "NeofusionOrange" },
    NavicIconsKey = { link = "NeofusionAqua" },
    NavicIconsNull = { link = "NeofusionOrange" },
    NavicIconsEnumMember = { link = "NeofusionYellow" },
    NavicIconsStruct = { link = "NeofusionPurple" },
    NavicIconsEvent = { link = "NeofusionYellow" },
    NavicIconsOperator = { link = "NeofusionRed" },
    NavicIconsTypeParameter = { link = "NeofusionRed" },
    NavicText = { link = "NeofusionWhite" },
    NavicSeparator = { link = "NeofusionWhite" },
    htmlTag = { link = "NeofusionAquaBold" },
    htmlEndTag = { link = "NeofusionAquaBold" },
    htmlTagName = { link = "NeofusionBlue" },
    htmlArg = { link = "NeofusionOrange" },
    htmlTagN = { link = "NeofusionFg1" },
    htmlSpecialTagName = { link = "NeofusionBlue" },
    htmlLink = { fg = colors.fg4, underline = config.underline },
    htmlSpecialChar = { link = "NeofusionRed" },
    htmlBold = { fg = colors.fg0, bg = colors.bg0, bold = config.bold },
    htmlBoldUnderline = { fg = colors.fg0, bg = colors.bg0, bold = config.bold, underline = config.underline },
    htmlBoldItalic = { fg = colors.fg0, bg = colors.bg0, bold = config.bold, italic = true },
    htmlBoldUnderlineItalic = {
      fg = colors.fg0,
      bg = colors.bg0,
      bold = config.bold,
      italic = true,
      underline = config.underline,
    },
    htmlUnderline = { fg = colors.fg0, bg = colors.bg0, underline = config.underline },
    htmlUnderlineItalic = {
      fg = colors.fg0,
      bg = colors.bg0,
      italic = true,
      underline = config.underline,
    },
    htmlItalic = { fg = colors.fg0, bg = colors.bg0, italic = true },
    xmlTag = { link = "NeofusionAquaBold" },
    xmlEndTag = { link = "NeofusionAquaBold" },
    xmlTagName = { link = "NeofusionBlue" },
    xmlEqual = { link = "NeofusionBlue" },
    docbkKeyword = { link = "NeofusionAquaBold" },
    xmlDocTypeDecl = { link = "NeofusionGray" },
    xmlDocTypeKeyword = { link = "NeofusionPurple" },
    xmlCdataStart = { link = "NeofusionGray" },
    xmlCdataCdata = { link = "NeofusionPurple" },
    dtdFunction = { link = "NeofusionGray" },
    dtdTagName = { link = "NeofusionPurple" },
    xmlAttrib = { link = "NeofusionOrange" },
    xmlProcessingDelim = { link = "NeofusionGray" },
    dtdParamEntityPunct = { link = "NeofusionGray" },
    dtdParamEntityDPunct = { link = "NeofusionGray" },
    xmlAttribPunct = { link = "NeofusionGray" },
    xmlEntity = { link = "NeofusionRed" },
    xmlEntityPunct = { link = "NeofusionRed" },
    clojureKeyword = { link = "NeofusionBlue" },
    clojureCond = { link = "NeofusionOrange" },
    clojureSpecial = { link = "NeofusionOrange" },
    clojureDefine = { link = "NeofusionOrange" },
    clojureFunc = { link = "NeofusionYellow" },
    clojureRepeat = { link = "NeofusionYellow" },
    clojureCharacter = { link = "NeofusionAqua" },
    clojureStringEscape = { link = "NeofusionAqua" },
    clojureException = { link = "NeofusionRed" },
    clojureRegexp = { link = "NeofusionAqua" },
    clojureRegexpEscape = { link = "NeofusionAqua" },
    clojureRegexpCharClass = { fg = colors.fg3, bold = config.bold },
    clojureRegexpMod = { link = "clojureRegexpCharClass" },
    clojureRegexpQuantifier = { link = "clojureRegexpCharClass" },
    clojureParen = { link = "NeofusionFg3" },
    clojureAnonArg = { link = "NeofusionYellow" },
    clojureVariable = { link = "NeofusionBlue" },
    clojureMacro = { link = "NeofusionOrange" },
    clojureMeta = { link = "NeofusionYellow" },
    clojureDeref = { link = "NeofusionYellow" },
    clojureQuote = { link = "NeofusionYellow" },
    clojureUnquote = { link = "NeofusionYellow" },
    cOperator = { link = "NeofusionPurple" },
    cppOperator = { link = "NeofusionPurple" },
    cStructure = { link = "NeofusionOrange" },
    pythonBuiltin = { link = "NeofusionOrange" },
    pythonBuiltinObj = { link = "NeofusionOrange" },
    pythonBuiltinFunc = { link = "NeofusionOrange" },
    pythonFunction = { link = "NeofusionAqua" },
    pythonDecorator = { link = "NeofusionRed" },
    pythonInclude = { link = "NeofusionBlue" },
    pythonImport = { link = "NeofusionBlue" },
    pythonRun = { link = "NeofusionBlue" },
    pythonCoding = { link = "NeofusionBlue" },
    pythonOperator = { link = "NeofusionRed" },
    pythonException = { link = "NeofusionRed" },
    pythonExceptions = { link = "NeofusionPurple" },
    pythonBoolean = { link = "NeofusionPurple" },
    pythonDot = { link = "NeofusionFg3" },
    pythonConditional = { link = "NeofusionRed" },
    pythonRepeat = { link = "NeofusionRed" },
    pythonDottedName = { link = "NeofusionGreenBold" },
    cssBraces = { link = "NeofusionBlue" },
    cssFunctionName = { link = "NeofusionYellow" },
    cssIdentifier = { link = "NeofusionOrange" },
    cssClassName = { link = "NeofusionGreen" },
    cssColor = { link = "NeofusionBlue" },
    cssSelectorOp = { link = "NeofusionBlue" },
    cssSelectorOp2 = { link = "NeofusionBlue" },
    cssImportant = { link = "NeofusionGreen" },
    cssVendor = { link = "NeofusionFg1" },
    cssTextProp = { link = "NeofusionAqua" },
    cssAnimationProp = { link = "NeofusionAqua" },
    cssUIProp = { link = "NeofusionYellow" },
    cssTransformProp = { link = "NeofusionAqua" },
    cssTransitionProp = { link = "NeofusionAqua" },
    cssPrintProp = { link = "NeofusionAqua" },
    cssPositioningProp = { link = "NeofusionYellow" },
    cssBoxProp = { link = "NeofusionAqua" },
    cssFontDescriptorProp = { link = "NeofusionAqua" },
    cssFlexibleBoxProp = { link = "NeofusionAqua" },
    cssBorderOutlineProp = { link = "NeofusionAqua" },
    cssBackgroundProp = { link = "NeofusionAqua" },
    cssMarginProp = { link = "NeofusionAqua" },
    cssListProp = { link = "NeofusionAqua" },
    cssTableProp = { link = "NeofusionAqua" },
    cssFontProp = { link = "NeofusionAqua" },
    cssPaddingProp = { link = "NeofusionAqua" },
    cssDimensionProp = { link = "NeofusionAqua" },
    cssRenderProp = { link = "NeofusionAqua" },
    cssColorProp = { link = "NeofusionAqua" },
    cssGeneratedContentProp = { link = "NeofusionAqua" },
    javaScriptBraces = { link = "NeofusionFg1" },
    javaScriptFunction = { link = "NeofusionAqua" },
    javaScriptIdentifier = { link = "NeofusionRed" },
    javaScriptMember = { link = "NeofusionBlue" },
    javaScriptNumber = { link = "NeofusionPurple" },
    javaScriptNull = { link = "NeofusionPurple" },
    javaScriptParens = { link = "NeofusionFg3" },
    typescriptReserved = { link = "NeofusionAqua" },
    typescriptLabel = { link = "NeofusionAqua" },
    typescriptFuncKeyword = { link = "NeofusionAqua" },
    typescriptIdentifier = { link = "NeofusionOrange" },
    typescriptBraces = { link = "NeofusionFg1" },
    typescriptEndColons = { link = "NeofusionFg1" },
    typescriptDOMObjects = { link = "NeofusionFg1" },
    typescriptAjaxMethods = { link = "NeofusionFg1" },
    typescriptLogicSymbols = { link = "NeofusionFg1" },
    typescriptDocSeeTag = { link = "Comment" },
    typescriptDocParam = { link = "Comment" },
    typescriptDocTags = { link = "vimCommentTitle" },
    typescriptGlobalObjects = { link = "NeofusionFg1" },
    typescriptParens = { link = "NeofusionFg3" },
    typescriptOpSymbols = { link = "NeofusionFg3" },
    typescriptHtmlElemProperties = { link = "NeofusionFg1" },
    typescriptNull = { link = "NeofusionPurple" },
    typescriptInterpolationDelimiter = { link = "NeofusionAqua" },
    purescriptModuleKeyword = { link = "NeofusionAqua" },
    purescriptModuleName = { link = "NeofusionFg1" },
    purescriptWhere = { link = "NeofusionAqua" },
    purescriptDelimiter = { link = "NeofusionFg4" },
    purescriptType = { link = "NeofusionFg1" },
    purescriptImportKeyword = { link = "NeofusionAqua" },
    purescriptHidingKeyword = { link = "NeofusionAqua" },
    purescriptAsKeyword = { link = "NeofusionAqua" },
    purescriptStructure = { link = "NeofusionAqua" },
    purescriptOperator = { link = "NeofusionBlue" },
    purescriptTypeVar = { link = "NeofusionFg1" },
    purescriptConstructor = { link = "NeofusionFg1" },
    purescriptFunction = { link = "NeofusionFg1" },
    purescriptConditional = { link = "NeofusionOrange" },
    purescriptBacktick = { link = "NeofusionOrange" },
    coffeeExtendedOp = { link = "NeofusionFg3" },
    coffeeSpecialOp = { link = "NeofusionFg3" },
    coffeeCurly = { link = "NeofusionOrange" },
    coffeeParen = { link = "NeofusionFg3" },
    coffeeBracket = { link = "NeofusionOrange" },
    rubyStringDelimiter = { link = "NeofusionGreen" },
    rubyInterpolationDelimiter = { link = "NeofusionAqua" },
    rubyDefinedOperator = { link = "rubyKeyword" },
    objcTypeModifier = { link = "NeofusionRed" },
    objcDirective = { link = "NeofusionBlue" },
    goDirective = { link = "NeofusionAqua" },
    goConstants = { link = "NeofusionPurple" },
    goDeclaration = { link = "NeofusionRed" },
    goDeclType = { link = "NeofusionBlue" },
    goBuiltins = { link = "NeofusionOrange" },
    luaIn = { link = "NeofusionRed" },
    luaFunction = { link = "NeofusionAqua" },
    luaTable = { link = "NeofusionOrange" },
    moonSpecialOp = { link = "NeofusionFg3" },
    moonExtendedOp = { link = "NeofusionFg3" },
    moonFunction = { link = "NeofusionFg3" },
    moonObject = { link = "NeofusionYellow" },
    javaAnnotation = { link = "NeofusionBlue" },
    javaDocTags = { link = "NeofusionAqua" },
    javaCommentTitle = { link = "vimCommentTitle" },
    javaParen = { link = "NeofusionFg3" },
    javaParen1 = { link = "NeofusionFg3" },
    javaParen2 = { link = "NeofusionFg3" },
    javaParen3 = { link = "NeofusionFg3" },
    javaParen4 = { link = "NeofusionFg3" },
    javaParen5 = { link = "NeofusionFg3" },
    javaOperator = { link = "NeofusionOrange" },
    javaVarArg = { link = "NeofusionGreen" },
    elixirDocString = { link = "Comment" },
    elixirStringDelimiter = { link = "NeofusionGreen" },
    elixirInterpolationDelimiter = { link = "NeofusionAqua" },
    elixirModuleDeclaration = { link = "NeofusionYellow" },
    scalaNameDefinition = { link = "NeofusionFg1" },
    scalaCaseFollowing = { link = "NeofusionFg1" },
    scalaCapitalWord = { link = "NeofusionFg1" },
    scalaTypeExtension = { link = "NeofusionFg1" },
    scalaKeyword = { link = "NeofusionRed" },
    scalaKeywordModifier = { link = "NeofusionRed" },
    scalaSpecial = { link = "NeofusionAqua" },
    scalaOperator = { link = "NeofusionFg1" },
    scalaTypeDeclaration = { link = "NeofusionYellow" },
    scalaTypeTypePostDeclaration = { link = "NeofusionYellow" },
    scalaInstanceDeclaration = { link = "NeofusionFg1" },
    scalaInterpolation = { link = "NeofusionAqua" },
    markdownItalic = { fg = colors.fg3, italic = true },
    markdownBold = { fg = colors.fg3, bold = config.bold },
    markdownBoldItalic = { fg = colors.fg3, bold = config.bold, italic = true },
    markdownH1 = { link = "NeofusionGreenBold" },
    markdownH2 = { link = "NeofusionGreenBold" },
    markdownH3 = { link = "NeofusionYellowBold" },
    markdownH4 = { link = "NeofusionYellowBold" },
    markdownH5 = { link = "NeofusionYellow" },
    markdownH6 = { link = "NeofusionYellow" },
    markdownCode = { link = "NeofusionAqua" },
    markdownCodeBlock = { link = "NeofusionAqua" },
    markdownCodeDelimiter = { link = "NeofusionAqua" },
    markdownBlockquote = { link = "NeofusionGray" },
    markdownListMarker = { link = "NeofusionGray" },
    markdownOrderedListMarker = { link = "NeofusionGray" },
    markdownRule = { link = "NeofusionGray" },
    markdownHeadingRule = { link = "NeofusionGray" },
    markdownUrlDelimiter = { link = "NeofusionFg3" },
    markdownLinkDelimiter = { link = "NeofusionFg3" },
    markdownLinkTextDelimiter = { link = "NeofusionFg3" },
    markdownHeadingDelimiter = { link = "NeofusionOrange" },
    markdownUrl = { link = "NeofusionPurple" },
    markdownUrlTitleDelimiter = { link = "NeofusionGreen" },
    markdownLinkText = { fg = colors.gray, underline = config.underline },
    markdownIdDeclaration = { link = "markdownLinkText" },
    haskellType = { link = "NeofusionBlue" },
    haskellIdentifier = { link = "NeofusionAqua" },
    haskellSeparator = { link = "NeofusionFg4" },
    haskellDelimiter = { link = "NeofusionOrange" },
    haskellOperators = { link = "NeofusionPurple" },
    haskellBacktick = { link = "NeofusionOrange" },
    haskellStatement = { link = "NeofusionPurple" },
    haskellConditional = { link = "NeofusionPurple" },
    haskellLet = { link = "NeofusionRed" },
    haskellDefault = { link = "NeofusionRed" },
    haskellWhere = { link = "NeofusionRed" },
    haskellBottom = { link = "NeofusionRedBold" },
    haskellImportKeywords = { link = "NeofusionPurpleBold" },
    haskellDeclKeyword = { link = "NeofusionOrange" },
    haskellDecl = { link = "NeofusionOrange" },
    haskellDeriving = { link = "NeofusionPurple" },
    haskellAssocType = { link = "NeofusionAqua" },
    haskellNumber = { link = "NeofusionAqua" },
    haskellPragma = { link = "NeofusionRedBold" },
    haskellTH = { link = "NeofusionAquaBold" },
    haskellForeignKeywords = { link = "NeofusionGreen" },
    haskellKeyword = { link = "NeofusionRed" },
    haskellFloat = { link = "NeofusionAqua" },
    haskellInfix = { link = "NeofusionPurple" },
    haskellQuote = { link = "NeofusionGreenBold" },
    haskellShebang = { link = "NeofusionYellowBold" },
    haskellLiquid = { link = "NeofusionPurpleBold" },
    haskellQuasiQuoted = { link = "NeofusionBlueBold" },
    haskellRecursiveDo = { link = "NeofusionPurple" },
    haskellQuotedType = { link = "NeofusionRed" },
    haskellPreProc = { link = "NeofusionFg4" },
    haskellTypeRoles = { link = "NeofusionRedBold" },
    haskellTypeForall = { link = "NeofusionRed" },
    haskellPatternKeyword = { link = "NeofusionBlue" },
    jsonKeyword = { link = "NeofusionGreen" },
    jsonQuote = { link = "NeofusionGreen" },
    jsonBraces = { link = "NeofusionFg1" },
    jsonString = { link = "NeofusionFg1" },
    mailQuoted1 = { link = "NeofusionAqua" },
    mailQuoted2 = { link = "NeofusionPurple" },
    mailQuoted3 = { link = "NeofusionYellow" },
    mailQuoted4 = { link = "NeofusionGreen" },
    mailQuoted5 = { link = "NeofusionRed" },
    mailQuoted6 = { link = "NeofusionOrange" },
    mailSignature = { link = "Comment" },
    csBraces = { link = "NeofusionFg1" },
    csEndColon = { link = "NeofusionFg1" },
    csLogicSymbols = { link = "NeofusionFg1" },
    csParens = { link = "NeofusionFg3" },
    csOpSymbols = { link = "NeofusionFg3" },
    csInterpolationDelimiter = { link = "NeofusionFg3" },
    csInterpolationAlignDel = { link = "NeofusionAquaBold" },
    csInterpolationFormat = { link = "NeofusionAqua" },
    csInterpolationFormatDel = { link = "NeofusionAquaBold" },
    rustSigil = { link = "NeofusionOrange" },
    rustEscape = { link = "NeofusionAqua" },
    rustStringContinuation = { link = "NeofusionAqua" },
    rustEnum = { link = "NeofusionAqua" },
    rustStructure = { link = "NeofusionAqua" },
    rustModPathSep = { link = "NeofusionFg2" },
    rustCommentLineDoc = { link = "Comment" },
    rustDefault = { link = "NeofusionAqua" },
    ocamlOperator = { link = "NeofusionFg1" },
    ocamlKeyChar = { link = "NeofusionOrange" },
    ocamlArrow = { link = "NeofusionOrange" },
    ocamlInfixOpKeyword = { link = "NeofusionRed" },
    ocamlConstructor = { link = "NeofusionOrange" },
    LspSagaCodeActionTitle = { link = "Title" },
    LspSagaCodeActionBorder = { link = "NeofusionFg1" },
    LspSagaCodeActionContent = { fg = colors.green, bold = config.bold },
    LspSagaLspFinderBorder = { link = "NeofusionFg1" },
    LspSagaAutoPreview = { link = "NeofusionOrange" },
    TargetWord = { fg = colors.blue, bold = config.bold },
    FinderSeparator = { link = "NeofusionAqua" },
    FidgetTask = { fg = colors.gray },
    LspSagaDefPreviewBorder = { link = "NeofusionBlue" },
    LspSagaHoverBorder = { link = "NeofusionOrange" },
    LspSagaRenameBorder = { link = "NeofusionBlue" },
    LspSagaDiagnosticSource = { link = "NeofusionOrange" },
    LspSagaDiagnosticBorder = { link = "NeofusionPurple" },
    LspSagaDiagnosticHeader = { link = "NeofusionGreen" },
    LspSagaSignatureHelpBorder = { link = "NeofusionGreen" },
    SagaShadow = { link = "NeofusionBg0" },
    DashboardShortCut = { link = "NeofusionOrange" },
    DashboardHeader = { link = "NeofusionAqua" },
    DashboardCenter = { link = "NeofusionYellow" },
    DashboardFooter = { fg = colors.purple, italic = true },
    MasonHighlight = { link = "NeofusionAqua" },
    MasonHighlightBlock = { fg = colors.bg0, bg = colors.blue },
    MasonHighlightBlockBold = { fg = colors.bg0, bg = colors.blue, bold = true },
    MasonHighlightSecondary = { fg = colors.yellow },
    MasonHighlightBlockSecondary = { fg = colors.bg0, bg = colors.yellow },
    MasonHighlightBlockBoldSecondary = { fg = colors.bg0, bg = colors.yellow, bold = true },
    MasonHeader = { link = "MasonHighlightBlockBoldSecondary" },
    MasonHeaderSecondary = { link = "MasonHighlightBlockBold" },
    MasonMuted = { fg = colors.fg4 },
    MasonMutedBlock = { fg = colors.bg0, bg = colors.fg4 },
    MasonMutedBlockBold = { fg = colors.bg0, bg = colors.fg4, bold = true },
    LspInlayHint = { link = "comment" },
    CarbonFile = { link = "NeofusionFg1" },
    CarbonExe = { link = "NeofusionYellow" },
    CarbonSymlink = { link = "NeofusionAqua" },
    CarbonBrokenSymlink = { link = "NeofusionRed" },
    CarbonIndicator = { link = "NeofusionGray" },
    CarbonDanger = { link = "NeofusionRed" },
    CarbonPending = { link = "NeofusionYellow" },
    NoiceCursor = { link = "TermCursor" },
    NotifyDEBUGBorder = { link = "NeofusionBlue" },
    NotifyDEBUGIcon = { link = "NeofusionBlue" },
    NotifyDEBUGTitle = { link = "NeofusionBlue" },
    NotifyERRORBorder = { link = "NeofusionRed" },
    NotifyERRORIcon = { link = "NeofusionRed" },
    NotifyERRORTitle = { link = "NeofusionRed" },
    NotifyINFOBorder = { link = "NeofusionAqua" },
    NotifyINFOIcon = { link = "NeofusionAqua" },
    NotifyINFOTitle = { link = "NeofusionAqua" },
    NotifyTRACEBorder = { link = "NeofusionGreen" },
    NotifyTRACEIcon = { link = "NeofusionGreen" },
    NotifyTRACETitle = { link = "NeofusionGreen" },
    NotifyWARNBorder = { link = "NeofusionYellow" },
    NotifyWARNIcon = { link = "NeofusionYellow" },
    NotifyWARNTitle = { link = "NeofusionYellow" },
    GitSignsCurrentLineBlame = { fg = colors.gray },
    IlluminatedWordText = { link = "LspReferenceText" },
    IlluminatedWordRead = { link = "LspReferenceRead" },
    IlluminatedWordWrite = { link = "LspReferenceWrite" },
    TSRainbowRed = { fg = colors.red },
    TSRainbowOrange = { fg = colors.orange },
    TSRainbowYellow = { fg = colors.yellow },
    TSRainbowGreen = { fg = colors.green },
    TSRainbowBlue = { fg = colors.blue },
    TSRainbowViolet = { fg = colors.purple },
    TSRainbowCyan = { fg = colors.cyan },
    RainbowDelimiterRed = { fg = colors.red },
    RainbowDelimiterOrange = { fg = colors.purple },
    RainbowDelimiterYellow = { fg = colors.aqua },
    RainbowDelimiterGreen = { fg = colors.fg2 },
    RainbowDelimiterBlue = { fg = colors.green },
    RainbowDelimiterViolet = { fg = colors.orange },
    RainbowDelimiterCyan = { fg = colors.fg0 },
    DapBreakpointSymbol = { fg = colors.red, bg = colors.bg1 },
    DapStoppedSymbol = { fg = colors.green, bg = colors.bg1 },
    DapUIBreakpointsCurrentLine = { link = "NeofusionYellow" },
    DapUIBreakpointsDisabledLine = { link = "NeofusionGray" },
    DapUIBreakpointsInfo = { link = "NeofusionAqua" },
    DapUIBreakpointsLine = { link = "NeofusionYellow" },
    DapUIBreakpointsPath = { link = "NeofusionBlue" },
    DapUICurrentFrameName = { link = "NeofusionPurple" },
    DapUIDecoration = { link = "NeofusionPurple" },
    DapUIEndofBuffer = { link = "EndOfBuffer" },
    DapUIFloatBorder = { link = "NeofusionAqua" },
    DapUILineNumber = { link = "NeofusionYellow" },
    DapUIModifiedValue = { link = "NeofusionRed" },
    DapUIPlayPause = { fg = colors.green, bg = colors.bg1 },
    DapUIRestart = { fg = colors.green, bg = colors.bg1 },
    DapUIScope = { link = "NeofusionBlue" },
    DapUISource = { link = "NeofusionFg1" },
    DapUIStepBack = { fg = colors.blue, bg = colors.bg1 },
    DapUIStepInto = { fg = colors.blue, bg = colors.bg1 },
    DapUIStepOut = { fg = colors.blue, bg = colors.bg1 },
    DapUIStepOver = { fg = colors.blue, bg = colors.bg1 },
    DapUIStop = { fg = colors.red, bg = colors.bg1 },
    TreesitterContext = { bg = colors.bg1 },
    DapUIStoppedThread = { link = "NeofusionBlue" },
    DapUIThread = { link = "NeofusionBlue" },
    DapUIType = { link = "NeofusionOrange" },
    DapUIUnavailable = { link = "NeofusionGray" },
    DapUIWatchesEmpty = { link = "NeofusionGray" },
    DapUIWatchesError = { link = "NeofusionRed" },
    DapUIWatchesValue = { link = "NeofusionYellow" },
    DapUIWinSelect = { link = "NeofusionYellow" },
    NeogitDiffDelete = { link = "DiffDelete" },
    NeogitDiffAdd = { link = "DiffAdd" },
    NeogitHunkHeader = { link = "WinBar" },
    NeogitHunkHeaderHighlight = { link = "WinBarNC" },
    DiffviewStatusModified = { link = "NeofusionGreenBold" },
    DiffviewFilePanelInsertions = { link = "NeofusionGreenBold" },
    DiffviewFilePanelDeletions = { link = "NeofusionRedBold" },
    ["@comment"] = { link = "Comment" },
    ["@none"] = { bg = "NONE", fg = "NONE" },
    ["@preproc"] = { link = "PreProc" },
    ["@define"] = { link = "Define" },
    ["@operator"] = { link = "Operator" },
    ["@punctuation.delimiter"] = { link = "Delimiter" },
    ["@punctuation.bracket"] = { link = "Delimiter" },
    ["@punctuation.special"] = { link = "Delimiter" },
    ["@string"] = { link = "String" },
    ["@string.regex"] = { link = "String" },
    ["@string.regexp"] = { link = "String" },
    ["@string.escape"] = { link = "SpecialChar" },
    ["@string.special"] = { link = "SpecialChar" },
    ["@string.special.path"] = { link = "Underlined" },
    ["@string.special.symbol"] = { link = "Identifier" },
    ["@string.special.url"] = { link = "Underlined" },
    ["@character"] = { link = "Character" },
    ["@character.special"] = { link = "SpecialChar" },
    ["@boolean"] = { link = "Boolean" },
    ["@number"] = { link = "Number" },
    ["@number.float"] = { link = "Float" },
    ["@float"] = { link = "Float" },
    ["@function"] = { link = "Function" },
    ["@function.builtin"] = { link = "Special" },
    ["@function.call"] = { link = "Function" },
    ["@function.macro"] = { link = "Macro" },
    ["@function.method"] = { link = "Function" },
    ["@method"] = { link = "Function" },
    ["@method.call"] = { link = "Function" },
    ["@constructor"] = { link = "Special" },
    ["@parameter"] = { link = "Identifier" },
    ["@keyword"] = { link = "Keyword" },
    ["@keyword.conditional"] = { link = "Conditional" },
    ["@keyword.debug"] = { link = "Debug" },
    ["@keyword.directive"] = { link = "PreProc" },
    ["@keyword.directive.define"] = { link = "Define" },
    ["@keyword.exception"] = { link = "Exception" },
    ["@keyword.function"] = { link = "Keyword" },
    ["@keyword.import"] = { link = "Include" },
    ["@keyword.operator"] = { link = "NeofusionRed" },
    ["@keyword.repeat"] = { link = "Repeat" },
    ["@keyword.return"] = { link = "Keyword" },
    ["@keyword.storage"] = { link = "StorageClass" },
    ["@conditional"] = { link = "Conditional" },
    ["@repeat"] = { link = "Repeat" },
    ["@debug"] = { link = "Debug" },
    ["@label"] = { link = "Label" },
    ["@include"] = { link = "Include" },
    ["@exception"] = { link = "Exception" },
    ["@type"] = { link = "Type" },
    ["@type.builtin"] = { link = "Type" },
    ["@type.definition"] = { link = "Typedef" },
    ["@type.qualifier"] = { link = "Type" },
    ["@storageclass"] = { link = "StorageClass" },
    ["@attribute"] = { link = "PreProc" },
    ["@field"] = { link = "Identifier" },
    ["@property"] = { link = "Identifier" },
    ["@variable"] = { link = "NeofusionFg1" },
    ["@variable.builtin"] = { link = "Special" },
    ["@variable.member"] = { link = "Identifier" },
    ["@variable.parameter"] = { link = "Identifier" },
    ["@constant"] = { link = "Constant" },
    ["@constant.builtin"] = { link = "Special" },
    ["@constant.macro"] = { link = "Define" },
    ["@markup"] = { link = "NeofusionFg1" },
    ["@markup.strong"] = { bold = config.bold },
    ["@markup.italic"] = { link = "@text.emphasis" },
    ["@markup.underline"] = { underline = config.underline },
    ["@markup.strikethrough"] = { strikethrough = config.strikethrough },
    ["@markup.heading"] = { link = "Title" },
    ["@markup.raw"] = { link = "String" },
    ["@markup.math"] = { link = "Special" },
    ["@markup.environment"] = { link = "Macro" },
    ["@markup.environment.name"] = { link = "Type" },
    ["@markup.link"] = { link = "Underlined" },
    ["@markup.link.label"] = { link = "SpecialChar" },
    ["@markup.list"] = { link = "Delimiter" },
    ["@markup.list.checked"] = { link = "NeofusionGreen" },
    ["@markup.list.unchecked"] = { link = "NeofusionGray" },
    ["@comment.todo"] = { link = "Todo" },
    ["@comment.note"] = { link = "SpecialComment" },
    ["@comment.warning"] = { link = "WarningMsg" },
    ["@comment.error"] = { link = "ErrorMsg" },
    ["@diff.plus"] = { link = "diffAdded" },
    ["@diff.minus"] = { link = "diffRemoved" },
    ["@diff.delta"] = { link = "diffChanged" },
    ["@module"] = { link = "NeofusionFg1" },
    ["@namespace"] = { link = "NeofusionFg1" },
    ["@symbol"] = { link = "Identifier" },
    ["@text"] = { link = "NeofusionFg1" },
    ["@text.strong"] = { bold = config.bold },
    ["@text.emphasis"] = { italic = config.italic.emphasis },
    ["@text.underline"] = { underline = config.underline },
    ["@text.strike"] = { strikethrough = config.strikethrough },
    ["@text.title"] = { link = "Title" },
    ["@text.literal"] = { link = "String" },
    ["@text.uri"] = { link = "Underlined" },
    ["@text.math"] = { link = "Special" },
    ["@text.environment"] = { link = "Macro" },
    ["@text.environment.name"] = { link = "Type" },
    ["@text.reference"] = { link = "Constant" },
    ["@text.todo"] = { link = "Todo" },
    ["@text.todo.checked"] = { link = "NeofusionGreen" },
    ["@text.todo.unchecked"] = { link = "NeofusionGray" },
    ["@text.note"] = { link = "SpecialComment" },
    ["@text.note.comment"] = { fg = colors.purple, bold = config.bold },
    ["@text.warning"] = { link = "WarningMsg" },
    ["@text.danger"] = { link = "ErrorMsg" },
    ["@text.danger.comment"] = { fg = colors.fg0, bg = colors.red, bold = config.bold },
    ["@text.diff.add"] = { link = "diffAdded" },
    ["@text.diff.delete"] = { link = "diffRemoved" },
    ["@tag"] = { link = "Tag" },
    ["@tag.attribute"] = { link = "Identifier" },
    ["@tag.delimiter"] = { link = "Delimiter" },
    ["@punctuation"] = { link = "Delimiter" },
    ["@macro"] = { link = "Macro" },
    ["@structure"] = { link = "Structure" },
    ["@lsp.type.class"] = { link = "@type" },
    ["@lsp.type.comment"] = { link = "@comment" },
    ["@lsp.type.decorator"] = { link = "@macro" },
    ["@lsp.type.enum"] = { link = "@type" },
    ["@lsp.type.enumMember"] = { link = "@constant" },
    ["@lsp.type.function"] = { link = "@function" },
    ["@lsp.type.interface"] = { link = "@constructor" },
    ["@lsp.type.macro"] = { link = "@macro" },
    ["@lsp.type.method"] = { link = "@method" },
    ["@lsp.type.namespace"] = { link = "@namespace" },
    ["@lsp.type.parameter"] = { link = "@parameter" },
    ["@lsp.type.property"] = { link = "@property" },
    ["@lsp.type.struct"] = { link = "@type" },
    ["@lsp.type.type"] = { link = "@type" },
    ["@lsp.type.typeParameter"] = { link = "@type.definition" },
    ["@lsp.type.variable"] = { link = "@variable" },
  }

  for g, hl in pairs(config.overrides) do
    if groups[g] then
      groups[g].link = nil
    end

    groups[g] = vim.tbl_extend("force", groups[g] or {}, hl)
  end

  return groups
end

--- @param config NeofusionConfig?
Neofusion.setup = function(config)
  Neofusion.config = vim.tbl_extend("force", Neofusion.config, config or {})
end

-- load function
Neofusion.load = function()
  if vim.version().minor < 8 then
    vim.notify_once("neofusion.nvim: nvim 0.8 or higher is needed")
    return
  end

  -- reset colors
  if vim.g.colors_name then
    vim.cmd.hi("clear")
  end

  vim.g.colors_name = "neofusion"
  vim.o.termguicolors = true

  local groups = get_groups()

  -- add highlights
  for group, settings in pairs(groups) do
    vim.api.nvim_set_hl(0, group, settings)
  end
end

return Neofusion
