From fd668e559ed6ccfdd565e3f43a7ae1c6efc16582 Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 9 Nov 2021 06:21:27 +0530 Subject: [PATCH] add option for overriding highlights (#596) --- lua/colors/highlights.lua | 30 +++++++++--------------------- lua/core/default_config.lua | 1 + lua/core/utils.lua | 26 ++++++++++++++++++++++++++ lua/plugins/configs/lspconfig.lua | 2 +- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/lua/colors/highlights.lua b/lua/colors/highlights.lua index ce14692..c16675d 100644 --- a/lua/colors/highlights.lua +++ b/lua/colors/highlights.lua @@ -1,3 +1,5 @@ +local override = require("core.utils").load_config().ui.hl_override + local cmd = vim.cmd local colors = require("colors").get() @@ -23,27 +25,9 @@ local one_bg3 = colors.one_bg3 local ui = require("core.utils").load_config().ui --- Define bg color --- @param group Group --- @param color Color -local function bg(group, color) - cmd("hi " .. group .. " guibg=" .. color) -end - --- Define fg color --- @param group Group --- @param color Color -local function fg(group, color) - cmd("hi " .. group .. " guifg=" .. color) -end - --- Define bg and fg color --- @param group Group --- @param fgcol Fg Color --- @param bgcol Bg Color -local function fg_bg(group, fgcol, bgcol) - cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) -end +local fg = require("core.utils").fg +local fg_bg = require("core.utils").fg_bg +local bg = require("core.utils").bg -- Comments if ui.italic_comments then @@ -155,3 +139,7 @@ fg("TelescopeBorder", one_bg) fg_bg("TelescopePreviewTitle", green, one_bg) fg_bg("TelescopePromptTitle", blue, one_bg) fg_bg("TelescopeResultsTitle", red, one_bg) + +if #override ~= 0 then + require(override) +end diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 9859c4e..9b087cf 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -42,6 +42,7 @@ M.options = { -- ui configs M.ui = { + hl_override = "", -- path of your file which contains highlight stuffs italic_comments = false, -- theme to be used, check available themes with ` + t + h` theme = "onedark", diff --git a/lua/core/utils.lua b/lua/core/utils.lua index bab04fc..e9fbd1f 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,5 +1,6 @@ local M = {} +local cmd = vim.cmd M.close_buffer = function(bufexpr, force) -- This is a modification of a NeoVim plugin from -- Author: ojroques - Olivier Roques @@ -330,4 +331,29 @@ M.packer_lazy_load = function(plugin, timer) end end +-- Highlights functions + +-- Define bg color +-- @param group Group +-- @param color Color + +M.bg = function(group, col) + cmd("hi " .. group .. " guibg=" .. col) +end + +-- Define fg color +-- @param group Group +-- @param color Color +M.fg = function(group, col) + cmd("hi " .. group .. " guifg=" .. col) +end + +-- Define bg and fg color +-- @param group Group +-- @param fgcol Fg Color +-- @param bgcol Bg Color +M.fg_bg = function(group, fgcol, bgcol) + cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) +end + return M diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 36446d1..be12585 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -98,6 +98,6 @@ end local addlsp_confs = require("core.utils").load_config().plugins.options.lspconfig.setup_lspconf -if string.len(addlsp_confs) ~= 0 then +if #addlsp_confs ~= 0 then require(addlsp_confs).setup_lsp(on_attach, capabilities) end