Closed EricDriussi closed 1 year ago
Thanks for including a clear reproduction 🙏 I'm going to look into this.
Unrelated question: why do you relink NeoTreeEndOfBuffer
and NeoTreeNormal
using autocmds? Is there a glitch in the way we support NeoTree? (I'm not a NeoTree user myself so it's useful to get that feedback from actual users.)
The expected behavior is darker background as shown in this piece of code, but you added your custom hi groups which change the background color to the same as normal background.
This bug is caused by the order of loading code in vim. When better performance is disabled, the order of loading code is the following:
But with better performance disabled, this piece of code is place in after/syntax/neo-tree/gruvbox_material.vim
that will only be load when open a neo-tree buffer, so the order of loading code is the following:
after/syntax/neo-tree/gruvbox_material.vim
will be loaded. At this time, the background color is set to darker.There is not a good solution to this problem yet, but there is a dirty hack. You can place your custom code in BufReadPost
event, so your custom code will load after after/syntax/neo-tree/gruvbox_material.vim
has been loaded.
Thanks a lot for getting back! Regarding this
Unrelated question: why do you relink
NeoTreeEndOfBuffer
andNeoTreeNormal
using autocmds? Is there a glitch in the way we support NeoTree? (I'm not a NeoTree user myself so it's useful to get that feedback from actual users.)
I just wanted to change NeoTree's bg color and followed the instructions in the docs.
Now with the knowledge gathered from our lord and savior @sainnhe, I looked around in NeoTree's docs and found this handler which fits nicely with what you described above (thanks a lot by the way).
So I gave it a try and it turns out it also does the job! Here's the updated working config:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup({
{
"nvim-neo-tree/neo-tree.nvim",
cmd = "Neotree",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
opts = {
event_handlers = {
{
event = "after_render",
handler = function()
vim.cmd([[
highlight! link NeoTreeNormal Normal
highlight! link NeoTreeEndOfBuffer Normal
]])
end,
},
},
},
},
{
"sainnhe/gruvbox-material",
lazy = false,
priority = 1000,
},
}, {})
vim.g.gruvbox_material_background = "medium"
vim.g.gruvbox_material_better_performance = 1
vim.api.nvim_command("colorscheme gruvbox-material")
They also provide other "after-type" events that also work by the way, this is just one of them.
It's a less hacky solution, but NeoTree dependent (I understand that this might happen with a lot of other plugins, so the BufReadPost
workaround mentioned above might be a better suit depending on the use case).
In any case, I'm closing the issue since this behavior seems pretty central to how the perf improvement is achieved and there are ways to work around it.
Thanks a lot for the help!
I have done the following steps before reporting this issue:
Operating system/version
Linux 6.2.9-arch1-1
Terminal emulator/version
wezterm 20230712-072601-f4abf8fd
$TERM environment variable
xterm-256color
Tmux version
No response
Feature matrix
Minimal vimrc that can reproduce this bug.
Steps to reproduce this bug using minimal vimrc
:Neotree
Expected behavior
Both bg colors are the same
Actual behavior
bg colors differ (they dont if
vim.g.gruvbox_material_better_performance = 0
)