# ~/.config/nvim/colors/zshell.lua
-- Generated by zshell. Material 3 based Neovim colorscheme.
-- This file is a Jinja template rendered by zshell.

vim.g.colors_name = nil
vim.o.background = "{{mode}}"

vim.cmd("highlight clear")
if vim.fn.exists("syntax_on") == 1 then
  vim.cmd("syntax reset")
end

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

local set = vim.api.nvim_set_hl
local function hl(group, opts)
  set(0, group, opts)
end

local function link(from, to)
  hl(from, { link = to })
end

local is_light = "{{mode}}" == "light"
local function pick(light, dark)
  return is_light and light or dark
end

local c = {
  bg = "{{m3surface}}",
  bg_alt = "{{m3surfaceContainerLow}}",
  bg_float = "{{m3surfaceContainer}}",
  bg_popup = "{{m3surfaceContainerHigh}}",
  bg_cursorline = pick("{{m3surfaceContainerHigh}}", "{{m3surfaceContainerHighest}}"),
  bg_fold = "{{m3surfaceContainerLow}}",
  bg_visual = "{{m3secondaryContainer}}",
  bg_search = pick("{{m3tertiaryContainer}}", "{{m3secondaryContainer}}"),
  bg_incsearch = "{{m3primaryContainer}}",
  bg_selection = "{{m3primaryContainer}}",
  bg_statusline = pick("{{m3surfaceContainerHigh}}", "{{m3surfaceContainer}}"),
  bg_statusline_nc = "{{m3surfaceContainerLow}}",
  bg_tabline = "{{m3surfaceContainerLow}}",
  bg_tabsel = "{{m3surfaceContainerHigh}}",

  fg = "{{m3onSurface}}",
  fg_muted = "{{m3onSurfaceVariant}}",
  fg_subtle = "{{m3outline}}",
  fg_comment = pick("{{m3outline}}", "{{m3outlineVariant}}"),
  fg_strong = pick("#1A1B1F", "#F2F2F7"),
  fg_on_soft = pick("#17181C", "#F4F4F8"),

  border = "{{m3outlineVariant}}",
  accent = "{{m3primary}}",
  accent_container = "{{m3primaryContainer}}",
  accent_fg = "{{m3onPrimaryContainer}}",
  accent_solid_fg = "{{m3onPrimary}}",

  secondary = "{{m3secondary}}",
  secondary_container = "{{m3secondaryContainer}}",
  secondary_fg = "{{m3onSecondaryContainer}}",
  secondary_solid_fg = "{{m3onSecondary}}",

  tertiary = "{{m3tertiary}}",
  tertiary_container = "{{m3tertiaryContainer}}",
  tertiary_fg = "{{m3onTertiaryContainer}}",
  tertiary_solid_fg = "{{m3onTertiary}}",

  error = "{{m3error}}",
  error_container = "{{m3errorContainer}}",
  error_fg = "{{m3onErrorContainer}}",
  error_solid_fg = "{{m3onError}}",

  ok = "{{term2}}",
  warn = "{{term3}}",
  info = "{{term4}}",
  hint = "{{term6}}",
  add = "{{term2}}",
  change = "{{term4}}",
  delete = "{{term1}}",

  cursor_fg = "{{m3onPrimary}}",
  cursor_bg = "{{m3primary}}",
  match_bg = "{{m3tertiaryContainer}}",
  match_fg = "{{m3onTertiaryContainer}}",
  todo_bg = "{{m3tertiaryContainer}}",
  todo_fg = "{{m3onTertiaryContainer}}",

  -- Syntax accents must stay dynamic. These come from your generated palette
  -- instead of fixed hex values, so foregrounds change with the wallpaper too.
  code_keyword = "{{term5}}",
  code_func = "{{term6}}",
  code_string = "{{term2}}",
  code_number = "{{term3}}",
  code_const = "{{term1}}",
  code_type = "{{m3primary}}",
  code_special = "{{m3tertiary}}",
  code_preproc = "{{m3secondary}}",
  code_builtin = "{{m3primary}}",
  code_param = "{{term3}}",
  code_field = "{{m3secondary}}",
  code_namespace = "{{m3tertiary}}",
  code_operator = pick("{{m3primary}}", "{{m3secondary}}"),

  line_current = pick("#232428", "#E7E7EC"),
  ref_bg = pick("{{m3surfaceContainerHighest}}", "{{m3surfaceContainerHigh}}"),
}

-- Core UI -------------------------------------------------------------------
hl("Normal", { fg = c.fg, bg = c.bg })
hl("NormalNC", { fg = c.fg, bg = c.bg })
hl("NormalFloat", { fg = c.fg, bg = c.bg_float })
hl("FloatBorder", { fg = c.border, bg = c.bg_float })
hl("FloatTitle", { fg = c.accent, bg = c.bg_float, bold = true })
hl("FloatFooter", { fg = c.fg_muted, bg = c.bg_float })
hl("WinSeparator", { fg = c.border, bg = "NONE" })
link("VertSplit", "WinSeparator")

hl("Cursor", { fg = c.cursor_fg, bg = c.cursor_bg })
link("lCursor", "Cursor")
link("CursorIM", "Cursor")
link("TermCursor", "Cursor")

hl("CursorLine", { bg = c.bg_cursorline })
hl("CursorColumn", { bg = c.bg_cursorline })
hl("ColorColumn", { bg = c.bg_alt })

hl("LineNr", { fg = c.fg_subtle, bg = c.bg })
hl("LineNrAbove", { fg = c.fg_subtle, bg = c.bg })
hl("LineNrBelow", { fg = c.fg_subtle, bg = c.bg })
hl("CursorLineNr", { fg = c.line_current, bg = c.bg_cursorline, bold = true })

hl("SignColumn", { fg = c.fg_muted, bg = c.bg })
hl("FoldColumn", { fg = c.fg_muted, bg = c.bg })
hl("Folded", { fg = c.fg_muted, bg = c.bg_fold, italic = true })

hl("NonText", { fg = c.border, bg = "NONE" })
link("EndOfBuffer", "NonText")
hl("Whitespace", { fg = c.border, bg = "NONE" })
hl("SpecialKey", { fg = c.border, bg = "NONE" })

hl("Visual", { bg = c.bg_visual })
link("VisualNOS", "Visual")
hl("Search", { fg = c.tertiary_fg, bg = c.bg_search })
hl("CurSearch", { fg = c.accent_fg, bg = c.bg_incsearch, bold = true })
link("IncSearch", "CurSearch")
hl("Substitute", { fg = c.accent_fg, bg = c.bg_incsearch, bold = true })
hl("MatchParen", { fg = c.match_fg, bg = c.match_bg, bold = true })

hl("Pmenu", { fg = c.fg, bg = c.bg_popup })
hl("PmenuSel", { fg = c.fg_on_soft, bg = c.bg_selection, bold = true })
hl("PmenuKind", { fg = c.secondary, bg = c.bg_popup })
hl("PmenuKindSel", { fg = c.fg_on_soft, bg = c.secondary_container, bold = true })
hl("PmenuExtra", { fg = c.fg_muted, bg = c.bg_popup })
hl("PmenuExtraSel", { fg = c.fg_on_soft, bg = c.bg_selection })
hl("PmenuSbar", { bg = c.bg_alt })
hl("PmenuThumb", { bg = c.border })
hl("PmenuMatch", { fg = c.accent, bg = c.bg_popup, bold = true })
hl("PmenuMatchSel", { fg = c.accent, bg = c.bg_selection, bold = true })
hl("PmenuBorder", { fg = c.border, bg = c.bg_popup })

hl("StatusLine", { fg = c.fg_strong, bg = c.bg_statusline })
hl("StatusLineNC", { fg = c.fg_muted, bg = c.bg_statusline_nc })
link("StatusLineTerm", "StatusLine")
link("StatusLineTermNC", "StatusLineNC")
hl("TabLine", { fg = c.fg_muted, bg = c.bg_tabline })
hl("TabLineFill", { bg = c.bg_tabline })
hl("TabLineSel", { fg = c.fg_on_soft, bg = c.accent_container, bold = true })
hl("WinBar", { fg = c.fg, bg = c.bg })
hl("WinBarNC", { fg = c.fg_muted, bg = c.bg })

