From 896a4a9271165448d911d7c40d60380c65ab6088 Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 15 Jun 2022 17:06:37 +0530 Subject: [PATCH] minor fixes --- lua/base46/chadlights.lua | 32 ++++++------- lua/base46/init.lua | 65 +++++++++++++++++++++----- lua/base46/integrations/syntax.lua | 4 ++ lua/base46/integrations/treesitter.lua | 14 ++++++ lua/base46/themes/vscode_dark.lua | 16 +++++-- 5 files changed, 99 insertions(+), 32 deletions(-) diff --git a/lua/base46/chadlights.lua b/lua/base46/chadlights.lua index 9149d2c..a09e32d 100644 --- a/lua/base46/chadlights.lua +++ b/lua/base46/chadlights.lua @@ -23,28 +23,26 @@ if polish_hl then end -- override user highlights if there are any -if ui.hl_override then - local user_highlights = ui.hl_override - local colors = require("base46").get_theme_tb "base_30" - - -- fg = "white" set by user becomes fg = colors["white"] - -- so no need for the user to import colors - - for group, _ in pairs(user_highlights) do - for key, val in pairs(user_highlights[group]) do - if key == "fg" or key == "bg" then - if val:sub(1, 1) == "#" or val == "none" or val == "NONE" then - user_highlights[group][key] = val - else - user_highlights[group][key] = colors[val] - end +local user_highlights = ui.hl_override +local colors = require("base46").get_theme_tb "base_30" + +-- fg = "white" set by user becomes fg = colors["white"] +-- so no need for the user to import colors + +for group, _ in pairs(user_highlights) do + for key, val in pairs(user_highlights[group]) do + if key == "fg" or key == "bg" then + if val:sub(1, 1) == "#" or val == "none" or val == "NONE" then + user_highlights[group][key] = val + else + user_highlights[group][key] = colors[val] end end end - - highlights = merge_tb(highlights, user_highlights) end +highlights = merge_tb(highlights, user_highlights) + -- local set_transparent = nvchad.load_config().ui.transparency if vim.g.transparency then highlights = merge_tb(highlights, require "base46.glassy") diff --git a/lua/base46/init.lua b/lua/base46/init.lua index e862d00..08a4c81 100644 --- a/lua/base46/init.lua +++ b/lua/base46/init.lua @@ -39,10 +39,9 @@ end 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" + M.clear_highlights "BufferLine" + M.clear_highlights "TS" reload "base46.integrations" reload "base46.chadlights" @@ -54,21 +53,64 @@ M.load_all_highlights = function() end end -M.load_highlight = function(group) - local default_hl = require("base46.integrations." .. group) - local user_hl = config.ui.hl_override +M.turn_str_to_color = function(tb) + local colors = M.get_theme_tb "base_30" + + for _, groups in pairs(tb) do + for k, v in pairs(groups) do + if k == "fg" or k == "bg" then + if v:sub(1, 1) == "#" or v == "none" or v == "NONE" then + else + groups[k] = colors[v] + end + end + end + end + + return tb +end + +M.extend_default_hl = function(highlights) + local glassy = require "base46.glassy" + local polish_hl = M.get_theme_tb "polish_hl" + + if polish_hl then + -- polish themes + for key, value in pairs(polish_hl) do + if highlights[key] then + highlights[key] = value + end + end + end + -- transparency if vim.g.transparency then - user_hl = M.merge_tb(user_hl, require "base46.glassy") + -- highlights_tb = M.merge_tb(highlights_tb,) + for key, value in pairs(glassy) do + if highlights[key] then + highlights[key] = value + end + end end - for key, value in pairs(user_hl) do - if default_hl[key] then - default_hl[key] = value + local overriden_hl = M.turn_str_to_color(config.ui.hl_override) + + for key, value in pairs(overriden_hl) do + if highlights[key] then + highlights[key] = value end end +end + +M.load_highlight = function(group) + if type(group) == "string" then + group = require("base46.integrations." .. group) + M.extend_default_hl(group) + else + group = group + end - for hl, col in pairs(default_hl) do + for hl, col in pairs(group) do vim.api.nvim_set_hl(0, hl, col) end end @@ -80,6 +122,7 @@ M.load_theme = function() M.load_highlight "defaults" M.load_highlight "statusline" + M.load_highlight(M.turn_str_to_color(config.ui.hl_add)) end M.override_theme = function(default_theme, theme_name) diff --git a/lua/base46/integrations/syntax.lua b/lua/base46/integrations/syntax.lua index aa4a581..4a6a3d2 100644 --- a/lua/base46/integrations/syntax.lua +++ b/lua/base46/integrations/syntax.lua @@ -32,6 +32,10 @@ return { fg = theme.base09, }, + Variable = { + fg = theme.base05, + }, + Function = { fg = theme.base0D, }, diff --git a/lua/base46/integrations/treesitter.lua b/lua/base46/integrations/treesitter.lua index 1f79853..58a301c 100644 --- a/lua/base46/integrations/treesitter.lua +++ b/lua/base46/integrations/treesitter.lua @@ -41,6 +41,16 @@ return { sp = "none", }, + TSKeywordFunction = { + fg = theme.base0E, + sp = "none", + }, + + TSKeywordReturn = { + fg = theme.base0E, + sp = "none", + }, + TSFuncBuiltin = { fg = theme.base0D, sp = "none", @@ -152,6 +162,10 @@ return { sp = "none", }, + TSVariable = { + fg = theme.base05, + }, + TSDefinition = { sp = theme.base04, underline = true, diff --git a/lua/base46/themes/vscode_dark.lua b/lua/base46/themes/vscode_dark.lua index 6c32e3b..b83ef51 100644 --- a/lua/base46/themes/vscode_dark.lua +++ b/lua/base46/themes/vscode_dark.lua @@ -17,6 +17,7 @@ M.base_30 = { pink = "#bb7cb6", line = "#2e2e2e", -- for lines like vertsplit green = "#B5CEA8", + green1 = "#4EC994", vibrant_green = "#bfd8b2", blue = "#569CD6", nord_blue = "#60a6e0", @@ -24,7 +25,7 @@ M.base_30 = { sun = "#e1c487", purple = "#c68aee", dark_purple = "#b77bdf", - teal = "#4EC994", + teal = "#4294D6", orange = "#d3967d", cyan = "#9CDCFE", statusline_bg = "#242424", @@ -50,10 +51,13 @@ M.base_16 = { base0C = "#9CDCFE", base0D = "#DCDCAA", base0E = "#C586C0", - base0F = "#CE9178", + base0F = "#E9E9E9", } M.polish_hl = { + TSParameter = { + fg = M.base_30.blue, + }, TSKeyword = { fg = M.base_30.blue, @@ -64,16 +68,20 @@ M.polish_hl = { }, luaTSField = { - fg = M.base_30.red, + fg = M.base_30.teal, }, TSFieldKey = { - fg = M.base_30.teal, + fg = M.base_30.green1, }, TSKeywordReturn = { fg = M.base_16.base0E, }, + + TSKeywordFunction = { + fg = M.base_30.teal, + }, } M.type = "dark"