From c6a9f4c5331423435ee1cfe1083b73cabdf3ea40 Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 17 Nov 2022 19:27:47 +0530 Subject: [PATCH] add module for compiling highlight groups & their colors --- lua/base46/init.lua | 40 ++- lua/base46/integrations/defaults.lua | 321 +++++++++++++++++++++++++ lua/base46/integrations/statusline.lua | 208 ---------------- lua/base46/integrations/syntax.lua | 118 --------- 4 files changed, 356 insertions(+), 331 deletions(-) delete mode 100644 lua/base46/integrations/statusline.lua delete mode 100644 lua/base46/integrations/syntax.lua diff --git a/lua/base46/init.lua b/lua/base46/init.lua index 5c3ab9f..282769b 100644 --- a/lua/base46/init.lua +++ b/lua/base46/init.lua @@ -99,11 +99,41 @@ M.load_highlight = function(group) end end -M.load_theme = function() - M.load_highlight "defaults" - M.load_highlight "statusline" - M.load_highlight "syntax" - M.load_highlight(M.turn_str_to_color(config.ui.hl_add)) +-- save table +M.table_to_file = function(filename, tb) + local file = io.open(filename, "w") + local result = "" + + for hlgroupName, hlgroup_vals in pairs(tb) do + local hlname = "'" .. hlgroupName .. "'," + local opts = "" + + for optName, optVal in pairs(hlgroup_vals) do + local valueInStr = type(optVal) == "boolean" and " " .. tostring(optVal) or '"' .. optVal .. '"' + opts = opts .. optName .. "=" .. valueInStr .. "," + end + + result = result .. "vim.api.nvim_set_hl(0," .. hlname .. "{" .. opts .. "})" + end + + if file then + file:write(result) + file:close() + end +end + +-- M.load_highlight(M.turn_str_to_color(config.ui.hl_add)) + +M.compile = function() + local hl_files = vim.fn.stdpath "data" .. "/site/pack/packer/start/base46/lua/base46/integrations" + + for _, file in ipairs(vim.fn.readdir(hl_files)) do + local integration = require("base46.integrations." .. vim.fn.fnamemodify(file, ":r")) + M.table_to_file( + vim.fn.stdpath "data" .. "/site/pack/packer/start/base46_cache/lua/base46_cache/" .. file, + integration + ) + end end M.override_theme = function(default_theme, theme_name) diff --git a/lua/base46/integrations/defaults.lua b/lua/base46/integrations/defaults.lua index 183329c..e334346 100644 --- a/lua/base46/integrations/defaults.lua +++ b/lua/base46/integrations/defaults.lua @@ -210,4 +210,325 @@ return { bg = colors.green, fg = colors.black, }, + + ------------------------------------- Syntax ---------------------------------------------- + + Boolean = { + fg = theme.base09, + }, + + Character = { + fg = theme.base08, + }, + + Conditional = { + fg = theme.base0E, + }, + + Constant = { + fg = theme.base08, + }, + + Define = { + fg = theme.base0E, + sp = "none", + }, + + Delimiter = { + fg = theme.base0F, + }, + + Float = { + fg = theme.base09, + }, + + Variable = { + fg = theme.base05, + }, + + Function = { + fg = theme.base0D, + }, + + Identifier = { + fg = theme.base08, + sp = "none", + }, + + Include = { + fg = theme.base0D, + }, + + Keyword = { + fg = theme.base0E, + }, + + Label = { + fg = theme.base0A, + }, + + Number = { + fg = theme.base09, + }, + + Operator = { + fg = theme.base05, + sp = "none", + }, + + PreProc = { + fg = theme.base0A, + }, + + Repeat = { + fg = theme.base0A, + }, + + Special = { + fg = theme.base0C, + }, + + SpecialChar = { + fg = theme.base0F, + }, + + Statement = { + fg = theme.base08, + }, + + StorageClass = { + fg = theme.base0A, + }, + + String = { + fg = theme.base0B, + }, + + Structure = { + fg = theme.base0E, + }, + + Tag = { + fg = theme.base0A, + }, + + Todo = { + fg = theme.base0A, + bg = theme.base01, + }, + + Type = { + fg = theme.base0A, + sp = "none", + }, + + Typedef = { + fg = theme.base0A, + }, + + ------------------------------------- Statusline ---------------------------------------------- + + StatusLine = { + bg = colors.statusline_bg, + }, + + St_gitIcons = { + fg = colors.light_grey, + bg = colors.statusline_bg, + bold = true, + }, + + -- LSP + + St_lspError = { + fg = colors.red, + bg = colors.statusline_bg, + }, + + St_lspWarning = { + fg = colors.yellow, + bg = colors.statusline_bg, + }, + + St_LspHints = { + fg = colors.purple, + bg = colors.statusline_bg, + }, + + St_LspInfo = { + fg = colors.green, + bg = colors.statusline_bg, + }, + + St_LspStatus = { + fg = colors.nord_blue, + bg = colors.statusline_bg, + }, + + St_LspProgress = { + fg = colors.green, + bg = colors.statusline_bg, + }, + + St_LspStatus_Icon = { + fg = colors.black, + bg = colors.nord_blue, + }, + + -- MODES + + St_NormalMode = { + bg = colors.nord_blue, + fg = colors.black, + bold = true, + }, + + St_InsertMode = { + bg = colors.dark_purple, + fg = colors.black, + + bold = true, + }, + + St_TerminalMode = { + bg = colors.green, + fg = colors.black, + bold = true, + }, + + St_NTerminalMode = { + bg = colors.yellow, + fg = colors.black, + bold = true, + }, + + St_VisualMode = { + bg = colors.cyan, + fg = colors.black, + bold = true, + }, + + St_ReplaceMode = { + bg = colors.orange, + fg = colors.black, + + bold = true, + }, + + St_ConfirmMode = { + bg = colors.teal, + fg = colors.black, + + bold = true, + }, + + St_CommandMode = { + bg = colors.green, + fg = colors.black, + + bold = true, + }, + + St_SelectMode = { + bg = colors.nord_blue, + fg = colors.black, + + bold = true, + }, + + -- Separators for mode + St_NormalModeSep = { + fg = colors.nord_blue, + bg = colors.grey, + }, + + St_InsertModeSep = { + fg = colors.dark_purple, + bg = colors.grey, + }, + + St_TerminalModeSep = { + fg = colors.green, + bg = colors.grey, + }, + + St_NTerminalModeSep = { + fg = colors.yellow, + bg = colors.grey, + }, + + St_VisualModeSep = { + fg = colors.cyan, + bg = colors.grey, + }, + + St_ReplaceModeSep = { + fg = colors.orange, + bg = colors.grey, + }, + + St_ConfirmModeSep = { + fg = colors.teal, + bg = colors.grey, + }, + + St_CommandModeSep = { + fg = colors.green, + bg = colors.grey, + }, + + St_SelectModeSep = { + fg = colors.nord_blue, + bg = colors.grey, + }, + + St_EmptySpace = { + fg = colors.grey, + bg = colors.lightbg, + }, + + St_EmptySpace2 = { + fg = colors.grey, + bg = colors.statusline_bg, + }, + + St_file_info = { + bg = colors.lightbg, + fg = colors.white, + }, + + St_file_sep = { + bg = colors.statusline_bg, + fg = colors.lightbg, + }, + + St_cwd_icon = { + fg = colors.one_bg, + bg = colors.red, + }, + + St_cwd_text = { + fg = colors.white, + bg = colors.lightbg, + }, + + St_cwd_sep = { + fg = colors.red, + bg = colors.statusline_bg, + }, + + St_pos_sep = { + fg = colors.green, + bg = colors.lightbg, + }, + + St_pos_icon = { + fg = colors.black, + bg = colors.green, + }, + + St_pos_text = { + fg = colors.green, + bg = colors.lightbg, + }, } diff --git a/lua/base46/integrations/statusline.lua b/lua/base46/integrations/statusline.lua deleted file mode 100644 index 3e08c81..0000000 --- a/lua/base46/integrations/statusline.lua +++ /dev/null @@ -1,208 +0,0 @@ -local colors = require("base46").get_theme_tb "base_30" - -return { - - StatusLine = { - bg = colors.statusline_bg, - }, - - St_gitIcons = { - fg = colors.light_grey, - bg = colors.statusline_bg, - bold = true, - }, - - -- LSP - - St_lspError = { - fg = colors.red, - bg = colors.statusline_bg, - }, - - St_lspWarning = { - fg = colors.yellow, - bg = colors.statusline_bg, - }, - - St_LspHints = { - fg = colors.purple, - bg = colors.statusline_bg, - }, - - St_LspInfo = { - fg = colors.green, - bg = colors.statusline_bg, - }, - - St_LspStatus = { - fg = colors.nord_blue, - bg = colors.statusline_bg, - }, - - St_LspProgress = { - fg = colors.green, - bg = colors.statusline_bg, - }, - - St_LspStatus_Icon = { - fg = colors.black, - bg = colors.nord_blue, - }, - - -- MODES - - St_NormalMode = { - bg = colors.nord_blue, - fg = colors.black, - bold = true, - }, - - St_InsertMode = { - bg = colors.dark_purple, - fg = colors.black, - - bold = true, - }, - - St_TerminalMode = { - bg = colors.green, - fg = colors.black, - bold = true, - }, - - St_NTerminalMode = { - bg = colors.yellow, - fg = colors.black, - bold = true, - }, - - St_VisualMode = { - bg = colors.cyan, - fg = colors.black, - bold = true, - }, - - St_ReplaceMode = { - bg = colors.orange, - fg = colors.black, - - bold = true, - }, - - St_ConfirmMode = { - bg = colors.teal, - fg = colors.black, - - bold = true, - }, - - St_CommandMode = { - bg = colors.green, - fg = colors.black, - - bold = true, - }, - - St_SelectMode = { - bg = colors.nord_blue, - fg = colors.black, - - bold = true, - }, - - -- Separators for mode - St_NormalModeSep = { - fg = colors.nord_blue, - bg = colors.grey, - }, - - St_InsertModeSep = { - fg = colors.dark_purple, - bg = colors.grey, - }, - - St_TerminalModeSep = { - fg = colors.green, - bg = colors.grey, - }, - - St_NTerminalModeSep = { - fg = colors.yellow, - bg = colors.grey, - }, - - St_VisualModeSep = { - fg = colors.cyan, - bg = colors.grey, - }, - - St_ReplaceModeSep = { - fg = colors.orange, - bg = colors.grey, - }, - - St_ConfirmModeSep = { - fg = colors.teal, - bg = colors.grey, - }, - - St_CommandModeSep = { - fg = colors.green, - bg = colors.grey, - }, - - St_SelectModeSep = { - fg = colors.nord_blue, - bg = colors.grey, - }, - - St_EmptySpace = { - fg = colors.grey, - bg = colors.lightbg, - }, - - St_EmptySpace2 = { - fg = colors.grey, - bg = colors.statusline_bg, - }, - - St_file_info = { - bg = colors.lightbg, - fg = colors.white, - }, - - St_file_sep = { - bg = colors.statusline_bg, - fg = colors.lightbg, - }, - - St_cwd_icon = { - fg = colors.one_bg, - bg = colors.red, - }, - - St_cwd_text = { - fg = colors.white, - bg = colors.lightbg, - }, - - St_cwd_sep = { - fg = colors.red, - bg = colors.statusline_bg, - }, - - St_pos_sep = { - fg = colors.green, - bg = colors.lightbg, - }, - - St_pos_icon = { - fg = colors.black, - bg = colors.green, - }, - - St_pos_text = { - fg = colors.green, - bg = colors.lightbg, - }, -} diff --git a/lua/base46/integrations/syntax.lua b/lua/base46/integrations/syntax.lua deleted file mode 100644 index 6e3b44a..0000000 --- a/lua/base46/integrations/syntax.lua +++ /dev/null @@ -1,118 +0,0 @@ -local theme = require("base46").get_theme_tb "base_16" - --- Standard syntax highlighting - -return { - Boolean = { - fg = theme.base09, - }, - - Character = { - fg = theme.base08, - }, - - Conditional = { - fg = theme.base0E, - }, - - Constant = { - fg = theme.base08, - }, - - Define = { - fg = theme.base0E, - sp = "none", - }, - - Delimiter = { - fg = theme.base0F, - }, - - Float = { - fg = theme.base09, - }, - - Variable = { - fg = theme.base05, - }, - - Function = { - fg = theme.base0D, - }, - - Identifier = { - fg = theme.base08, - sp = "none", - }, - - Include = { - fg = theme.base0D, - }, - - Keyword = { - fg = theme.base0E, - }, - - Label = { - fg = theme.base0A, - }, - - Number = { - fg = theme.base09, - }, - - Operator = { - fg = theme.base05, - sp = "none", - }, - - PreProc = { - fg = theme.base0A, - }, - - Repeat = { - fg = theme.base0A, - }, - - Special = { - fg = theme.base0C, - }, - - SpecialChar = { - fg = theme.base0F, - }, - - Statement = { - fg = theme.base08, - }, - - StorageClass = { - fg = theme.base0A, - }, - - String = { - fg = theme.base0B, - }, - - Structure = { - fg = theme.base0E, - }, - - Tag = { - fg = theme.base0A, - }, - - Todo = { - fg = theme.base0A, - bg = theme.base01, - }, - - Type = { - fg = theme.base0A, - sp = "none", - }, - - Typedef = { - fg = theme.base0A, - }, -}