From 887a36ec00e524c193a658769ca326786d9ed26b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Mon, 19 Feb 2024 02:00:45 -0600 Subject: [PATCH] refactor(nvim): massively overhaul how highlights are set --- .../nvim/after/queries/org/highlights.scm | 17 +- .../nvim/lua/plugins/configs/headlines.lua | 30 +- .../nvim/lua/plugins/configs/kanagawa.lua | 465 ++++++++++-------- .../nvim/lua/plugins/configs/nvim-ufo.lua | 2 +- dots/.config/nvim/lua/utils/funcs.lua | 61 +++ 5 files changed, 359 insertions(+), 216 deletions(-) diff --git a/dots/.config/nvim/after/queries/org/highlights.scm b/dots/.config/nvim/after/queries/org/highlights.scm index 6d156641..3c46c71e 100644 --- a/dots/.config/nvim/after/queries/org/highlights.scm +++ b/dots/.config/nvim/after/queries/org/highlights.scm @@ -1,7 +1,7 @@ ; extends ((bullet) - @punctuation.special - (#any-of? @punctuation.special "-" "*" "+") + @markup.list + (#any-of? @markup.list "-" "*" "+") (#set! conceal "•")) ((checkbox !status) @markup.list.unchecked (#set! conceal "")) @@ -27,3 +27,16 @@ (row (cell (contents) @markup.heading)) (hr) @punctuation.special) + + +; Quote highlights +(block + name: (expr) @org-block-start-name (#any-of? @org-block-start-name "quote" "QUOTE") + contents: (contents) @markup.quote + end_name: (expr) @org-block-end-name (#any-of? @org-block-end-name "quote" "QUOTE")) + +(block + name: (expr) @org-block-start-name (#any-of? @org-block-start-name "src" "SRC") + !parameter + contents: (contents) @markup.raw.block + end_name: (expr) @org-block-end-name (#any-of? @org-block-end-name "src" "SRC")) diff --git a/dots/.config/nvim/lua/plugins/configs/headlines.lua b/dots/.config/nvim/lua/plugins/configs/headlines.lua index 13290efa..a8aae123 100644 --- a/dots/.config/nvim/lua/plugins/configs/headlines.lua +++ b/dots/.config/nvim/lua/plugins/configs/headlines.lua @@ -4,25 +4,39 @@ return { dependencies = "nvim-treesitter/nvim-treesitter", opts = function() local bullets = { - "󰀘", - "", - "󰺕", - "", - "󰬪", - "󱆭", + "󰀘", + "", + "󰺕", + "", + "󰬪", + "󱆭", + } + local bullet_highlights = { + "@markup.heading.1.marker", + "@markup.heading.2.marker", + "@markup.heading.3.marker", + "@markup.heading.4.marker", + "@markup.heading.5.marker", + "@markup.heading.6.marker", + "@markup.heading.7.marker", + "@markup.heading.8.marker" } return { markdown = { bullets = bullets, + bullet_highlights = bullet_highlights }, rmd = { bullets = bullets, + bullet_highlights = bullet_highlights }, norg = { - bullets = bullets + bullets = bullets, + bullet_highlights = bullet_highlights }, org = { - bullets = bullets + bullets = bullets, + bullet_highlights = bullet_highlights } } end, diff --git a/dots/.config/nvim/lua/plugins/configs/kanagawa.lua b/dots/.config/nvim/lua/plugins/configs/kanagawa.lua index 4e3c069e..29efc51c 100644 --- a/dots/.config/nvim/lua/plugins/configs/kanagawa.lua +++ b/dots/.config/nvim/lua/plugins/configs/kanagawa.lua @@ -1,3 +1,7 @@ +local utils = require("utils.funcs") +local get_hl = utils.get_hl +local select_hl = utils.select_hl + return { { "rebelot/kanagawa.nvim", @@ -6,7 +10,6 @@ return { require("plugins.configs.kanagawa") vim.cmd.KanagawaCompile() end, - ---@param opts KanagawaConfig config = function() vim.api.nvim_create_autocmd("BufWritePost", { pattern = "lua/plugins/configs/kanagawa.lua", @@ -29,214 +32,266 @@ return { }, }, }, - overrides = function(palette) - ---@type PaletteColors - local colors = palette.palette - vim.api.nvim_set_hl(0, "NvimNotifyError", { fg = colors.samuraiRed }) - vim.api.nvim_set_hl(0, "NvimNotifyWarn", { fg = colors.roninYellow }) - vim.api.nvim_set_hl(0, "NvimNotifyInfo", { fg = colors.springGreen }) - vim.api.nvim_set_hl(0, "NvimNotifyDebug", { fg = colors.crystalBlue }) - vim.api.nvim_set_hl(0, "NvimNotifyTrace", { fg = colors.oniViolet }) - - local overrides = { - CursorLineNr = { fg = colors.roninYellow, bg = palette.theme.ui.bg_p1 }, - CursorLineFold = { fg = colors.crystalBlue, bg = palette.theme.ui.bg_p1 }, - CursorLineSign = { bg = palette.theme.ui.bg_p1 }, - LightBulbSign = { fg = colors.crystalBlue, bg = palette.theme.ui.bg_p1 }, - WinSeparator = { fg = colors.fujiGray }, - StatusLine = { fg = colors.fujiWhite, bg = colors.sumiInk0 }, - WinBar = { fg = colors.fujiWhite, bg = nil }, - NeogitPopupSectionTitle = { fg = colors.crystalBlue }, - NeogitPopupConfigEnabled = { fg = colors.springBlue, italic = true }, - NeogitPopupActionkey = { fg = colors.surimiOrange }, - NeogitPopupConfigKey = { fg = colors.peachRed }, - NeogitHunkHeader = { fg = colors.crystalBlue, bg = colors.sumiInk2 }, - NeogitHunkHeaderHighlight = { fg = colors.roninYellow, bg = colors.sumiInk1 }, - NeogitBranch = { fg = colors.autumnYellow, bold = true }, - NeogitUnmergedInto = { fg = colors.surimiOrange, bold = true }, - NeogitRemote = { fg = colors.carpYellow, bold = true }, - NeogitDiffContext = { bg = colors.sumiInk3 }, - NeogitDiffContextHighlight = { bg = colors.sumiInk4 }, - NeogitCursorLine = { link = "CursorLine" }, - NeogitDiffAdd = { fg = colors.autumnGreen, bg = colors.winterGreen }, - NeogitDiffDelete = { fg = colors.autumnRed, bg = colors.winterRed }, - NeogitDiffDeleteHighlight = { link = "DiffDelete" }, - NeogitDiffHeader = { fg = colors.oniViolet, bg = colors.sumiInk0, bold = true }, - NeogitDiffHeaderHighlight = { fg = colors.sakuraPink, bg = colors.sumiInk0, bold = true }, - NeogitDiffAddHighlight = { link = "DiffAdd" }, - NeogitStagedChanges = { fg = colors.surimiOrange, bold = true }, - NeogitUnpulledChanges = { fg = colors.peachRed, bold = true }, - NeogitUnmergedChanges = { fg = colors.springGreen, bold = true }, - NeogitUnstagedChanges = { fg = colors.peachRed, bold = true }, - NeogitUntrackedFiles = { fg = colors.peachRed, bold = true }, - NeogitRecentCommits = { fg = colors.crystalBlue, bold = true }, - NeogitCommitViewHeader = { fg = colors.crystalBlue, bold = true, italic = true }, - NeogitFilePath = { fg = colors.autumnYellow, italic = true }, - NeogitNotificationInfo = { fg = colors.springGreen, bold = true }, - NeogitNotificationWarning = { fg = colors.roninYellow, bold = true }, - NeogitNotificationError = { fg = colors.samuraiRed, bold = true }, - menuSel = { bg = colors.sumiInk0, fg = "NONE" }, - Pmenu = { fg = colors.fujiWhite, bg = colors.sumiInk2 }, - CmpGhostText = { fg = colors.boatYellow1, italic = true }, - CmpItemAbbrDeprecated = { fg = colors.fujiGray, bg = "NONE" }, - CmpItemAbbrMatch = { fg = colors.crystalBlue, bg = "NONE" }, - CmpItemAbbrMatchFuzzy = { fg = colors.crystalBlue, bg = "NONE" }, - CmpItemMenu = { fg = colors.roninYellow, bg = "NONE" }, - CmpItemKindField = { fg = colors.fujiWhite, bg = colors.sakuraPink }, - CmpItemKindProperty = { fg = colors.fujiWhite, bg = colors.sakuraPink }, - CmpItemKindEvent = { fg = colors.fujiWhite, bg = colors.sakuraPink }, - CmpItemKindText = { fg = colors.fujiWhite, bg = colors.dragonBlue }, - CmpItemKindEnum = { fg = colors.fujiWhite, bg = colors.crystalBlue }, - CmpItemKindKeyword = { fg = colors.fujiWhite, bg = colors.springBlue }, - CmpItemKindConstant = { fg = colors.fujiWhite, bg = colors.crystalBlue }, - CmpItemKindConstructor = { fg = colors.fujiWhite, bg = colors.crystalBlue }, - CmpItemKindReference = { fg = colors.fujiWhite, bg = colors.crystalBlue }, - CmpItemKindFunction = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpItemKindStruct = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpItemKindClass = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpItemKindModule = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpItemKindOperator = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpItemKindVariable = { fg = colors.fujiWhite, bg = colors.roninYellow }, - CmpItemKindFile = { fg = colors.fujiWhite, bg = colors.autumnYellow }, - CmpItemKindUnit = { fg = colors.fujiWhite, bg = colors.autumnYellow }, - CmpItemKindSnippet = { fg = colors.fujiWhite, bg = colors.autumnYellow }, - CmpItemKindFolder = { fg = colors.fujiWhite, bg = colors.autumnYellow }, - CmpItemKindMethod = { fg = colors.fujiWhite, bg = colors.autumnGreen }, - CmpItemKindValue = { fg = colors.fujiWhite, bg = colors.autumnGreen }, - CmpItemKindEnumMember = { fg = colors.fujiWhite, bg = colors.autumnGreen }, - CmpItemKindInterface = { fg = colors.fujiWhite, bg = colors.waveRed }, - CmpItemKindColor = { fg = colors.fujiWhite, bg = colors.waveAqua2 }, - CmpItemKindTypeParameter = { fg = colors.fujiWhite, bg = colors.waveAqua2 }, - CmpCustomSelectionColor = { bg = colors.sumiInk5 }, - CmpCustomSelectionDadbodCompletion = { fg = colors.fujiWhite, bg = colors.oniViolet }, - CmpCustomSelectionGit = { fg = colors.fujiWhite, bg = colors.roninYellow }, - CmpCustomSelectionBuffer = { fg = colors.fujiWhite, bg = colors.springBlue }, - CmpCustomSelectionPath = { fg = colors.fujiWhite, bg = colors.autumnYellow }, - CmpCustomSelectionCalculator = { fg = colors.fujiWhite, bg = colors.waveBlue2 }, - CmpCustomSelectionOrgmode = { fg = colors.fujiWhite, bg = colors.waveAqua1 }, - CmpCustomSelectionEmoji = { fg = colors.fujiWhite, bg = colors.carpYellow }, - CmpCustomSelectionZsh = { fg = colors.fujiWhite, bg = colors.springGreen }, - CmpCustomSelectionCrates = { fg = colors.fujiWhite, bg = colors.roninYellow }, - CmpCustomSelectionDocker = { fg = colors.fujiWhite, bg = colors.springBlue }, - CmpCustomSelectionCmdHistory = { fg = colors.fujiWhite, bg = colors.waveBlue2 }, - CmpCustomSelectionRipgrep = { fg = colors.fujiWhite, bg = colors.crystalBlue }, - CmpCustomSelectionNpm = { fg = colors.fujiWhite, bg = colors.peachRed }, - CmpCustomSelectionCommit = { fg = colors.fujiWhite, bg = colors.peachRed }, - CmpCustomSelectionSnippet = { fg = colors.fujiWhite, bg = colors.peachRed }, - CmpCustomSelectionLuaLatexSymbol = { fg = colors.fujiWhite, bg = colors.surimiOrange }, - TelescopeNormal = { bg = colors.sumiInk2 }, - TelescopeBorder = { bg = colors.sumiInk2, fg = colors.sumiInk1 }, - TelescopePromptBorder = { bg = colors.sumiInk0, fg = colors.sumiInk0 }, - TelescopePromptNormal = { bg = colors.sumiInk0, fg = colors.fujiWhite }, - TelescopePromptTitle = { fg = colors.sumiInk0, bg = colors.oniViolet }, - TelescopePreviewTitle = { fg = colors.sumiInk0, bg = colors.sakuraPink }, - TelescopePreviewNormal = { bg = colors.sumiInk4 }, - TelescopePreviewBorder = { link = "TelescopePreviewNormal" }, - TelescopeResultsTitle = { fg = "NONE", bg = "NONE" }, - MiniCursorword = { bg = colors.waveBlue2 }, - MiniCursorwordCurrent = { bg = colors.waveBlue2 }, - rainbowcol1 = { fg = colors.oniViolet }, - rainbowcol2 = { fg = colors.crystalBlue }, - rainbowcol3 = { fg = colors.lightBlue }, - rainbowcol4 = { fg = colors.sakuraPink }, - rainbowcol5 = { fg = colors.springGreen }, - rainbowcol6 = { fg = colors.springViolet2 }, - rainbowcol7 = { fg = colors.carpYellow }, - packerSuccess = { fg = colors.autumnGreen, bg = "NONE" }, - NeoTreeNormal = { bg = colors.sumiInk1 }, - NeoTreeNormalNC = { bg = colors.sumiInk1 }, - NoiceCmdlineIconCmdline = { fg = colors.oniViolet }, - NoiceCmdlinePopupBorderCmdline = { fg = colors.oniViolet }, - NoiceCmdlineIconFilter = { fg = colors.springGreen }, - NoiceCmdlinePopupBorderFilter = { fg = colors.springGreen }, - NoiceCmdLineIconLua = { fg = colors.crystalBlue }, - NoiceCmdlinePopupBorderLua = { fg = colors.crystalBlue }, - NoiceCmdlineIconHelp = { fg = colors.surimiOrange }, - NoiceCmdlinePopupBorderHelp = { fg = colors.surimiOrange }, - NoiceCmdLineIconSearch = { fg = colors.roninYellow }, - NoiceCmdlinePopupBorderSearch = { fg = colors.roninYellow }, - NoiceCmdlineIconIncRename = { fg = colors.peachRed }, - NoiceCmdlinePopupdBorderIncRename = { fg = colors.peachRed }, - NoiceMini = { bg = colors.sumiInk4 }, - NoiceLspProgressClient = { fg = colors.oniViolet, bold = true }, - Folded = { underline = true, sp = colors.oniViolet, bg = "NONE" }, - UfoFoldedBg = { bg = colors.waveBlue1 }, - TSRainbowRed = { fg = colors.peachRed }, - TSRainbowYellow = { fg = colors.carpYellow }, - TSRainbowBlue = { fg = colors.crystalBlue }, - TSRainbowGreen = { fg = colors.springGreen }, - TSRainbowViolet = { fg = colors.oniViolet }, - TSRainbowCyan = { fg = colors.lightBlue }, - TreesitterContext = { bg = colors.sumiInk0 }, - FloatTitle = { bg = "NONE" }, - DiffviewFilePanelTitle = { fg = colors.crystalBlue }, - Headline = { bg = colors.sumiInk2 }, - HeadlineReversed = { bg = colors.sumiInk1 }, - LspInlayHint = { fg = colors.springViolet2, bg = colors.winterBlue }, - ["@text"] = { fg = colors.fujiWhite }, - ["@markup.raw.markdown_inline"] = { link = "String" }, - ["@markup.raw.delimiter.markdown_inline"] = { link = "@punctuation.delimiter" }, - ["@markup.raw.delimiter.markdown"] = { link = "@punctuation.delimiter" }, - ["@markup.link.markdown_inline"] = { fg = colors.crystalBlue }, - ["@text.title.1.marker.markdown"] = { fg = colors.surimiOrange }, - ["@text.title.2.marker.markdown"] = { fg = colors.surimiOrange }, - ["@text.title.3.marker.markdown"] = { fg = colors.surimiOrange }, - ["@text.title.4.marker.markdown"] = { fg = colors.surimiOrange }, - ["@text.title.5.marker.markdown"] = { fg = colors.surimiOrange }, - ["@text.title.6.marker.markdown"] = { fg = colors.surimiOrange }, - RainbowDelimiterRed = { fg = colors.peachRed }, - RainbowDelimiterYellow = { fg = colors.autumnYellow }, - RainbowDelimiterBlue = { fg = colors.crystalBlue }, - RainbowDelimiterOrange = { fg = colors.surimiOrange }, - RainbowDelimiterGreen = { fg = colors.waveAqua1 }, - RainbowDelimiterViolet = { fg = colors.oniViolet }, - RainbowDelimiterCyan = { fg = colors.lightBlue }, - NotifyERRORBorder = { link = "NvimNotifyError" }, - NotifyERRORIcon = { link = "NvimNotifyError" }, - NotifyERRORTitle = { link = "NvimNotifyError" }, - NotifyWARNBorder = { link = "NvimNotifyWarn" }, - NotifyWARNIcon = { link = "NvimNotifyWarn" }, - NotifyWARNTitle = { link = "NvimNotifyWarn" }, - NotifyINFOBorder = { link = "NvimNotifyInfo" }, - NotifyINFOIcon = { link = "NvimNotifyInfo" }, - NotifyINFOTitle = { link = "NvimNotifyInfo" }, - NotifyDEBUGBorder = { link = "NvimNotifyDebug" }, - NotifyDEBUGIcon = { link = "NvimNotifyDebug" }, - NotifyDEBUGTitle = { link = "NvimNotifyDebug" }, - NotifyTRACEBorder = { link = "NvimNotifyTrace" }, - NotifyTRACEIcon = { link = "NvimNotifyTrace" }, - NotifyTRACETitle = { link = "NvimNotifyTrace" }, - NotificationInfo = { link = "NvimNotifyInfo" }, - NotificationWarning = { link = "NvimNotifyWarn" }, - NotificationError = { link = "NvimNotifyError" }, - - -- Org mode specific - org_verbatim = { bg = colors.sumiInk0, fg = colors.springGreen }, - org_code = { fg = colors.carpYellow, bg = colors.sumiInk0 }, - org_table_sep = { fg = colors.springBlue }, - org_table_header = { fg = colors.crystalBlue }, - ["@OrgTSBlock.org"] = { fg = colors.fujiGray, bold = true, italic = true }, - ["@OrgTSDirective.org"] = { link = "@OrgTSBlock.org" }, - - -- Markup specific - ["@markup.list.checked"] = { fg = colors.springGreen }, - ["@markup.list.indeterminate"] = { fg = colors.carpYellow }, - ["@markup.list.unchecked"] = { fg = colors.crystalBlue }, - ["@OrgTSCheckboxChecked.org"] = { link = "@markup.list.checked" }, - ["@OrgTSCheckboxHalfChecked.org"] = { link = "@markup.list.indeterminate"}, - ["@OrgTSCheckbox.org"] = { link = "@markup.list.unchecked" }, - } - - return overrides - end, }) vim.cmd.colorscheme("kanagawa") + local palette = require("kanagawa.colors").setup() local colors = require("kanagawa.colors").setup().palette - vim.api.nvim_set_hl(0, "StatusLine", { bg = colors.sumiInk0 }) - vim.api.nvim_set_hl(0, "WinBar", { bg = nil }) - vim.api.nvim_set_hl(0, "StatusLineNC", { bg = nil }) - vim.api.nvim_set_hl(0, "WinBarNC", { bg = nil }) + + -- This table was formed as an array to ensure the ordering of the keys. Since some + -- highlights defined below depend on other highlights being correctly set, order is + -- very important. Lua does not guarantee hashmaps will be in the order they are + -- defined, thus the array. + ---@type { [1]: string, [2]: vim.api.keyset.highlight | fun(): vim.api.keyset.highlight }[] + local extra_hls = { + { "NvimNotifyError", { fg = colors.samuraiRed } }, + { "NvimNotifyWarn", { fg = colors.roninYellow } }, + { "NvimNotifyInfo", { fg = colors.springGreen } }, + { "NvimNotifyDebug", { fg = colors.crystalBlue } }, + { "NvimNotifyTrace", { fg = colors.oniViolet } }, + { "Winbar", { bg = nil } }, + { "StatusLineNC", { bg = nil } }, + { "WinBarNC", { bg = nil } }, + { "CursorLineNr", { fg = colors.roninYellow, bg = palette.theme.ui.bg_m1 } }, + { "CursorLineFold", { fg = colors.crystalBlue, bg = palette.theme.ui.bg_m1 } }, + { "CursorLineSign", { bg = palette.theme.ui.bg_m1 } }, + { "LightBulbSign", { fg = colors.crystalBlue, bg = palette.theme.ui.bg_m1 } }, + { "WinSeparator", { fg = colors.fujiGray } }, + { "StatusLine", { fg = colors.fujiWhite, bg = colors.sumiInk0 } }, + { "WinBar", { fg = colors.fujiWhite, bg = nil } }, + { "NeogitPopupSectionTitle", { fg = colors.crystalBlue } }, + { "NeogitPopupConfigEnabled", { fg = colors.springBlue, italic = true } }, + { "NeogitPopupActionkey", { fg = colors.surimiOrange } }, + { "NeogitPopupConfigKey", { fg = colors.peachRed } }, + { "NeogitHunkHeader", { fg = colors.crystalBlue, bg = colors.sumiInk2 } }, + { "NeogitHunkHeaderHighlight", { fg = colors.roninYellow, bg = colors.sumiInk1 } }, + { "NeogitBranch", { fg = colors.autumnYellow, bold = true } }, + { "NeogitUnmergedInto", { fg = colors.surimiOrange, bold = true } }, + { "NeogitRemote", { fg = colors.carpYellow, bold = true } }, + { "NeogitDiffContext", { bg = colors.sumiInk3 } }, + { "NeogitDiffContextHighlight", { bg = colors.sumiInk4 } }, + { "NeogitCursorLine", { link = "CursorLine" } }, + { "NeogitDiffAdd", { fg = colors.autumnGreen, bg = colors.winterGreen } }, + { "NeogitDiffDelete", { fg = colors.autumnRed, bg = colors.winterRed } }, + { "NeogitDiffDeleteHighlight", { link = "DiffDelete" } }, + { + "NeogitDiffHeader", + { fg = colors.oniViolet, bg = colors.sumiInk0, bold = true }, + }, + { + "NeogitDiffHeaderHighlight", + { fg = colors.sakuraPink, bg = colors.sumiInk0, bold = true }, + }, + { "NeogitDiffAddHighlight", { link = "DiffAdd" } }, + { "NeogitStagedChanges", { fg = colors.surimiOrange, bold = true } }, + { "NeogitUnpulledChanges", { fg = colors.peachRed, bold = true } }, + { "NeogitUnmergedChanges", { fg = colors.springGreen, bold = true } }, + { "NeogitUnstagedChanges", { fg = colors.peachRed, bold = true } }, + { "NeogitUntrackedFiles", { fg = colors.peachRed, bold = true } }, + { "NeogitRecentCommits", { fg = colors.crystalBlue, bold = true } }, + { "NeogitCommitViewHeader", { fg = colors.crystalBlue, bold = true, italic = true } }, + { "NeogitFilePath", { fg = colors.autumnYellow, italic = true } }, + { "NeogitNotificationInfo", { fg = colors.springGreen, bold = true } }, + { "NeogitNotificationWarning", { fg = colors.roninYellow, bold = true } }, + { "NeogitNotificationError", { fg = colors.samuraiRed, bold = true } }, + { "menuSel", { bg = colors.sumiInk0, fg = "NONE" } }, + { "Pmenu", { fg = colors.fujiWhite, bg = colors.sumiInk2 } }, + { "CmpGhostText", { fg = colors.boatYellow1, italic = true } }, + { "CmpItemAbbrDeprecated", { fg = colors.fujiGray, bg = "NONE" } }, + { "CmpItemAbbrMatch", { fg = colors.crystalBlue, bg = "NONE" } }, + { "CmpItemAbbrMatchFuzzy", { fg = colors.crystalBlue, bg = "NONE" } }, + { "CmpItemMenu", { fg = colors.roninYellow, bg = "NONE" } }, + { "CmpItemKindField", { fg = colors.fujiWhite, bg = colors.sakuraPink } }, + { "CmpItemKindProperty", { fg = colors.fujiWhite, bg = colors.sakuraPink } }, + { "CmpItemKindEvent", { fg = colors.fujiWhite, bg = colors.sakuraPink } }, + { "CmpItemKindText", { fg = colors.fujiWhite, bg = colors.dragonBlue } }, + { "CmpItemKindEnum", { fg = colors.fujiWhite, bg = colors.crystalBlue } }, + { "CmpItemKindKeyword", { fg = colors.fujiWhite, bg = colors.springBlue } }, + { "CmpItemKindConstant", { fg = colors.fujiWhite, bg = colors.crystalBlue } }, + { "CmpItemKindConstructor", { fg = colors.fujiWhite, bg = colors.crystalBlue } }, + { "CmpItemKindReference", { fg = colors.fujiWhite, bg = colors.crystalBlue } }, + { "CmpItemKindFunction", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpItemKindStruct", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpItemKindClass", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpItemKindModule", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpItemKindOperator", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpItemKindVariable", { fg = colors.fujiWhite, bg = colors.roninYellow } }, + { "CmpItemKindFile", { fg = colors.fujiWhite, bg = colors.autumnYellow } }, + { "CmpItemKindUnit", { fg = colors.fujiWhite, bg = colors.autumnYellow } }, + { "CmpItemKindSnippet", { fg = colors.fujiWhite, bg = colors.autumnYellow } }, + { "CmpItemKindFolder", { fg = colors.fujiWhite, bg = colors.autumnYellow } }, + { "CmpItemKindMethod", { fg = colors.fujiWhite, bg = colors.autumnGreen } }, + { "CmpItemKindValue", { fg = colors.fujiWhite, bg = colors.autumnGreen } }, + { "CmpItemKindEnumMember", { fg = colors.fujiWhite, bg = colors.autumnGreen } }, + { "CmpItemKindInterface", { fg = colors.fujiWhite, bg = colors.waveRed } }, + { "CmpItemKindColor", { fg = colors.fujiWhite, bg = colors.waveAqua2 } }, + { "CmpItemKindTypeParameter", { fg = colors.fujiWhite, bg = colors.waveAqua2 } }, + { "CmpCustomSelectionColor", { bg = colors.sumiInk5 } }, + { "CmpCustomSelectionDadbodCompletion", { fg = colors.fujiWhite, bg = colors.oniViolet } }, + { "CmpCustomSelectionGit", { fg = colors.fujiWhite, bg = colors.roninYellow } }, + { "CmpCustomSelectionBuffer", { fg = colors.fujiWhite, bg = colors.springBlue } }, + { "CmpCustomSelectionPath", { fg = colors.fujiWhite, bg = colors.autumnYellow } }, + { "CmpCustomSelectionCalculator", { fg = colors.fujiWhite, bg = colors.waveBlue2 } }, + { "CmpCustomSelectionOrgmode", { fg = colors.fujiWhite, bg = colors.waveAqua1 } }, + { "CmpCustomSelectionEmoji", { fg = colors.fujiWhite, bg = colors.carpYellow } }, + { "CmpCustomSelectionZsh", { fg = colors.fujiWhite, bg = colors.springGreen } }, + { "CmpCustomSelectionCrates", { fg = colors.fujiWhite, bg = colors.roninYellow } }, + { "CmpCustomSelectionDocker", { fg = colors.fujiWhite, bg = colors.springBlue } }, + { "CmpCustomSelectionCmdHistory", { fg = colors.fujiWhite, bg = colors.waveBlue2 } }, + { "CmpCustomSelectionRipgrep", { fg = colors.fujiWhite, bg = colors.crystalBlue } }, + { "CmpCustomSelectionNpm", { fg = colors.fujiWhite, bg = colors.peachRed } }, + { "CmpCustomSelectionCommit", { fg = colors.fujiWhite, bg = colors.peachRed } }, + { "CmpCustomSelectionSnippet", { fg = colors.fujiWhite, bg = colors.peachRed } }, + { "CmpCustomSelectionLuaLatexSymbol", { fg = colors.fujiWhite, bg = colors.surimiOrange } }, + { "TelescopeNormal", { bg = colors.sumiInk2 } }, + { "TelescopeBorder", { bg = colors.sumiInk2, fg = colors.sumiInk1 } }, + { "TelescopePromptBorder", { bg = colors.sumiInk0, fg = colors.sumiInk0 } }, + { "TelescopePromptNormal", { bg = colors.sumiInk0, fg = colors.fujiWhite } }, + { "TelescopePromptTitle", { fg = colors.sumiInk0, bg = colors.oniViolet } }, + { "TelescopePreviewTitle", { fg = colors.sumiInk0, bg = colors.sakuraPink } }, + { "TelescopePreviewNormal", { bg = colors.sumiInk4 } }, + { "TelescopePreviewBorder", { link = "TelescopePreviewNormal" } }, + { "TelescopeResultsTitle", { fg = "NONE", bg = "NONE" } }, + { "MiniCursorword", { bg = colors.waveBlue2 } }, + { "MiniCursorwordCurrent", { bg = colors.waveBlue2 } }, + { "rainbowcol1", { fg = colors.oniViolet } }, + { "rainbowcol2", { fg = colors.crystalBlue } }, + { "rainbowcol3", { fg = colors.lightBlue } }, + { "rainbowcol4", { fg = colors.sakuraPink } }, + { "rainbowcol5", { fg = colors.springGreen } }, + { "rainbowcol6", { fg = colors.springViolet2 } }, + { "rainbowcol7", { fg = colors.carpYellow } }, + { "packerSuccess", { fg = colors.autumnGreen, bg = "NONE" } }, + { "NeoTreeNormal", { bg = colors.sumiInk1 } }, + { "NeoTreeNormalNC", { bg = colors.sumiInk1 } }, + { "NoiceCmdlineIconCmdline", { fg = colors.oniViolet } }, + { "NoiceCmdlinePopupBorderCmdline", { fg = colors.oniViolet } }, + { "NoiceCmdlineIconFilter", { fg = colors.springGreen } }, + { "NoiceCmdlinePopupBorderFilter", { fg = colors.springGreen } }, + { "NoiceCmdLineIconLua", { fg = colors.crystalBlue } }, + { "NoiceCmdlinePopupBorderLua", { fg = colors.crystalBlue } }, + { "NoiceCmdlineIconHelp", { fg = colors.surimiOrange } }, + { "NoiceCmdlinePopupBorderHelp", { fg = colors.surimiOrange } }, + { "NoiceCmdLineIconSearch", { fg = colors.roninYellow } }, + { "NoiceCmdlinePopupBorderSearch", { fg = colors.roninYellow } }, + { "NoiceCmdlineIconIncRename", { fg = colors.peachRed } }, + { "NoiceCmdlinePopupdBorderIncRename", { fg = colors.peachRed } }, + { "NoiceMini", { bg = colors.sumiInk4 } }, + { "NoiceLspProgressClient", { fg = colors.oniViolet, bold = true } }, + { "Folded", { underline = true, sp = colors.oniViolet, bg = "NONE" } }, + { "UfoFoldedBg", { bg = colors.waveBlue1 } }, + { "TSRainbowRed", { fg = colors.peachRed } }, + { "TSRainbowYellow", { fg = colors.carpYellow } }, + { "TSRainbowBlue", { fg = colors.crystalBlue } }, + { "TSRainbowGreen", { fg = colors.springGreen } }, + { "TSRainbowViolet", { fg = colors.oniViolet } }, + { "TSRainbowCyan", { fg = colors.lightBlue } }, + { "TreesitterContext", { bg = colors.sumiInk0 } }, + { "FloatTitle", { bg = "NONE" } }, + { "DiffviewFilePanelTitle", { fg = colors.crystalBlue } }, + { "LspInlayHint", { fg = colors.springViolet2, bg = colors.winterBlue } }, + { "@text", { fg = colors.fujiWhite } }, + { "RainbowDelimiterRed", { fg = colors.peachRed } }, + { "RainbowDelimiterYellow", { fg = colors.autumnYellow } }, + { "RainbowDelimiterBlue", { fg = colors.crystalBlue } }, + { "RainbowDelimiterOrange", { fg = colors.surimiOrange } }, + { "RainbowDelimiterGreen", { fg = colors.waveAqua1 } }, + { "RainbowDelimiterViolet", { fg = colors.oniViolet } }, + { "RainbowDelimiterCyan", { fg = colors.lightBlue } }, + { "NotifyERRORBorder", { link = "NvimNotifyError" } }, + { "NotifyERRORIcon", { link = "NvimNotifyError" } }, + { "NotifyERRORTitle", { link = "NvimNotifyError" } }, + { "NotifyWARNBorder", { link = "NvimNotifyWarn" } }, + { "NotifyWARNIcon", { link = "NvimNotifyWarn" } }, + { "NotifyWARNTitle", { link = "NvimNotifyWarn" } }, + { "NotifyINFOBorder", { link = "NvimNotifyInfo" } }, + { "NotifyINFOIcon", { link = "NvimNotifyInfo" } }, + { "NotifyINFOTitle", { link = "NvimNotifyInfo" } }, + { "NotifyDEBUGBorder", { link = "NvimNotifyDebug" } }, + { "NotifyDEBUGIcon", { link = "NvimNotifyDebug" } }, + { "NotifyDEBUGTitle", { link = "NvimNotifyDebug" } }, + { "NotifyTRACEBorder", { link = "NvimNotifyTrace" } }, + { "NotifyTRACEIcon", { link = "NvimNotifyTrace" } }, + { "NotifyTRACETitle", { link = "NvimNotifyTrace" } }, + { "NotificationInfo", { link = "NvimNotifyInfo" } }, + { "NotificationWarning", { link = "NvimNotifyWarn" } }, + { "NotificationError", { link = "NvimNotifyError" } }, + + + -- Markup specific + { "@markup.raw", { fg = colors.carpYellow, bg = colors.sumiInk2 } }, + { "@markup.raw.block", select_hl("@markup.raw", { "fg" }) }, + { "@markup.raw.delimiter", { link = "@punctuation.delimiter" } }, + { "CodeBlock", function() return { bg = get_hl("@markup.raw")().bg } end }, + { "Headline", { bg = colors.sumiInk0 } }, + { "@markup.list.checked", { fg = colors.springGreen } }, + { "@markup.list.indeterminate", { fg = colors.carpYellow } }, + { "@markup.list.unchecked", { fg = colors.crystalBlue } }, + { "@OrgTSCheckboxChecked.org", { link = "@markup.list.checked" } }, + { "@OrgTSCheckboxHalfChecked.org", { link = "@markup.list.indeterminate" } }, + { "@OrgTSCheckbox.org", { link = "@markup.list.unchecked" } }, + { "org_verbatim", { fg = colors.springGreen, bg = colors.sumiInk0 } }, + { "org_code", { link = "@markup.raw" } }, + { "@OrgTSBlock.org", { fg = colors.fujiGray, bold = true, italic = true } }, + { "@OrgTSDirective.org", { link = "@OrgTSBlock.org" } }, + + -- Titles/Headlines + { "@markup.heading.1", { fg = colors.crystalBlue, bold = true } }, + { "@markup.heading.2", { fg = colors.carpYellow, bold = true } }, + { "@markup.heading.3", { fg = colors.peachRed, bold = true } }, + { "@markup.heading.4", { fg = colors.surimiOrange, bold = true } }, + { "@markup.heading.5", { fg = colors.oniViolet2, bold = true } }, + { "@markup.heading.6", { fg = colors.sakuraPink, bold = true } }, + { "@markup.heading.7", { fg = colors.lightBlue, bold = true } }, + { "@markup.heading.8", { fg = colors.springGreen, bold = true } }, + { "@OrgTSHeadlineLevel1.org", { link = "@markup.heading.1" } }, + { "@OrgTSHeadlineLevel2.org", { link = "@markup.heading.2" } }, + { "@OrgTSHeadlineLevel3.org", { link = "@markup.heading.3" } }, + { "@OrgTSHeadlineLevel4.org", { link = "@markup.heading.4" } }, + { "@OrgTSHeadlineLevel5.org", { link = "@markup.heading.5" } }, + { "@OrgTSHeadlineLevel6.org", { link = "@markup.heading.6" } }, + { "@OrgTSHeadlineLevel7.org", { link = "@markup.heading.7" } }, + { "@OrgTSHeadlineLevel8.org", { link = "@markup.heading.8" } }, + { "@markup.heading.1.marker", { link = "@markup.heading.1" } }, + { "@markup.heading.2.marker", { link = "@markup.heading.2" } }, + { "@markup.heading.3.marker", { link = "@markup.heading.3" } }, + { "@markup.heading.4.marker", { link = "@markup.heading.4" } }, + { "@markup.heading.5.marker", { link = "@markup.heading.5" } }, + { "@markup.heading.6.marker", { link = "@markup.heading.6" } }, + { "@markup.heading.7.marker", { link = "@markup.heading.7" } }, + { "@markup.heading.8.marker", { link = "@markup.heading.8" } }, + { "@markup.quote", get_hl("@markup.quote", { italic = true }) }, + { "@markup.quote.org", get_hl("@markup.quote", { bg = colors.sumiInk5 }) }, + } + + vim.iter(extra_hls):enumerate():fold({}, function(t, index, tbl) + local hl_name = tbl[1] + local hl_opts = tbl[2] + if t[hl_name] then + vim.notify(string.format("Duplicate highlight '%s' defined at index '%d'!", hl_name, index), vim.log.levels.ERROR) + end + + if type(hl_opts) == "function" then + hl_opts = hl_opts() + end + if hl_opts.force == nil then + vim.tbl_deep_extend("force", hl_opts, { force = true }) + end + local success, err = pcall(vim.api.nvim_set_hl, 0, hl_name, hl_opts) + if not success then + vim.notify( + string.format( + "Failed to set highlight for '%s', err: '%s' ... Table:\n%s", + hl_name, + err, + vim.inspect(hl_opts) + ), + vim.log.levels.ERROR + ) + end + t[hl_name] = true + return t + end) end, }, } diff --git a/dots/.config/nvim/lua/plugins/configs/nvim-ufo.lua b/dots/.config/nvim/lua/plugins/configs/nvim-ufo.lua index d46c2459..235a1ef1 100644 --- a/dots/.config/nvim/lua/plugins/configs/nvim-ufo.lua +++ b/dots/.config/nvim/lua/plugins/configs/nvim-ufo.lua @@ -106,7 +106,7 @@ return { end curWidth = curWidth + chunkWidth end - table.insert(newVirtText, { suffix, "@conditional" }) + table.insert(newVirtText, { suffix, "@label" }) return newVirtText end diff --git a/dots/.config/nvim/lua/utils/funcs.lua b/dots/.config/nvim/lua/utils/funcs.lua index 2466f14a..4039f548 100755 --- a/dots/.config/nvim/lua/utils/funcs.lua +++ b/dots/.config/nvim/lua/utils/funcs.lua @@ -51,4 +51,65 @@ U.title_case = function(str) return string.gsub(str, "(%a)([%w_']*)", inner) end +---Get the effective given highlight, optionally overriding some of its fields +---@param name string Highlight name +---@param opts? vim.api.keyset.highlight +---@return fun(): vim.api.keyset.highlight +U.get_hl = function(name, opts) + ---@return vim.api.keyset.highlight + return function() + ---@diagnostic disable-next-line: return-type-mismatch + return vim.tbl_deep_extend("force", vim.api.nvim_get_hl(0, { name = name, link = false }), opts or {}) + end +end + +---@alias Highlight.Keys +---| '"bold"' +---| '"standout"' +---| '"strikethrough"' +---| '"underline"' +---| '"undercurl"' +---| '"underdouble"' +---| '"underdotted"' +---| '"underdashed"' +---| '"italic"' +---| '"reverse"' +---| '"altfont"' +---| '"nocombine"' +---| '"default"' +---| '"cterm"' +---| '"foreground"' +---| '"fg"' +---| '"background"' +---| '"bg"' +---| '"ctermfg"' +---| '"ctermbg"' +---| '"special"' +---| '"sp"' +---| '"link"' +---| '"global_link"' +---| '"fallback"' +---| '"blend"' +---| '"fg_indexed"' +---| '"bg_indexed"' +---| '"force"' +---| '"url"' + +---Get only the specified items from the highlight +---@param name string Highlight name +---@param fields Highlight.Keys[] +---@return fun(): vim.api.keyset.highlight +U.select_hl = function(name, fields) + ---@return vim.api.keyset.highlight + return function() + return vim.iter(U.get_hl(name)()):filter(function(k, _) + return vim.list_contains(fields, k) + end):fold({}, function(t, k, v) + t[k] = v + return t + end) + end +end + return U +