hl("Directory", { fg = c.accent, bg = "NONE" })
hl("Title", { fg = c.accent, bg = "NONE", bold = true })
hl("Question", { fg = c.secondary, bg = "NONE", bold = true })
hl("ModeMsg", { fg = c.accent, bg = "NONE", bold = true })
hl("MoreMsg", { fg = c.info, bg = "NONE", bold = true })
hl("ErrorMsg", { fg = c.error, bg = "NONE", bold = true })
hl("WarningMsg", { fg = c.warn, bg = "NONE", bold = true })
hl("OkMsg", { fg = c.ok, bg = "NONE", bold = true })
hl("QuickFixLine", { bg = c.bg_selection, bold = true })

-- Diffs ---------------------------------------------------------------------
hl("DiffAdd", { fg = c.add, bg = c.bg_alt })
hl("DiffChange", { fg = c.change, bg = c.bg_alt })
hl("DiffDelete", { fg = c.delete, bg = c.bg_alt })
hl("DiffText", { fg = c.fg_on_soft, bg = c.accent_container, bold = true })
link("DiffTextAdd", "DiffText")
hl("Added", { fg = c.add })
hl("Changed", { fg = c.change })
hl("Removed", { fg = c.delete })

-- Standard syntax groups ----------------------------------------------------
hl("Comment", { fg = c.fg_comment, italic = true })
hl("Constant", { fg = c.code_const })
hl("String", { fg = c.code_string })
hl("Character", { fg = c.code_string })
hl("Number", { fg = c.code_number })
hl("Boolean", { fg = c.code_number, bold = true })
hl("Float", { fg = c.code_number })

hl("Identifier", { fg = c.fg })
hl("Function", { fg = c.code_func, bold = true })

hl("Statement", { fg = c.code_keyword, bold = true })
link("Conditional", "Statement")
link("Repeat", "Statement")
link("Label", "Statement")
hl("Operator", { fg = c.code_operator })
hl("Keyword", { fg = c.code_keyword, italic = true })
link("Exception", "Statement")

hl("PreProc", { fg = c.code_preproc })
link("Include", "PreProc")
link("Define", "PreProc")
link("Macro", "PreProc")
link("PreCondit", "PreProc")

hl("Type", { fg = c.code_type, bold = true })
link("StorageClass", "Type")
link("Structure", "Type")
link("Typedef", "Type")

hl("Special", { fg = c.code_special })
link("SpecialChar", "Special")
link("Tag", "Special")
hl("Delimiter", { fg = c.fg_muted })
link("SpecialComment", "Special")
link("Debug", "Special")

hl("Underlined", { fg = c.accent, underline = true })
hl("Todo", { fg = c.todo_fg, bg = c.todo_bg, bold = true })
hl("Error", { fg = c.error, bold = true })

-- Spell ---------------------------------------------------------------------
hl("SpellBad", { sp = c.error, undercurl = true })
hl("SpellCap", { sp = c.info, undercurl = true })
hl("SpellLocal", { sp = c.hint, undercurl = true })
hl("SpellRare", { sp = c.secondary, undercurl = true })

-- Diagnostics ---------------------------------------------------------------
hl("DiagnosticError", { fg = c.error })
hl("DiagnosticWarn", { fg = c.warn })
hl("DiagnosticInfo", { fg = c.info })
hl("DiagnosticHint", { fg = c.hint })
hl("DiagnosticOk", { fg = c.ok })

hl("DiagnosticUnderlineError", { sp = c.error, undercurl = true })
hl("DiagnosticUnderlineWarn", { sp = c.warn, undercurl = true })
hl("DiagnosticUnderlineInfo", { sp = c.info, undercurl = true })
hl("DiagnosticUnderlineHint", { sp = c.hint, undercurl = true })
hl("DiagnosticUnderlineOk", { sp = c.ok, undercurl = true })

link("DiagnosticSignError", "DiagnosticError")
link("DiagnosticSignWarn", "DiagnosticWarn")
link("DiagnosticSignInfo", "DiagnosticInfo")
link("DiagnosticSignHint", "DiagnosticHint")
link("DiagnosticSignOk", "DiagnosticOk")

link("DiagnosticFloatingError", "DiagnosticError")
link("DiagnosticFloatingWarn", "DiagnosticWarn")
link("DiagnosticFloatingInfo", "DiagnosticInfo")
link("DiagnosticFloatingHint", "DiagnosticHint")
link("DiagnosticFloatingOk", "DiagnosticOk")

