nvim-lualine / lualine.nvim

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

Bug: Flicker Issue on Lualine Still Exist #1280

Open ochi12 opened 4 months ago

ochi12 commented 4 months ago

Self Checks

Expected behaviour

This was Already Solved In issue #744 I already looked up the source code in and confirmed it was already commited d2a727.

Actual behavior

The flicker issue is still bugging me Specifically when toggling NeoTree. Also when opening Telescope just like in [ issue #1220 ] It also do flicker

Minimal config to reproduce the issue

local lualine_c = function()

    local devicons = require("nvim-web-devicons")
    local theme = require("lualine.themes.catppuccin")
    local mocha = require("catppuccin.palettes").get_palette("mocha")

    -- overriding default colors
    theme.normal.c.bg = "#242435"

    -- defining section colors
    local z_colors = {
        left = {
            bg = theme.insert.a.bg,
            fg = theme.insert.a.fg,
        },
        right = {
            bg = theme.normal.b.bg,
            fg = theme.insert.b.fg,
        },
    }

    local y_colors = {
        left = {
            bg = mocha.red,
            fg = mocha.base,
        },
    }

    require("lualine").setup({
        options = {
            theme = theme,

            ignore_focus = { "neo-tree"  },
            disabled_filetypes = { statusline = { "neo-tree" }  },
            section_separators = { left = "", right = "" },
            component_separators = { left = "", right = "" },
            globalstatus = true,

            refresh = {
                statusline = 100,
            }
        },

        sections = {
            lualine_a = {
                {
                    "mode",
                    separator = { right = "" },
                    fmt = function(str)
                        return " " .. str
                    end,
                },
            },
            lualine_b = {
                {
                    function()
                        return ""
                    end,
                    padding = 0,
                    color = { bg = mocha.surface1 },
                    separator = { right = "" },
                },
                {
                    "filename",
                    padding = { left = 2, right = 2 },
                    colored = false,
                    fmt = function(str)
                        local name = str
                        local extension = vim.fn.fnamemodify(name, ":e")
                        local icon = devicons.get_icon(name, extension, { default = true })
                        return icon .. " " .. str
                    end,
                    symbols = {
                        unnamed = "unnamed",
                        newfile = "new file",
                        modified = MyIco.file.modified,
                        readonly = MyIco.file.readonly,
                    },
                    separator = { right = "" },
                    color = { fg = mocha.text },
                },
            },
            lualine_c = {
                {
                    "branch",
                    color = { fg = mocha.surface1 },
                    icon = "",
                },
                {
                    "diff",
                    colored = false, -- Displays a colored diff status if set to true
                    symbols = {
                        added = MyIco.file.added,
                        modified = MyIco.file.modified,
                        removed = MyIco.file.removed,
                    }, -- Changes the symbols used by the diff.
                    source = nil,
                    color = { fg = mocha.surface1 },
                },
            },
            lualine_x = {
                {
                    "diagnostics",
                    symbols = {
                        warn = MyIco.diagnostics.warn .. " ",
                        error = MyIco.diagnostics.error .. " ",
                        hint = MyIco.diagnostics.hint .. " ",
                        info = MyIco.diagnostics.info .. " ",
                    }
                },
                {
                    function(str)
                        local current_lsp = vim.lsp.get_active_clients()[1]["_log_prefix"]
                        return "LSP ~ " .. current_lsp:sub(5, -2)
                    end,
                    icons_enabled = true,
                    icon = " ",
                    color = { fg = mocha.blue },
                },
            },
            lualine_y = {
                {
                    function()
                        return " "
                    end,
                    separator = { left = "" },
                    padding = { left = 0, right = 1 },
                    color = y_colors.left,
                },

                {
                    function()
                        local cwd = vim.fn.getcwd()
                        local home = vim.fn.expand("~")
                        cwd = cwd:gsub(home, "~")

                        --local cwd_list = vim.split(cwdp, "/")

                        --cwd = table.concat(vim.list_slice(cwd_list, 1, 3), "/")

                        return cwd
                    end,
                    color = { fg = mocha.text },
                },
            },
            lualine_z = {
                {
                    function()
                        return "󰦪"
                    end,
                    separator = { left = "" },
                    padding = { left = 0, right = 1 },
                    color = z_colors.left,
                },
                {
                    "progress",
                    color = z_colors.right,
                },
            },
        },
    })
end

return lualine_c

Additional information

ochi12 commented 4 months ago

https://github.com/user-attachments/assets/ee5d5a0d-4bf0-4a33-aa0d-f704e92761e7

bighi commented 4 months ago

Also flickering for me. I tried 4 different themes, and they all had the issue, so it's not associated with a particular theme.

I'm using the latest iTerm app, on an M3 Max MacBook Pro.

MarceliJankowski commented 3 months ago

I'm running into the same issue when toggling Netrw. Lualine also flickers when I open new buffers from within Netrw. These flickerings do not happen every time; more like every 3-4 time.

maleksware commented 1 month ago

This seems to be happening only with globalstatus = true. The cause of the flicker seems to also be the cause of the highlight group corruption bug in NvimTree (untested with other trees) (https://github.com/nvim-tree/nvim-tree.lua/issues/245)

Edit: the highlight corruption has been fixed there, small compatibility issue (1c9553a19f70df3dcb171546a3d5e034531ef093).

shadmansaleh commented 3 weeks ago

Can you check if #1316 fixes the flickering?

maleksware commented 3 weeks ago

Doesn't seem so. The flicker is now longer (I'd assume it to be 100ms as specified in the PR).

shadmansaleh commented 3 weeks ago

Doesn't seem so. The flicker is now longer (I'd assume it to be 100ms as specified in the PR).

