neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
81.64k stars 5.59k forks source link

flicker if plugin sets 'background' during startup #19362

Open vimpostor opened 2 years ago

vimpostor commented 2 years ago

Neovim version (nvim -v)

v0.7.2

Vim (not Nvim) behaves the same?

no, vim 9.0.0

Operating system/version

Arch Linux

Terminal name/version

wezterm nightly

$TERM environment variable

xterm-256color

Installation

Arch Linux community repo

How to reproduce the issue

If we set background=light in init.vim, then we set it early enough before nvim renders anything. But it's not possible to do that from a plugin (without calling the plugin from init.vim), because the plugin is sourced too late in the startup process: nvim already shows the UI before sourcing it, while normal vim does not (so the problem does not occur with normal vim).

See the attached video for a visual explanation:

https://user-images.githubusercontent.com/21310755/178955503-66796c13-79ac-4e4b-8399-fd17b177194b.mp4

Minimal example myplugin/plugin/myplugin.vim (myplugin needs to be in rtp):

" myplugin.vim
set background=light

Expected behavior

neovim renders with background=light immediately, like vim does

Actual behavior

neovim renders with background=dark, then sources the plugin, rerenders with background=light causing a visible flickering

vimpostor commented 2 years ago

Unfortunately it looks like there is no way to execute something earlier than from plugin/ directories, is there?

    List of directories to be searched for these runtime files:
      filetype.vim  filetypes by file name |new-filetype|
      scripts.vim   filetypes by file contents |new-filetype-scripts|
      autoload/ automatically loaded scripts |autoload-functions|
      colors/   color scheme files |:colorscheme|
      compiler/ compiler files |:compiler|
      doc/      documentation |write-local-help|
      ftplugin/ filetype plugins |write-filetype-plugin|
      indent/   indent scripts |indent-expression|
      keymap/   key mapping files |mbyte-keymap|
      lang/     menu translations |:menutrans|
      menu.vim  GUI menus |menu.vim|
      pack/     packages |:packadd|
      plugin/   plugin scripts |write-plugin|
      print/    files for printing |postscript-print-encoding|
      rplugin/  |remote-plugin| scripts
      spell/    spell checking files |spell|
      syntax/   syntax files |mysyntaxfile|
      tutor/    tutorial files |:Tutor|
justinmk commented 2 years ago

Unfortunately it looks like there is no way to execute something earlier than from plugin/ directories, is there?

Only with --cmd. Can you try that , just for troubleshooting ?

neovim renders with background=light immediately, like vim does

Vim assumes bg=light on many environments. Does the opposite problem happen in Vim, with a dark terminal?

vimpostor commented 2 years ago

Only with --cmd. Can you try that , just for troubleshooting ?

nvim --cmd "set background=light" works (it does not flicker), but obviously I can't use that in a plugin.

Vim assumes bg=light on many environments. Does the opposite problem happen in Vim, with a dark terminal?

No, it does not happen in vim in any case, because vim sources the plugin file before rendering anything.

zeertzjq commented 7 months ago

I cannot reproduce this v0.9.5 or v0.10.0-dev. Does this bug still exist?

vimpostor commented 7 months ago

Yes I can still reproduce this with v0.9.5 following the steps from the description (using a plugin that sets background from the plugin/ directory, e.g. vim-lumen).

ErrorNoInternet commented 7 months ago

I'm still reproducing this on v0.10.0-dev-78b000c, with the nord.nvim colorscheme. My current "fix" is to run echo " " right after setting the colorscheme