nvim-lualine / lualine.nvim

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

Bug: `buffers` in `tabline` don't render `color` appropriately #1169

Open savchenko opened 9 months ago

savchenko commented 9 months ago

Self Checks

How to reproduce the problem

  1. Start nVim with the config below.
  2. Observe the tabline.

Expected behaviour

buffers component of the tabline reacts to color{} the same way as any other component.

Actual behaviour

Odd rendering using theme colours.

Minimal config to reproduce the issue

      require 'lualine'.setup {
        options = {
          theme = 'base16',
          icons_enabled = false,
          always_divide_middle = false,
          globalstatus = true,
        },
        tabline = {
          lualine_a = {
            { 'buffers',
              color = { -- This doesn't work
                fg = '#ff0000',
                bg = '#0000ff',
              },
              use_mode_colors = false,
            }
          }
        }
      }

Additional information

Latest Lazy and lualine.nvim, nVim v0.9.4.

pronvis commented 9 months ago

When I set colors like in readme (and in the same way as you) :LualineNotices tell me that I am doing it wrong. And it advice to change it to:

        lualine_c = { 'branch', require('lsp-progress').progress, { 'color', fg = 'grey', bg = 'red' } },

That doesn't work neither, but at least I dont receive lualine: There are some issues with your config. Run :LualineNotices for details

Why am I trying to change colors of lualine, cause it is unreadable with base16_blueforest:

image

and with mouse selected status line:

image

My sections config:

    sections = {
        lualine_a = { 'mode' },
        lualine_b = {
            {
                'filename',
                path = 1,
                shorting_target = 100
            },
            'diff', 'diagnostics' },
        lualine_c = { 'branch', require('lsp-progress').progress },
        lualine_x = { ObsStatus, 'encoding', 'fileformat', 'filetype' },
        lualine_y = { 'progress' },
        lualine_z = { 'location' }
    },

update: with use_mode_colors dont work too:

        lualine_c = { 'branch', require('lsp-progress').progress, { 'color', fg = 'grey', bg = 'red', use_mode_colors = false } },
RaphaelEDiener commented 8 months ago

image

I also have this bug. I've read that

-- Automatically updates active tab color to match color of other components (will be overidden if buffers_color is set)

So I went into the files and changed the default flags inside the buffers init.lua too. (use_mode_colors = true)

This also didn't work...

shadmansaleh commented 8 months ago

buffers component actually has a slightly different option named buffers_color it takes two color options active and inactive. because unlike regular component buffers has two colors to denote to separate states. I think what you're looking for is something like this.

  tabline = {
    lualine_a = {
      {
        'buffers',
        buffers_color = { -- This doesn't work
          active = {fg='#ff0000', bg='#0000ff'},
          inactive = {fg='#0000ff', bg='#ff0000'}
        },
        use_mode_colors = false,
      },
    },

https://github.com/nvim-lualine/lualine.nvim?tab=readme-ov-file#buffers-component-options

savchenko commented 8 months ago

buffers component actually has a slightly different option named buffers_color

You are correct! Any chance you know how to affect the background of the tabline?

Area outlined in red:

image

MarcoBuess commented 6 months ago

@shadmansaleh Are there ways to make the active color dynamic? I'd like to change color based on the mode im currently in. Thanks for the headsup.

shadmansaleh commented 6 months ago

You can set any color options in lualine to a function that returns the desired color value. You can get dynamic color that way

MarcoBuess commented 6 months ago

@shadmansaleh Do I need to trigger some sort of a refresh, so that when the mode changes the colors get reloaded? Any tips or docs on howto go about that?

Edit: So there seems to be

require('lualine').refresh()

But it is not supposed to be called from inside of components.

MarcoBuess commented 6 months ago

It was surprisingly easier that I thought. Here is the code for anyone interessted.

buffers_color = {
    active = function()
        local mode_names = {
            n = "lualine_a_normal",
            i = "lualine_a_insert",
            v = "lualine_a_visual",
            V = "lualine_a_visual",
            R = "lualine_a_replace",
        }
        local mode = vim.api.nvim_get_mode().mode
        return mode_names[mode]
    end,
},
shadmansaleh commented 6 months ago

@shadmansaleh Do I need to trigger some sort of a refresh, so that when the mode changes the colors get reloaded? Any tips or docs on howto go about that?

No. not necessary. Lualine already refreshes itself on mode change. Even if that wasn't the case you could've always created an autoc-command that calls lualine.refresh() it doesn't need to be called from inside the component.

MarcoBuess commented 4 months ago

I don't know if something broke recently, but it seems like the buffer component doesn't detect active buffers correctly. I'm sure this has worked in the past. When you have multiple buffers open in several windows lualine_c_buffers_inactive will be applied to all buffers except the currently selected one, even though the visible buffers are marked 'a'.

Anyone noticed this behavior?

error

Oh and the filetype icon seems to be broken for term:// buffers.