mirror of
https://github.com/gabehf/base46.git
synced 2026-03-09 07:28:50 -07:00
allow lazy loading of highlight groups
This commit is contained in:
parent
674d6bb3c4
commit
5db0e3ee99
14 changed files with 157 additions and 208 deletions
|
|
@ -1,7 +1,6 @@
|
|||
local ui = require("core.utils").load_config().ui
|
||||
|
||||
local merge_tb = require("base46").merge_tb
|
||||
|
||||
local ui = require("core.utils").load_config().ui
|
||||
local highlights = {}
|
||||
local hl_dir = vim.fn.stdpath "data" .. "/site/pack/packer/opt/base46/lua/base46/integrations"
|
||||
|
||||
|
|
@ -51,7 +50,4 @@ if vim.g.transparency then
|
|||
highlights = merge_tb(highlights, require "base46.glassy")
|
||||
end
|
||||
|
||||
-- finally set all highlights :D
|
||||
for hl, col in pairs(highlights) do
|
||||
vim.api.nvim_set_hl(0, hl, col)
|
||||
end
|
||||
return highlights
|
||||
|
|
|
|||
|
|
@ -41,23 +41,53 @@ M.clear_highlights = function(hl_group)
|
|||
end
|
||||
end
|
||||
|
||||
M.load_theme = function()
|
||||
-- set bg option
|
||||
local theme_type = M.get_theme_tb(g.nvchad_theme, "type") -- dark/light
|
||||
vim.opt.bg = theme_type
|
||||
|
||||
M.load_all_highlights = function()
|
||||
-- reload highlights for theme switcher
|
||||
local reload = require("plenary.reload").reload_module
|
||||
local clear_hl = require("base46").clear_highlights
|
||||
|
||||
clear_hl "BufferLine"
|
||||
clear_hl "TS"
|
||||
|
||||
-- reload highlights for theme switcher
|
||||
reload "base46.integrations"
|
||||
reload "base46.chadlights"
|
||||
|
||||
require "base46.term"
|
||||
require "base46.chadlights"
|
||||
local hl_groups = require "base46.chadlights"
|
||||
|
||||
for hl, col in pairs(hl_groups) do
|
||||
vim.api.nvim_set_hl(0, hl, col)
|
||||
end
|
||||
end
|
||||
|
||||
M.load_highlight = function(group)
|
||||
local default_hl = require("base46.integrations." .. group)
|
||||
local user_hl = config.ui.hl_override
|
||||
|
||||
if vim.g.transparency then
|
||||
user_hl = M.merge_tb(user_hl, require "base46.glassy")
|
||||
end
|
||||
|
||||
for key, value in pairs(user_hl) do
|
||||
if default_hl[key] then
|
||||
default_hl[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
for hl, col in pairs(default_hl) do
|
||||
vim.api.nvim_set_hl(0, hl, col)
|
||||
end
|
||||
end
|
||||
|
||||
M.load_theme = function()
|
||||
-- set bg option
|
||||
local theme_type = M.get_theme_tb(g.nvchad_theme, "type") -- dark/light
|
||||
vim.opt.bg = theme_type
|
||||
|
||||
if vim.g.theme_switcher_loaded then
|
||||
M.load_all_highlights()
|
||||
end
|
||||
|
||||
M.load_highlight "defaults"
|
||||
end
|
||||
|
||||
M.override_theme = function(default_theme, theme_name)
|
||||
|
|
@ -100,7 +130,7 @@ M.toggle_theme = function()
|
|||
end
|
||||
|
||||
M.toggle_transparency = function()
|
||||
local transparency_status = require("core.utils").load_config().ui.transparency
|
||||
local transparency_status = config.ui.transparency
|
||||
local write_data = require("nvchad").write_data
|
||||
|
||||
local function save_chadrc_data()
|
||||
|
|
@ -113,12 +143,12 @@ M.toggle_transparency = function()
|
|||
if g.transparency then
|
||||
g.transparency = false
|
||||
|
||||
M.load_theme()
|
||||
M.load_all_highlights()
|
||||
save_chadrc_data()
|
||||
else
|
||||
g.transparency = true
|
||||
|
||||
M.load_theme()
|
||||
M.load_all_highlights()
|
||||
save_chadrc_data()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
lua/base46/integrations/alpha.lua
Normal file
6
lua/base46/integrations/alpha.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
AlphaHeader = { fg = colors.grey_fg },
|
||||
AlphaButtons = { fg = colors.light_grey },
|
||||
}
|
||||
6
lua/base46/integrations/blankline.lua
Normal file
6
lua/base46/integrations/blankline.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
IndentBlanklineChar = { fg = colors.line },
|
||||
IndentBlanklineSpaceChar = { fg = colors.line },
|
||||
}
|
||||
|
|
@ -1,6 +1,34 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
local theme = require("base46").get_colors "base_16"
|
||||
|
||||
return {
|
||||
MatchWord = {
|
||||
bg = colors.grey,
|
||||
fg = colors.white,
|
||||
},
|
||||
|
||||
Pmenu = { bg = colors.one_bg },
|
||||
PmenuSbar = { bg = colors.one_bg },
|
||||
PmenuSel = { bg = colors.pmenu_bg, fg = colors.black },
|
||||
PmenuThumb = { bg = colors.grey },
|
||||
|
||||
MatchParen = { link = "MatchWord" },
|
||||
|
||||
Comment = { fg = colors.grey_fg },
|
||||
|
||||
CursorLineNr = { fg = colors.white },
|
||||
LineNr = { fg = colors.grey },
|
||||
|
||||
-- floating windows
|
||||
FloatBorder = { fg = colors.blue },
|
||||
NormalFloat = { bg = colors.darker_black },
|
||||
|
||||
NvimInternalError = { fg = colors.red },
|
||||
WinSeparator = { fg = colors.line },
|
||||
|
||||
-- packer
|
||||
packerPackageName = { fg = colors.red },
|
||||
|
||||
Normal = {
|
||||
fg = theme.base05,
|
||||
bg = theme.base00,
|
||||
|
|
@ -151,7 +179,6 @@ return {
|
|||
},
|
||||
|
||||
-- spell
|
||||
|
||||
SpellBad = {
|
||||
undercurl = true,
|
||||
sp = theme.base08,
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
local theme = require("base46").get_colors "base_16"
|
||||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
|
||||
|
|
@ -66,4 +67,33 @@ return {
|
|||
fg = theme.base0B,
|
||||
bold = true,
|
||||
},
|
||||
|
||||
-- Gitsigns.nvim
|
||||
DiffAdd = {
|
||||
fg = colors.blue,
|
||||
},
|
||||
|
||||
DiffAdded = {
|
||||
fg = colors.green,
|
||||
},
|
||||
|
||||
DiffChange = {
|
||||
fg = colors.light_grey,
|
||||
},
|
||||
|
||||
DiffChangeDelete = {
|
||||
fg = colors.red,
|
||||
},
|
||||
|
||||
DiffModified = {
|
||||
fg = colors.orange,
|
||||
},
|
||||
|
||||
DiffDelete = {
|
||||
fg = colors.red,
|
||||
},
|
||||
|
||||
DiffRemoved = {
|
||||
fg = colors.red,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
local base16 = require("base46").get_colors "base_16"
|
||||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
-- nvim Gps
|
||||
GpsItemAbbr = { fg = colors.white, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemAbbrMatch = { fg = colors.blue, bold = true, bg = colors.statusline_bg },
|
||||
GpsBorder = { fg = colors.grey, bg = colors.statusline_bg, bold = true },
|
||||
GpsDocBorder = { fg = colors.grey, bg = colors.statusline_bg, bold = true },
|
||||
|
||||
-- Gps item kinds
|
||||
GpsItemKindConstant = { fg = base16.base09, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindFunction = { fg = base16.base0D, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindIdentifier = { fg = base16.base08, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindField = { fg = base16.base08, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindVariable = { fg = base16.base0E, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindSnippet = { fg = colors.red, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindText = { fg = base16.base0B, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindStructure = { fg = base16.base0E, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindType = { fg = base16.base0A, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindKeyword = { fg = base16.base07, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindMethod = { fg = base16.base0D, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindConstructor = { fg = colors.blue, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindFolder = { fg = base16.base07, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindModule = { fg = base16.base0A, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindProperty = { fg = base16.base08, bg = colors.statusline_bg, bold = true },
|
||||
-- GpsItemKindEnum = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
GpsItemKindUnit = { fg = base16.base0E, bg = colors.statusline_bg, bold = true },
|
||||
-- GpsItemKindClass = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
GpsItemKindFile = { fg = base16.base07, bg = colors.statusline_bg, bold = true },
|
||||
-- GpsItemKindInterface = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
GpsItemKindColor = { fg = colors.red, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindReference = { fg = base16.base05, bg = colors.statusline_bg, bold = true },
|
||||
-- GpsItemKindEnumMember = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
GpsItemKindStruct = { fg = base16.base0E, bg = colors.statusline_bg, bold = true },
|
||||
-- GpsItemKindValue = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
-- GpsItemKindEvent = { fg = "", bg = colors.statusline_bg, bold = true},
|
||||
GpsItemKindOperator = { fg = base16.base05, bg = colors.statusline_bg, bold = true },
|
||||
GpsItemKindTypeParameter = { fg = base16.base08, bg = colors.statusline_bg, bold = true },
|
||||
}
|
||||
18
lua/base46/integrations/lsp.lua
Normal file
18
lua/base46/integrations/lsp.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
-- LSP References
|
||||
LspReferenceText = { fg = colors.darker_black, bg = colors.white },
|
||||
LspReferenceRead = { fg = colors.darker_black, bg = colors.white },
|
||||
LspReferenceWrite = { fg = colors.darker_black, bg = colors.white },
|
||||
|
||||
-- Lsp Diagnostics
|
||||
DiagnosticHint = { fg = colors.purple },
|
||||
DiagnosticError = { fg = colors.red },
|
||||
DiagnosticWarn = { fg = colors.yellow },
|
||||
DiagnosticInformation = { fg = colors.green },
|
||||
LspSignatureActiveParameter = { fg = colors.black, bg = colors.green },
|
||||
|
||||
RenamerTitle = { fg = colors.black, bg = colors.red },
|
||||
RenamerBorder = { fg = colors.red },
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
local theme = require("base46").get_colors "base_16"
|
||||
|
||||
return {
|
||||
mailQuoted1 = {
|
||||
fg = theme.base0A,
|
||||
},
|
||||
|
||||
mailQuoted2 = {
|
||||
fg = theme.base0B,
|
||||
},
|
||||
|
||||
mailQuoted3 = {
|
||||
fg = theme.base0E,
|
||||
},
|
||||
|
||||
mailQuoted4 = {
|
||||
fg = theme.base0C,
|
||||
},
|
||||
|
||||
mailQuoted5 = {
|
||||
fg = theme.base0D,
|
||||
},
|
||||
|
||||
mailQuoted6 = {
|
||||
fg = theme.base0A,
|
||||
},
|
||||
|
||||
mailURL = {
|
||||
fg = theme.base0D,
|
||||
},
|
||||
|
||||
mailEmail = {
|
||||
fg = theme.base0D,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
local black = colors.black
|
||||
local blue = colors.blue
|
||||
local darker_black = colors.darker_black
|
||||
local green = colors.green
|
||||
local grey = colors.grey
|
||||
local grey_fg = colors.grey_fg
|
||||
local light_grey = colors.light_grey
|
||||
local line = colors.line
|
||||
local one_bg = colors.one_bg
|
||||
local pmenu_bg = colors.pmenu_bg
|
||||
local purple = colors.purple
|
||||
local red = colors.red
|
||||
local white = colors.white
|
||||
local yellow = colors.yellow
|
||||
local orange = colors.orange
|
||||
|
||||
-- highlight groups & colors
|
||||
return {
|
||||
|
||||
Comment = { fg = grey_fg },
|
||||
|
||||
-- line numbers
|
||||
CursorLineNr = { fg = white },
|
||||
LineNr = { fg = grey },
|
||||
|
||||
-- those ugly ~'s
|
||||
EndOfBuffer = { fg = black },
|
||||
|
||||
-- floating windows
|
||||
FloatBorder = { fg = blue },
|
||||
NormalFloat = { bg = darker_black },
|
||||
|
||||
-- Renamer
|
||||
|
||||
RenamerTitle = { fg = black, bg = red },
|
||||
RenamerBorder = { fg = red },
|
||||
|
||||
-- Pmenu i.e completion menu
|
||||
Pmenu = { bg = one_bg },
|
||||
PmenuSbar = { bg = one_bg },
|
||||
PmenuSel = { bg = pmenu_bg, fg = black },
|
||||
PmenuThumb = { bg = grey },
|
||||
|
||||
NvimInternalError = { fg = red },
|
||||
WinSeparator = { fg = line },
|
||||
|
||||
-- Dashboard i.e alpha.nvim
|
||||
AlphaHeader = { fg = grey_fg },
|
||||
AlphaButtons = { fg = light_grey },
|
||||
|
||||
-- Gitsigns.nvim
|
||||
DiffAdd = {
|
||||
fg = blue,
|
||||
},
|
||||
|
||||
DiffAdded = {
|
||||
fg = green,
|
||||
},
|
||||
|
||||
DiffChange = {
|
||||
fg = light_grey,
|
||||
},
|
||||
|
||||
DiffChangeDelete = {
|
||||
fg = red,
|
||||
},
|
||||
|
||||
DiffModified = {
|
||||
fg = orange,
|
||||
},
|
||||
|
||||
DiffDelete = {
|
||||
fg = red,
|
||||
},
|
||||
|
||||
DiffRemoved = {
|
||||
fg = red,
|
||||
},
|
||||
|
||||
-- Indent blankline
|
||||
IndentBlanklineChar = { fg = line },
|
||||
IndentBlanklineSpaceChar = { fg = line },
|
||||
|
||||
-- LSP References
|
||||
LspReferenceText = { fg = darker_black, bg = white },
|
||||
LspReferenceRead = { fg = darker_black, bg = white },
|
||||
LspReferenceWrite = { fg = darker_black, bg = white },
|
||||
|
||||
-- Lsp Diagnostics
|
||||
DiagnosticHint = { fg = purple },
|
||||
DiagnosticError = { fg = red },
|
||||
DiagnosticWarn = { fg = yellow },
|
||||
DiagnosticInformation = { fg = green },
|
||||
|
||||
-- whichkey
|
||||
WhichKey = { fg = blue },
|
||||
WhichKeySeparator = { fg = light_grey },
|
||||
WhichKeyDesc = { fg = red },
|
||||
WhichKeyGroup = { fg = green },
|
||||
WhichKeyValue = { fg = green },
|
||||
|
||||
-- packer
|
||||
packerPackageName = { fg = red },
|
||||
|
||||
-- vim-matchup
|
||||
MatchWord = {
|
||||
bg = grey,
|
||||
fg = white,
|
||||
},
|
||||
|
||||
MatchParen = { link = "MatchWord" },
|
||||
}
|
||||
|
|
@ -25,4 +25,8 @@ return {
|
|||
NvimTreeCursorLine = {
|
||||
bg = colors.black2,
|
||||
},
|
||||
|
||||
NvimTreeGitNew = {
|
||||
fg = colors.yellow,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,16 @@ return {
|
|||
},
|
||||
|
||||
TelescopeSelection = { bg = colors.black2, fg = colors.white },
|
||||
|
||||
TelescopeResultsDiffAdd = {
|
||||
fg = colors.green,
|
||||
},
|
||||
|
||||
TelescopeResultsDiffChange = {
|
||||
fg = colors.yellow,
|
||||
},
|
||||
|
||||
TelescopeResultsDiffDelete = {
|
||||
fg = colors.red,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
9
lua/base46/integrations/whichkey.lua
Normal file
9
lua/base46/integrations/whichkey.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
local colors = require("base46").get_colors "base_30"
|
||||
|
||||
return {
|
||||
WhichKey = { fg = colors.blue },
|
||||
WhichKeySeparator = { fg = colors.light_grey },
|
||||
WhichKeyDesc = { fg = colors.red },
|
||||
WhichKeyGroup = { fg = colors.green },
|
||||
WhichKeyValue = { fg = colors.green },
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
local colors = require("base46").get_colors "base_16"
|
||||
|
||||
vim.g.terminal_color_0 = colors.base00
|
||||
vim.g.terminal_color_0 = colors.base02
|
||||
vim.g.terminal_color_1 = colors.base08
|
||||
vim.g.terminal_color_2 = colors.base0B
|
||||
vim.g.terminal_color_3 = colors.base0A
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue