Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
savchenko opened this issue Dec 26, 2023 · 9 comments
Open
2 tasks done

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

savchenko opened this issue Dec 26, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@savchenko
Copy link

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.

@savchenko savchenko added the bug Something isn't working label Dec 26, 2023
@pronvis
Copy link

pronvis commented Dec 30, 2023

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
Copy link

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
Copy link
Member

shadmansaleh commented Jan 29, 2024

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
Copy link
Author

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
Copy link

@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
Copy link
Member

shadmansaleh commented Mar 15, 2024

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
Copy link

MarcoBuess commented Mar 15, 2024

@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
Copy link

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
Copy link
Member

shadmansaleh commented Mar 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants