Description
Description
When the first action upon opening Neovim is opening a file in vsplit preview while there is a default empty buffer and then closing all windows except the nvim-tree one, the colorscheme of subsequently opened windows is corrupted (NvimTreeNormal is applied to them). This is probably closely related to Lualine and its globalstatus
configuration parameter.
Neovim version
NVIM v0.10.2
Build type: RelWithDebInfo
LuaJIT 2.1.1725453128
Operating system and version
Linux 6.11.2-arch1-1
Windows variant
No response
nvim-tree version
Clean room replication
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup {
{
"wbthomason/packer.nvim",
"nvim-tree/nvim-tree.lua",
"nvim-tree/nvim-web-devicons",
'nvim-lualine/lualine.nvim'
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
}
end
if vim.fn.isdirectory(install_path) == 0 then
print "Installing nvim-tree and dependencies."
vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
local function ot(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
api.config.mappings.default_on_attach(bufnr)
-- open as vsplit on current node
local function vsplit_preview()
local node = api.tree.get_node_under_cursor()
if node.nodes ~= nil then
-- expand or collapse folder
api.node.open.edit()
else
-- open file as vsplit
api.node.open.vertical()
end
end
vim.keymap.set("n", "o", vsplit_preview, opts("vsplit preview"))
end
require("nvim-tree").setup {
on_attach = ot,
}
require("lualine").setup {
options = {
globalstatus = true,
}
}
end
-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.
-- Requires diagnostics.enable = true in setup.
--[[
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.lsp.start { cmd = { "lua-language-server" } }
end,
})
]]
Steps to reproduce
An extra file with dummy contents is needed in the directory with the clean room config (let's call it a.txt
).
- nvim -nu /tmp/nvt-min.lua
- :NvimTreeToggle
o
on lazy-lock.json- Navigate back to the tree (C-w h)
o
on init.lua, pick window B- Write and close all buffers including the default empty one (:wq or :q)
- Open
a.txt
with either oro
from the tree or using :e a.txt - Verify that the buffer inherits the colorscheme of the tree: :hi NvimTreeNormal guibg=#909090
The issue is not reproduceable with Neotree and without globalstatus = true
in Lualine (or when Lualine is disabled).
The difference in colors is particularly noticeable when NvimTreeNormal significantly differs from the default window background.
Expected behavior
The highlight group is not applied to buffers opened after such operation.
Actual behavior
The opened buffer fully inherits the background and foreground colors of nvim-tree, signified by the NvimTreeNormal.