Git Product home page Git Product logo

Comments (5)

ArtAndreev avatar ArtAndreev commented on June 11, 2024 1
  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:
image

from sonokai.

antoineco avatar antoineco commented on June 11, 2024

Could you please share the output of :set statusline? while on that symbol?

from sonokai.

antoineco avatar antoineco commented on June 11, 2024

Very sorry for the delayed answer. I finally found the time to look into this.

I was able to reproduce:

Screenshot 2023-04-05 121352
Screenshot 2023-04-05 121417

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.

Screenshot 2023-04-05 122208
Screenshot 2023-04-05 122301
Screenshot 2023-04-05 122818 --> 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:

Screenshot 2023-04-05 143912

from sonokai.

ArtAndreev avatar ArtAndreev commented on June 11, 2024

Thank you for your detailed answer and help!

from sonokai.

antoineco avatar antoineco commented on June 11, 2024

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

from sonokai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.