lualine.nvim icon indicating copy to clipboard operation
lualine.nvim copied to clipboard

Feat: Delay updating lualine to prevent flickering

Open savchenko opened this issue 1 year ago • 3 comments

Requested feature

Allow "delaying" an update to prevent flicker when rapidly changing modes:

https://github.com/nvim-lualine/lualine.nvim/assets/300146/f4089705-46c7-4523-a82a-73598641cde7

Motivation

User has a hotkey:

map('n', '<Tab>', ':call NextFile()<cr>', remap_silent('Next buff|tab'))

It works as expected, however when executing the command, lualine briefly flickers from Normal to Command and then back to Normal.

It is "as expected" behaviour, but nevertheless annoying.

savchenko avatar Dec 25 '23 07:12 savchenko

:help <cmd> Should be used to prevent this from happening,

Also the fzfx issue isn't about mapping/mode changes, If you open a tabpage with lualine the whole statusline disappears sometimes. I think this is because lualine doesn't load the window's statusline in the time a tabpage opens. Try refreshing it when the tab is opened.

vim.api.nvim_create_autocmd("TabNewEntered",{
    pattern = "*",
    callback = function(opts)
        require('lualine').refresh()
    end,
})

This should fix the flicker, However adding this to lualine is gonna be difficult/ugly, Because in lualine the autocmd updates are scheduled via vim.schedule,But this one needs to be refreshed right away.

Sam-programs avatar Dec 25 '23 13:12 Sam-programs

@Sam-programs,

:help Should be used to prevent this from happening,

What do you mean?

savchenko avatar Dec 27 '23 11:12 savchenko

Use <cmd> instead of : to stop the flickering in the mapping. :help <cmd> :

The <Cmd> pseudokey begins a "command mapping", which executes the command
directly without changing modes.  Where you might use ":...<CR>" in the
{rhs} of a mapping, you can instead use "<Cmd>...<CR>".

Since it doesn't change modes lualine doesn't flicker.

Sam-programs avatar Dec 27 '23 13:12 Sam-programs