enhance: check for new diagnostics highlight groups
- Now DiagnosticError, DiagnosticWarn, DiagnosticInfo, DiagnosticHint are also consider3d for default highlight in diagnostics component. - Moved getHl from auto theme to utils as extract_color_from_hllist closes #56
This commit is contained in:
parent
b76c410dba
commit
f7702d8841
|
@ -53,24 +53,32 @@ local default_options = {
|
||||||
sections = { 'error', 'warn', 'info', 'hint' },
|
sections = { 'error', 'warn', 'info', 'hint' },
|
||||||
diagnostics_color = {
|
diagnostics_color = {
|
||||||
error = {
|
error = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg')
|
fg = modules.utils.extract_color_from_hllist(
|
||||||
or modules.utils.extract_highlight_colors('DiffDelete', 'fg')
|
'fg',
|
||||||
or '#e32636',
|
{ 'DiagnosticError', 'LspDiagnosticsDefaultError', 'DiffDelete' },
|
||||||
|
'#e32636'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
warn = {
|
warn = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg')
|
fg = modules.utils.extract_color_from_hllist(
|
||||||
or modules.utils.extract_highlight_colors('DiffText', 'fg')
|
'fg',
|
||||||
or '#ffa500',
|
{ 'DiagnosticWarn', 'LspDiagnosticsDefaultWarning', 'DiffText' },
|
||||||
|
'#ffa500'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
info = {
|
info = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg')
|
fg = modules.utils.extract_color_from_hllist(
|
||||||
or modules.utils.extract_highlight_colors('Normal', 'fg')
|
'fg',
|
||||||
or '#ffffff',
|
{ 'DiagnosticInfo', 'LspDiagnosticsDefaultInformation', 'Normal' },
|
||||||
|
'#ffffff'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
hint = {
|
hint = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg')
|
fg = modules.utils.extract_color_from_hllist(
|
||||||
or modules.utils.extract_highlight_colors('DiffChange', 'fg')
|
'fg',
|
||||||
or '#273faf',
|
{ 'DiagnosticHint', 'LspDiagnosticsDefaultHint', 'DiffChange' },
|
||||||
|
'#273faf'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,6 @@ local contrast_threshold = 0.3
|
||||||
-- how much brightness is changed in percentage for light and dark themes
|
-- how much brightness is changed in percentage for light and dark themes
|
||||||
local brightness_modifier_parameter = 10
|
local brightness_modifier_parameter = 10
|
||||||
|
|
||||||
-- retrives color value from highlight group name in syntax_list
|
|
||||||
-- first present highlight is returned
|
|
||||||
local function getHi(scope, syntaxlist)
|
|
||||||
for _, highlight_name in pairs(syntaxlist) do
|
|
||||||
if vim.fn.hlexists(highlight_name) ~= 0 then
|
|
||||||
local color = utils.extract_highlight_colors(highlight_name)
|
|
||||||
if color.reverse then
|
|
||||||
if scope == 'bg' then
|
|
||||||
scope = 'fg'
|
|
||||||
else
|
|
||||||
scope = 'bg'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if color[scope] then
|
|
||||||
return color[scope]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return '#000000'
|
|
||||||
end
|
|
||||||
|
|
||||||
-- truns #rrggbb -> { red, green, blue }
|
-- truns #rrggbb -> { red, green, blue }
|
||||||
local function rgb_str2num(rgb_color_str)
|
local function rgb_str2num(rgb_color_str)
|
||||||
if rgb_color_str:find '#' == 1 then
|
if rgb_color_str:find '#' == 1 then
|
||||||
|
@ -124,14 +103,14 @@ end
|
||||||
-- Get the colors to create theme
|
-- Get the colors to create theme
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
local colors = {
|
local colors = {
|
||||||
normal = getHi('bg', { 'PmenuSel', 'PmenuThumb', 'TabLineSel' }),
|
normal = utils.extract_color_from_hllist('bg', { 'PmenuSel', 'PmenuThumb', 'TabLineSel' }, '#000000'),
|
||||||
insert = getHi('fg', { 'String', 'MoreMsg' }),
|
insert = utils.extract_color_from_hllist('fg', { 'String', 'MoreMsg' }, '#000000'),
|
||||||
replace = getHi('fg', { 'Number', 'Type' }),
|
replace = utils.extract_color_from_hllist('fg', { 'Number', 'Type' }, '#000000'),
|
||||||
visual = getHi('fg', { 'Special', 'Boolean', 'Constant' }),
|
visual = utils.extract_color_from_hllist('fg', { 'Special', 'Boolean', 'Constant' }, '#000000'),
|
||||||
command = getHi('fg', { 'Identifier' }),
|
command = utils.extract_color_from_hllist('fg', { 'Identifier' }, '#000000'),
|
||||||
back1 = getHi('bg', { 'Normal', 'StatusLineNC' }),
|
back1 = utils.extract_color_from_hllist('bg', { 'Normal', 'StatusLineNC' }, '#000000'),
|
||||||
fore = getHi('fg', { 'Normal', 'StatusLine' }),
|
fore = utils.extract_color_from_hllist('fg', { 'Normal', 'StatusLine' }, '#000000'),
|
||||||
back2 = getHi('bg', { 'StatusLine' }),
|
back2 = utils.extract_color_from_hllist('bg', { 'StatusLine' }, '#000000'),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Change brightness of colors
|
-- Change brightness of colors
|
||||||
|
|
|
@ -23,6 +23,27 @@ function M.extract_highlight_colors(color_group, scope)
|
||||||
return color
|
return color
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- retrives color value from highlight group name in syntax_list
|
||||||
|
-- first present highlight is returned
|
||||||
|
function M.extract_color_from_hllist(scope, syntaxlist, default)
|
||||||
|
for _, highlight_name in ipairs(syntaxlist) do
|
||||||
|
if vim.fn.hlexists(highlight_name) ~= 0 then
|
||||||
|
local color = M.extract_highlight_colors(highlight_name)
|
||||||
|
if color.reverse then
|
||||||
|
if scope == 'bg' then
|
||||||
|
scope = 'fg'
|
||||||
|
else
|
||||||
|
scope = 'bg'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if color[scope] then
|
||||||
|
return color[scope]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
|
||||||
-- remove empty strings from list
|
-- remove empty strings from list
|
||||||
function M.list_shrink(list)
|
function M.list_shrink(list)
|
||||||
local new_list = {}
|
local new_list = {}
|
||||||
|
|
Loading…
Reference in New Issue