fix: default diff & diagnostics color not changing with colorscheme

fixes #647
This commit is contained in:
shadmansaleh 2022-04-13 11:26:31 +06:00
parent c2165540a8
commit 19cbf69b2e
3 changed files with 16 additions and 6 deletions

View File

@ -20,7 +20,10 @@ M.options = {
always_visible = false, always_visible = false,
sources = { vim.fn.has('nvim-0.6') == 1 and 'nvim_diagnostic' or 'nvim_lsp', 'coc' }, sources = { vim.fn.has('nvim-0.6') == 1 and 'nvim_diagnostic' or 'nvim_lsp', 'coc' },
sections = { 'error', 'warn', 'info', 'hint' }, sections = { 'error', 'warn', 'info', 'hint' },
diagnostics_color = { }
function M.apply_default_colors(opts)
local default_diagnostics_color = {
error = { error = {
fg = utils.extract_color_from_hllist( fg = utils.extract_color_from_hllist(
'fg', 'fg',
@ -49,7 +52,8 @@ M.options = {
'#273faf' '#273faf'
), ),
}, },
}, }
} opts.diagnostics_color = vim.tbl_deep_extend('keep', opts.diagnostics_color or {}, default_diagnostics_color)
end
return M return M

View File

@ -19,6 +19,7 @@ function M:init(options)
-- Run super() -- Run super()
M.super.init(self, options) M.super.init(self, options)
-- Apply default options -- Apply default options
modules.default_config.apply_default_colors(self.options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, modules.default_config.options) self.options = vim.tbl_deep_extend('keep', self.options or {}, modules.default_config.options)
-- Apply default symbols -- Apply default symbols
self.symbols = vim.tbl_extend( self.symbols = vim.tbl_extend(

View File

@ -12,7 +12,10 @@ local M = lualine_require.require('lualine.component'):extend()
local default_options = { local default_options = {
colored = true, colored = true,
symbols = { added = '+', modified = '~', removed = '-' }, symbols = { added = '+', modified = '~', removed = '-' },
diff_color = { }
local function apply_default_colors(opts)
local default_diff_color = {
added = { added = {
fg = modules.utils.extract_color_from_hllist( fg = modules.utils.extract_color_from_hllist(
'fg', 'fg',
@ -34,12 +37,14 @@ local default_options = {
'#ff0038' '#ff0038'
), ),
}, },
}, }
} opts.diff_color = vim.tbl_deep_extend('keep', opts.diff_color or {}, default_diff_color)
end
-- Initializer -- Initializer
function M:init(options) function M:init(options)
M.super.init(self, options) M.super.init(self, options)
apply_default_colors(self.options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
-- create highlights and save highlight_name in highlights table -- create highlights and save highlight_name in highlights table
if self.options.colored then if self.options.colored then