hl("DiagnosticVirtualTextError", { fg = c.error, bg = c.error_container })
hl("DiagnosticVirtualTextWarn", { fg = c.warn, bg = c.bg_alt })
hl("DiagnosticVirtualTextInfo", { fg = c.info, bg = c.bg_alt })
hl("DiagnosticVirtualTextHint", { fg = c.hint, bg = c.bg_alt })
hl("DiagnosticVirtualTextOk", { fg = c.ok, bg = c.bg_alt })

link("DiagnosticVirtualLinesError", "DiagnosticVirtualTextError")
link("DiagnosticVirtualLinesWarn", "DiagnosticVirtualTextWarn")
link("DiagnosticVirtualLinesInfo", "DiagnosticVirtualTextInfo")
link("DiagnosticVirtualLinesHint", "DiagnosticVirtualTextHint")
link("DiagnosticVirtualLinesOk", "DiagnosticVirtualTextOk")

hl("DiagnosticDeprecated", { fg = c.fg_muted, strikethrough = true })
hl("DiagnosticUnnecessary", { fg = c.fg_muted, italic = true })

-- LSP reference/inlay/codelens ---------------------------------------------
hl("LspReferenceText", { bg = c.ref_bg })
hl("LspReferenceRead", { bg = c.ref_bg })
hl("LspReferenceWrite", { bg = c.ref_bg, sp = c.accent, undercurl = true })
hl("LspReferenceTarget", { fg = c.accent, bg = c.ref_bg, bold = true })
hl("LspInlayHint", { fg = c.fg_muted, bg = c.bg_alt, italic = true })
hl("LspCodeLens", { fg = c.fg_muted, italic = true })
hl("LspCodeLensSeparator", { fg = c.border })
hl("LspSignatureActiveParameter", { fg = c.accent, bold = true, underline = true })

-- Treesitter captures -------------------------------------------------------
link("@comment", "Comment")
link("@comment.documentation", "Comment")
link("@comment.todo", "Todo")
link("@comment.error", "DiagnosticError")
link("@comment.warning", "DiagnosticWarn")
link("@comment.note", "DiagnosticInfo")

link("@constant", "Constant")
hl("@constant.builtin", { fg = c.code_builtin, italic = true, bold = true })
hl("@constant.macro", { fg = c.code_preproc, bold = true })
link("@string", "String")
hl("@string.escape", { fg = c.code_special, bold = true })
link("@string.regex", "Special")
link("@character", "Character")
link("@number", "Number")
link("@boolean", "Boolean")
link("@float", "Float")

link("@variable", "Identifier")
hl("@variable.builtin", { fg = c.code_builtin, italic = true, bold = true })
hl("@variable.parameter", { fg = c.code_param, italic = true })
hl("@variable.member", { fg = c.code_field })
hl("@property", { fg = c.code_field })
hl("@field", { fg = c.code_field })

link("@function", "Function")
hl("@function.builtin", { fg = c.code_builtin, bold = true })
link("@function.call", "Function")
hl("@function.method", { fg = c.code_func })
hl("@function.method.call", { fg = c.code_func })
hl("@constructor", { fg = c.code_type, bold = true })

link("@keyword", "Keyword")
hl("@keyword.function", { fg = c.code_keyword, bold = true })
hl("@keyword.operator", { fg = c.code_operator })
link("@keyword.return", "Keyword")
link("@conditional", "Conditional")
link("@repeat", "Repeat")
link("@label", "Label")
link("@operator", "Operator")
link("@exception", "Exception")

link("@preproc", "PreProc")
link("@include", "Include")
link("@define", "Define")
link("@macro", "Macro")

link("@type", "Type")
hl("@type.builtin", { fg = c.code_type, italic = true, bold = true })
link("@type.definition", "Type")
hl("@attribute", { fg = c.code_preproc })
hl("@module", { fg = c.code_namespace })
hl("@namespace", { fg = c.code_namespace })

link("@punctuation.delimiter", "Delimiter")
link("@punctuation.bracket", "Delimiter")
hl("@punctuation.special", { fg = c.code_special })
link("@tag", "Tag")
hl("@tag.attribute", { fg = c.code_field })
link("@tag.delimiter", "Delimiter")