Give it another go if you have time. I've added another fix.

maleksware commented 3 weeks ago

This has fixed it indeed. Thanks a lot! I'd also wait for the OP's replication but it worked no problem for me (in the circumstances similar to the original issue).

sand4rt commented 3 weeks ago

Thank you for looking into this! The flicker still exists for me unfortunately, but seems to be less, also got errors when i open telescope sometimes;

 E5108: Error executing lua ../.local/share/nvim/lazy/lualine.nvim/lua/lualine.lua:429: Invalid window id: 1003 
 stack traceback: 
 [C]: in function 'nvim_win_call'  .../.local/share/nvim/lazy/lualine.nvim/lua/lualine.lua 
 a:429: in function <.../.local/share/nvim/lazy/lualine.nvim/lua/lualine.lua:318> 

Related; https://github.com/nvim-lualine/lualine.nvim/issues/1220

shadmansaleh commented 3 weeks ago

@sand4rt see if your issue is fixed now in #1316

sand4rt commented 3 weeks ago

@sand4rt see if your issue is fixed now in #1316

@shadmansaleh thank you! the error is gone, the flicker still exists for me unfortunately.

shadmansaleh commented 3 weeks ago

@sand4rt try the latest commit on that pr. If the flicker still exists do provide a minimal config and instructions to reproduce it.

sand4rt commented 3 weeks ago

@shadmansaleh Big improvement! Although, there's still some flickering most of the time (especially when toggling Telescope + editing a large file). Please let me know if this is sufficient; otherwise, i’ll start disabling plugins one by one and send the minimal config

shadmansaleh commented 3 weeks ago

I don't see flickering on either cases. Are you sure you aren't doing something in your config that might delay the first render? Try to create an isolated minimal config with https://github.com/nvim-lualine/lualine.nvim/blob/640260d7c2d98779cab89b1e7088ab14ea354a02/scripts/nvim_isolated_conf.sh

A short screen recording would be a good addition too

sand4rt commented 3 weeks ago

Hey @shadmansaleh, it was hard to pinpoint the flicker to a specific plugin, but i've found a consistent way to reproduce it:

https://github.com/user-attachments/assets/6af30712-02cf-4b4c-9277-1c4d4e2e7978

  1. Start Neovim
  2. Open Telescope using Space + Space

The flicker only happens once at this point, and nvim-cmp seems to be related;

https://github.com/sand4rt/lualine-flicker

Do you want me to send a larger config where the flicker happens more often?

shadmansaleh commented 3 weeks ago

Can you try to drop as much as stuff from your lualine config while the bug still occurs ? I mean just the lualine config you gave me is 400 lines

Do you want me to send a larger config where the flicker happens more often?

Quite the opposite. I want a config as little config and as few plugins as possible. I don't have the time nor the energy to go through thousands of lines of config that pulls several times more as plugins.

sand4rt commented 3 weeks ago

@shadmansaleh I've removed additional unrelated code. Hopefully, this streamlines things—but let me know if i can do anything else. It's basically a clean install of telescope+lualine+cmp. You might have to spam space + space and esc to close telescope a few times to see the flicker

ochi12 commented 2 weeks ago

I think this is a status line issue tho. I haven't tried using my config yet without the Lualine installed

shadmansaleh commented 2 weeks ago

@sand4rt unfortunately, I couldn't reproduce the flickering you mentioned with your config. Only case I could find flickering in that branch is with cmdheight=0 without showmode=false. That makes sense and showmode and statusline is fighting for the same space. The builtin statusline behaves the same in this case.

I'll merge that pr and mark this as resolved for now