Closed ArtAndreev closed 1 year ago
Could you please share the output of :set statusline?
while on that symbol?
statusline=%#lualine_a_command# COMMAND %<%#lualine_c_command# main.go [+] %#lualine_c_command# %#lualine_c_command#%=%#NavicIconsInterface# 練%*%#NavicText#I%*%#NavicSeparator#
%*%#NavicIconsMethod# %*%#NavicText#cc%* %#lualine_c_command#%#lualine_c_command# utf-8 %#lualine_c_command# %#lualine_x_filetype_DevIconGo_command# %#lualine_c_command# go %#lua
line_b_command# 80%% %#lualine_a_command# 4:5
Edit:
Very sorry for the delayed answer. I finally found the time to look into this.
I was able to reproduce:
Quick analysis:
" highlight = false
statusline=%#lualine_a_2_command# %#lualine_b_3_command# main %<%#lualine_c_diff_added_command# 11 %#lualine_c_diff_modified_command# 13 %#lualine_c_diff_removed_command# 1 %#lualine_c_command#%=%#lualine_c_command# lvim.colorscheme %#lualine_b_command# 13:26 %#lualine_z_progress_command# %P/%L
" highlight = true
statusline=%#lualine_a_2_command# %#lualine_b_3_command# main %<%#lualine_c_diff_added_command# 11 %#lualine_c_diff_modified_command# 13 %#lualine_c_diff_removed_command# 1 %#lualine_c_command#%=%#NavicIconsString# %*%#NavicText#lvim.colorscheme%* %#lualine_b_command# 13:26 %#lualine_z_progress_command# %P/%L
I think the issue is that the NavicIcons*
highlight groups indirectly reset the background to NONE
, whereas they should inherit the background value of the lualine section they are located in.
--> No background
I don't think there is a way to achieve this in the colorscheme. I have a feeling that this requires some integration between lualine and navic to dynamically adjust the background values of all NavicIcons*
highlight groups based on the lualine section.
One example is lualine's LSP diagnostic component, which creates highlight groups on the fly during initialization.
The Git diff component—visible in the lualine section C in my screenshots—is initialized in the same manner (lualine_c_diff_added_*
, lualine_c_diff_modified_*
, etc.).
A few additional interesting code locations, for future reference: 1, 2, 3.
For the time being, the simplest workaround is to override NavicIcons*
highlight groups using an autocmd as shown below. Simply add to your Neovim config:
-- Apply custom highlights on colorscheme change.
-- Must be declared before executing ':colorscheme'.
grpid = vim.api.nvim_create_augroup('custom_highlights_sonokai', {})
vim.api.nvim_create_autocmd('ColorScheme', {
group = grpid,
pattern = 'sonokai',
callback = function()
-- navic colors for lualine
local config = vim.fn['sonokai#get_configuration']()
local palette = vim.fn['sonokai#get_palette'](config.style, config.colors_override)
local navic_bg = palette.bg1[1]
local function set_hl(name, fg)
vim.api.nvim_set_hl(0, name, { foreground = fg, background = navic_bg })
end
local function get_hl(name)
return vim.api.nvim_get_hl_by_name(name, true).foreground
end
set_hl('NavicText', get_hl('Fg'))
set_hl('NavicSeparator', get_hl('Grey'))
for _, c in ipairs(vim.g.sonokai_lsp_kind_color) do
set_hl('NavicIcons' .. c[1], get_hl(c[2]))
end
end
})
Result:
Thank you for your detailed answer and help!
If turns out that navic had options for color correction, specially designed for it to be embedded into a statusline: https://github.com/SmiteshP/nvim-navic/blob/83dc174da915f9dbc9b51169e9b62a2e0d42b527/README.md?plain=1#L275-L281
I have done the following steps before reporting this issue:
Operating system/version
macOS Ventura 13.2.1
Terminal emulator/version
Alacritty 0.12.0-rc2
$TERM environment variable
tmux-256color
Tmux version
tmux 3.3a
Feature matrix
Minimal vimrc that can reproduce this bug.
Steps to reproduce this bug using minimal vimrc
nvim-navic
.Take this code:
nvim -u init.lua main.go
.Expected behavior
The background of component matches the background of statusline.
If I disable highlight in
nvim-navic
config, I get this:Actual behavior
The background of component doesn't match the background of statusline.