ease changing/adding highlight group colors

nvim_set_hl function from nvim v0.7 was used, now the highlight groups & their colors are in one whole table, can easily merge user highlghts override table, check https://nvchad.github.io/config/Custom%20config#override-default-highlights
This commit is contained in:
siduck 2022-05-01 21:24:33 +05:30
parent 841f839bb6
commit 89e271c095
2 changed files with 164 additions and 106 deletions

View File

@ -22,124 +22,182 @@ local red = colors.red
local white = colors.white local white = colors.white
local yellow = colors.yellow local yellow = colors.yellow
local orange = colors.orange local orange = colors.orange
local one_bg3 = colors.one_bg3
-- functions for setting highlights
local fg = require("core.utils").fg
local fg_bg = require("core.utils").fg_bg
local bg = require("core.utils").bg
-- Comments
fg("Comment", grey_fg)
-- Disable cursor line -- Disable cursor line
cmd "hi clear CursorLine" cmd "hi clear CursorLine"
-- Line number
fg("cursorlinenr", white)
-- same it bg, so it doesn't appear -- highlight groups & colors
fg("EndOfBuffer", black) local hl_cols = {
-- For floating windows Comment = { fg = grey_fg },
fg("FloatBorder", blue)
bg("NormalFloat", darker_black)
-- Pmenu -- line numbers
bg("Pmenu", one_bg) CursorLineNr = { fg = white },
bg("PmenuSbar", one_bg2) LineNr = { fg = grey },
bg("PmenuSel", pmenu_bg)
bg("PmenuThumb", nord_blue)
fg("CmpItemAbbr", white)
fg("CmpItemAbbrMatch", white)
fg("CmpItemKind", white)
fg("CmpItemMenu", white)
-- misc -- those ugly ~'s
EndOfBuffer = { fg = black },
-- inactive statuslines as thin lines -- floating windows
fg("StatusLineNC", one_bg3 .. " gui=underline") FloatBorder = { fg = blue },
NormalFloat = { bg = darker_black },
fg("LineNr", grey) -- Pmenu i.e completion menu
fg("NvimInternalError", red) Pmenu = { bg = one_bg },
fg("WinSeparator", one_bg2) PmenuSbar = { bg = one_bg2 },
PmenuSel = { bg = pmenu_bg, fg = black },
PmenuThumb = { bg = nord_blue },
if ui.transparency then -- nvim cmp
bg("Normal", "NONE") CmpItemAbbr = { fg = white },
bg("Folded", "NONE") CmpItemAbbrMatch = { fg = white },
fg("Folded", "NONE") CmpItemKind = { fg = white },
fg("Comment", grey) CmpItemMenu = { fg = white },
end
-- [[ Plugin Highlights NvimInternalError = { fg = red },
WinSeparator = { fg = one_bg2 },
-- Dashboard -- Dashboard i.e alpha.nvim
fg("AlphaHeader", grey_fg) AlphaHeader = { fg = grey_fg },
fg("AlphaButtons", light_grey) AlphaButtons = { fg = light_grey },
-- Git signs -- Gitsigns.nvim
fg_bg("DiffAdd", blue, "NONE") DiffAdd = {
fg_bg("DiffChange", grey_fg, "NONE") fg = blue,
fg_bg("DiffChangeDelete", red, "NONE") bg = "NONE",
fg_bg("DiffModified", red, "NONE") },
fg_bg("DiffDelete", red, "NONE")
-- Indent blankline plugin DiffChange = {
fg("IndentBlanklineChar", line) fg = light_grey,
fg("IndentBlanklineSpaceChar", line) bg = "NONE",
},
-- Lsp diagnostics DiffChangeDelete = {
fg = red,
bg = "NONE",
},
fg("DiagnosticHint", purple) DiffModified = {
fg("DiagnosticError", red) fg = orange,
fg("DiagnosticWarn", yellow) bg = "NONE",
fg("DiagnosticInformation", green) },
DiffDelete = {
fg = red,
bg = "NONE",
},
-- Indent blankline
IndentBlanklineChar = { fg = line },
IndentBlanklineSpaceChar = { fg = line },
-- Lsp Diagnostics
DiagnosticHint = { fg = purple },
DiagnosticError = { fg = red },
DiagnosticWarn = { fg = yellow },
DiagnosticInformation = { fg = green },
-- NvimTree -- NvimTree
fg("NvimTreeEmptyFolderName", folder_bg) NvimTreeEmptyFolderName = { fg = folder_bg },
fg("NvimTreeEndOfBuffer", darker_black) NvimTreeEndOfBuffer = { fg = darker_black },
fg("NvimTreeFolderIcon", folder_bg) NvimTreeFolderIcon = { fg = folder_bg },
fg("NvimTreeFolderName", folder_bg) NvimTreeFolderName = { fg = folder_bg },
fg("NvimTreeGitDirty", red) NvimTreeGitDirty = { fg = red },
fg("NvimTreeIndentMarker", one_bg2) NvimTreeIndentMarker = { fg = one_bg2 },
bg("NvimTreeNormal", darker_black) NvimTreeNormal = { bg = darker_black },
bg("NvimTreeNormalNC", darker_black) NvimTreeNormalNC = { bg = darker_black },
fg("NvimTreeOpenedFolderName", folder_bg) NvimTreeOpenedFolderName = { fg = folder_bg },
fg("NvimTreeRootFolder", red .. " gui=underline") -- enable underline for root folder in nvim tree
fg_bg("NvimTreeStatuslineNc", darker_black, darker_black) NvimTreeWinSeparator = {
fg_bg("NvimTreeWinSeparator", darker_black, darker_black) fg = darker_black,
fg_bg("NvimTreeWindowPicker", red, black2) bg = darker_black,
},
NvimTreeWindowPicker = {
fg = red,
bg = black2,
},
-- Telescope -- Telescope
fg_bg("TelescopeBorder", darker_black, darker_black) TelescopeBorder = {
fg_bg("TelescopePromptBorder", black2, black2) fg = darker_black,
bg = darker_black,
},
fg_bg("TelescopePromptNormal", white, black2) TelescopePromptBorder = {
fg_bg("TelescopePromptPrefix", red, black2) fg = black2,
bg = black2,
},
bg("TelescopeNormal", darker_black) TelescopePromptNormal = {
fg = white,
bg = black2,
},
fg_bg("TelescopePreviewTitle", black, green) TelescopePromptPrefix = {
fg_bg("TelescopePromptTitle", black, red) fg = red,
fg_bg("TelescopeResultsTitle", darker_black, darker_black) bg = black2,
},
bg("TelescopeSelection", black2) TelescopeNormal = { bg = darker_black },
TelescopePreviewTitle = {
fg = black,
bg = green,
},
TelescopePromptTitle = {
fg = black,
bg = red,
},
TelescopeResultsTitle = {
fg = darker_black,
bg = darker_black,
},
TelescopeSelection = { bg = black2 },
}
-- Disable some highlight in nvim tree if transparency enabled
if ui.transparency then if ui.transparency then
bg("NormalFloat", "NONE") local hl_groups = {
bg("NvimTreeNormal", "NONE") "NormalFloat",
bg("NvimTreeNormalNC", "NONE") "Normal",
bg("NvimTreeStatusLineNC", "NONE") "Folded",
fg_bg("NvimTreeWinSeparator", grey, "NONE") "NvimTreeNormal",
"NvimTreeNormalNC",
"TelescopeNormal",
"TelescopePrompt",
"TelescopeResults",
"TelescopeBorder",
"TelescopePromptBorder",
"TelescopePromptNormal",
"TelescopePromptPrefix",
}
-- telescope for index, _ in ipairs(hl_groups) do
bg("TelescopeBorder", "NONE") hl_cols[hl_groups[index]] = {
bg("TelescopePrompt", "NONE") bg = "NONE",
bg("TelescopeResults", "NONE") }
bg("TelescopePromptBorder", "NONE") end
bg("TelescopePromptNormal", "NONE")
bg("TelescopeNormal", "NONE") hl_cols.NvimTreeWinSeparator = {
bg("TelescopePromptPrefix", "NONE") fg = grey,
fg("TelescopeBorder", one_bg) bg = "NONE",
fg_bg("TelescopeResultsTitle", black, blue) }
hl_cols.TelescopeResultsTitle = {
fg = black,
bg = blue,
}
end
local utils = require "core.utils"
local user_highlights = utils.load_config().ui.hl_override
-- override user highlights if there are any
hl_cols = vim.tbl_deep_extend("force", hl_cols, user_highlights)
for hl, col in pairs(hl_cols) do
vim.api.nvim_set_hl(0, hl, col)
end end

View File

@ -18,7 +18,7 @@ M.options = {
---- UI ----- ---- UI -----
M.ui = { M.ui = {
hl_override = "", hl_override = {},
colors = "", -- path of your file that contains colors colors = "", -- path of your file that contains colors
theme = "onedark", -- default theme theme = "onedark", -- default theme
transparency = false, transparency = false,