-- LSP semantic token families ----------------------------------------------
link("@lsp.type.class", "@type")
link("@lsp.type.comment", "@comment")
link("@lsp.type.decorator", "@attribute")
link("@lsp.type.enum", "@type")
link("@lsp.type.enumMember", "@constant")
link("@lsp.type.event", "@property")
link("@lsp.type.function", "@function")
link("@lsp.type.interface", "@type")
link("@lsp.type.keyword", "@keyword")
link("@lsp.type.macro", "@macro")
link("@lsp.type.method", "@function.method")
link("@lsp.type.modifier", "@keyword")
link("@lsp.type.namespace", "@namespace")
link("@lsp.type.number", "@number")
link("@lsp.type.operator", "@operator")
link("@lsp.type.parameter", "@variable.parameter")
link("@lsp.type.property", "@property")
link("@lsp.type.regexp", "@string.regex")
link("@lsp.type.string", "@string")
link("@lsp.type.struct", "@type")
link("@lsp.type.type", "@type")
link("@lsp.type.typeParameter", "@type")
link("@lsp.type.variable", "@variable")

hl("@lsp.mod.deprecated", { strikethrough = true })
link("@lsp.mod.readonly", "Constant")
link("@lsp.typemod.variable.readonly", "Constant")

-- Common plugin aliases -----------------------------------------------------
hl("GitSignsAdd", { fg = c.add, bg = c.bg })
hl("GitSignsChange", { fg = c.change, bg = c.bg })
hl("GitSignsDelete", { fg = c.delete, bg = c.bg })

hl("MiniIndentscopeSymbol", { fg = c.border, nocombine = true })
hl("IblIndent", { fg = c.border, nocombine = true })
hl("IblScope", { fg = c.fg_muted, nocombine = true })

link("TelescopeNormal", "NormalFloat")
link("TelescopeBorder", "FloatBorder")
link("TelescopeTitle", "FloatTitle")
link("TelescopeSelection", "PmenuSel")
hl("TelescopeMatching", { fg = c.accent, bold = true })

-- Snacks.nvim picker / explorer --------------------------------------------
hl("SnacksPicker", { fg = c.fg, bg = c.bg })
hl("SnacksPickerBorder", { fg = c.border, bg = c.bg })
hl("SnacksPickerBoxBorder", { fg = c.border, bg = c.bg_alt })
hl("SnacksPickerTitle", { fg = c.accent, bg = c.bg_alt, bold = true })

hl("SnacksPickerInput", { fg = c.fg, bg = c.bg_alt })
hl("SnacksPickerInputBorder", { fg = c.border, bg = c.bg_alt })
hl("SnacksPickerInputTitle", { fg = c.accent, bg = c.bg_alt, bold = true })
hl("SnacksPickerInputSearch", { fg = c.accent, bg = c.bg_alt, bold = true })
hl("SnacksPickerPrompt", { fg = c.accent, bg = c.bg_alt, bold = true })

hl("SnacksPickerList", { fg = c.fg, bg = c.bg })
hl("SnacksPickerListBorder", { fg = c.border, bg = c.bg })
hl("SnacksPickerListTitle", { fg = c.secondary, bg = c.bg, bold = true })
hl("SnacksPickerListCursorLine", { bg = c.bg_cursorline })

hl("SnacksPickerPreview", { fg = c.fg, bg = c.bg_float })
hl("SnacksPickerPreviewBorder", { fg = c.border, bg = c.bg_float })
hl("SnacksPickerPreviewTitle", { fg = c.tertiary, bg = c.bg_float, bold = true })

hl("SnacksPickerMatch", { fg = c.accent, bold = true })
hl("SnacksPickerFile", { fg = c.fg })
hl("SnacksPickerDir", { fg = c.secondary })
hl("SnacksPickerPathHidden", { fg = c.fg_muted })
hl("SnacksPickerPathIgnored", { fg = c.fg_subtle, italic = true })
hl("SnacksPickerPathExcluded", { fg = c.fg_subtle, italic = true })

hl("SnacksPickerGitStatusAdded", { fg = c.add })
hl("SnacksPickerGitStatusModified", { fg = c.change })
hl("SnacksPickerGitStatusDeleted", { fg = c.delete })
hl("SnacksPickerGitStatusRenamed", { fg = c.info })
hl("SnacksPickerGitStatusCopied", { fg = c.info })
hl("SnacksPickerGitStatusUntracked", { fg = c.hint })
hl("SnacksPickerGitStatusIgnored", { fg = c.fg_subtle })
hl("SnacksPickerGitStatusStaged", { fg = c.ok })

return c
