nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.07k stars 465 forks source link

Allow components to not change color when vim mode changes #571

Closed n0bra1n3r closed 2 years ago

n0bra1n3r commented 2 years ago

Requested feature

When vim switches modes, the statusline component colors and tabline component colors change. I would like to disable this effect per component. Perhaps a mode_color component option?

Motivation

I am using the tabline feature to render certain components in the tabline. Since the tabline is not updated as frequently as the statusline, sometimes the colors desynchronize.

image

This will allow further customizability and control, especially for those who use the tabline feature.

shadmansaleh commented 2 years ago

TBH I don't like current behavior of modes changing color of all components at all . This behavior predates me and currently we are pretty much locked in as that's how themes are set .

I'd really like to change theme format to something like following:

local theme = {
  sections = {a={}, b={}, c={}, (optional x, y, z)},
  inactive = {a={}, b={}, c={},  (optional x, y, z)}, -- optional inactive status color customization
  tabline = {a={}, b={}, c={},  (optional x, y, z)}, -- optional tabline color customization
  components = { -- optional component specific color customization
    mode = { (mode colors effecting only mode compoent) },
   ....
   (other components)
}

But that will basically break all themes in existence .Since there are a ton of themes out of this repo in colorschemes I can't fix this without serious breakage for users :/

I would like to disable this effect per component. Perhaps a mode_color component option?

You can use color option (with both fg & bg or link ti a group) and set a default color for that component and it won't change color with mode. For example if your component is in lualine_a/z_section

require'lualine'.setup {
  tabline = {
   lualine_z = {
      {'branch', color = 'lualine_a_normal'}
    }
  }
}

As current mode based color change is done on section level making it stop on component level with an option like mode_color=false would require a ton of code change .It'll be too much effort for little gain in my opinion. So I think I'll just leave is a solved by color option unless in some time I actually decide to rewrite the themes .

Since the tabline is not updated as frequently as the statusline, sometimes the colors desynchronize

You can try https://github.com/nvim-lualine/lualine.nvim/wiki/FAQ#my-tabline-updates-infrequently

n0bra1n3r commented 2 years ago

Thanks! Yes explicitly setting the color in the components works well enough for me.