nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

savchenko opened this issue · comments

Self Checks

  • I'm using the latest lualine.
  • I didn't find the issue in existing issues or PRs.

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.

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 } },

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...

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

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

@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.

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

@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.

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 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.