Closed tristan957 closed 2 years ago
Did you try setting colored option to false ?
lualine_c = {
{
"diagnostics",
colored = false,
sources = { "nvim_lsp", "coc" },
}
}
Yes, but then you don't get the nice foreground colors.
Side note, I think in the "general component config" section, it uses "color" instead of "colored".
Side note, I think in the "general component config" section, it uses "color" instead of "colored".
colored
is specific to diagnostics & diff component but I can see it's not documented under diagnostics .
Yes, but then you don't get the nice foreground colors.
I though you wanted to get rid of colors ?? I don't think I understand the issue can you elaborate ?
This is really two issues in one.
When colored=true, the diagnostics background doesn't change with the theme when modes change.
The individual colors in diagnostic_colors
have no effect when set to nil as shown in the documentation.
The individual colors in diagnostic_colors have no effect when set to nil as shown in the documentation.
It doesn't have an effect .In lua when you set an entry to nil it deletes that entry . The nil was written just two show what fields are available for that table.
the diagnostics background doesn't change with the theme when modes change.
This might be a bug . I'll take a look.
Thanks for the correction on 2.
Can you check if the issue is fixed?
Works like a charm.
@shadmansaleh seeing the following issue:
Here is my current setup:
require("lualine").setup({
options = {
icons_enabled = false,
theme = "powerline",
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_b = {
"branch",
"diff",
},
lualine_c = {
"filename",
{
"diagnostics",
sources = { "nvim_diagnostic" },
diagnostics_color = {
error = "DiagnosticError",
warn = "DiagnosticWarn",
info = "DiagnosticInfo",
hint = "DiagnosticHint",
},
sections = { "error", "warn", "info", "hint" },
symbols = { error = "E", warn = "W", info = "I", hint = "H" },
always_visible = false,
update_in_insert = false,
},
require("lsp-status").status(),
},
},
})
This seems very much like the the original issue if I remember. I would have expected the background color of the diagnostics section to be the same as the rest of the theme.
@tristan957 I'm experiencing the same for what it's worth, practically the same configuration, but using gruvbox
for now, also expected it to default to the background of e.g. diff
to the left of it.
Setting colored
to false for diagnostics
properly sets the background, but does remove the foreground color, unlike with diff
?
The plugin is amazing so far @shadmansaleh, thank you!
So I found the issue:
You can see that there is not bg defined, just this "links to" thing
I think using linking here is incorrect. We need to apply the currently linked color as the foreground and apply the background as necessary. @shadmansaleh any thoughts? Would probably help to re-open this.
To evaluate a highlight group, use the following:
vim.fn.synIDattr(vim.fn.hlID("DiagnosticError"), "fg", "gui" | "cterm" ))
In my case, this comes out to Red
, so lualine could set guifg=Red
.
Once lualine has done this, it can use the necessary background color after applying the foreground without "links".
Sorry for late response . As you figured when Hl_goup is provided in color option lualine links to that group. Here lualine relies of user providing the correct group because hl_group can contain both foreground & background colors and lualine can't know if user want's fg/bg or both from that hl_group . To avoid this you xan set color as table containing fg,bg.... keys . You can use something like extract_highlight_colors to get color from hl_group .
For example:
local get_color = require'lualine.utils.utils'.extract_highlight_colors
require("lualine").setup({
lualine_c = {
{"diagnostics",
diagnostics_color = {
error = {fg = get_color("DiagnosticError", "fg")},
warn = {fg = get_color("DiagnosticWarn", "fg")},
info = {fg = get_color("DiagnosticInfo", "fg")},
hint = {fg = get_color("DiagnosticHint", "fg")},
},
},
}
@shadmansaleh thanks for the background on the issue. Is this information available in the README? If not, I wouldn't mind sending a PR, so others don't fall into the same trap.
You can put it in FAQ if you want to.
I'll look into that. Never submitted to a wiki on github before.
You can put it in FAQ if you want to.
I faced the exact same issue and was looking for docs related to the same but it wasn't mentioned in docs nor in the README. After some searching I stumbled upon here.
It'll be easy for those who face this issue to have the "fix" mentioned somewhere. I tried to edit docs but the Wiki has restricted edit permissions I guess.
I'll cast another vote here. I had the same problem and eventually searched for "background" in the issues. It would be nice if it'd be mentioned somewhere in the docs, though.
diagnostics_color
has no effect when each is set to nil.diagnostics
doesn't change when modes change unlesscolored=false
.Self Checks
How to reproduce the problem
Expected behaviour
diagnostics_color
should have an effect when set to nil, meaning unset the color. The background color of the diagnostics should follow the theme when switching modes.Actual behaviour
diagnostics_color
members don't get unset when set to nil. Background color doesn't update with theme when switching modes.