issue when using with neo-tree float window
doongjohn opened this issue ยท 13 comments
- open neo-tree float window using
:NeoTreeFloat
- buffer gets tinted
- close neo-tree float window by pressing
q
- buffer is still tinted
I was just about to post the same issue, but in my case its not a floating window...
toggle neotree with :Neotree reveal_force_cwd=true toggle=true
:
use the same command to close neotree and the buffer remains tinted:
if I create a new split and switch buffers a few times the problem seems to go away
configs if useful:
I've also seen similar, and it happens with tab movements sometimes as well. Realistically this just means that however a window is being operated on, the way it is closing is not triggering :h WinEnter
for the destination window after the main window is closed.
I'll take a look to see if I can reproduce it, as well as if there is a simple-ish workaround ๐
@doongjohn yes, re-triggering WinEnter
will fix it (the problem in the first place is that when certain windows are closed, this does not happen - an upstream issue as far as I can tell), but you'd have to do that every time any window is closed forcibly. This isn't something I can handle in the plugin here (at least by that same implementation), and would likely need to be changed upstream, or handled by another means in the plugin here (which I am still [slowly] looking into).
One thing you can do to handle it in a more general sense would be to "override" vim.api.nvim_win_close
, like:
local orig = vim.api.nvim_win_close
vim.api.nvim_win_close = function(winid, force)
orig(winid, force)
if force then
vim.schedule(function()
vim.cmd("doautocmd WinEnter")
end)
end
end
which obviously has its flaws.
@levouh could this actually just be an issue relating to something that maybe neo-tree
is doing specifically? I only ever see this issue if I go into a neo-tree window and then leave by toggling the window rather than moving my cursor out. If I move my cursor out manually then this issue doesn't happen. It's almost like the neo tree toggle command does like a noautocmd
so it purposely doesn't trigger the window autocommand ๐ค
@akinsho potentially, and at that it would likely be nui.nvim
rather than neo-tree.nvim
. But given either case, with the following I actually do not see the issue:
local opts = {
plugins = true,
dir = "/tmp/nvim-test",
}
vim.opt.runtimepath:remove(vim.fn.stdpath("config"))
vim.opt.packpath:remove(vim.fn.stdpath("data") .. "/site")
vim.opt.runtimepath:append(vim.fn.expand(opts.dir))
vim.opt.packpath:append(vim.fn.expand(opts.dir))
vim.opt.termguicolors = true
local function install_packer()
local install_path = opts.dir .. "/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
vim.cmd("packadd packer.nvim")
end
local packer = require("packer")
packer.init({
package_root = opts.dir .. "/pack",
compile_path = opts.dir .. "/plugin/packer_compiled.lua",
})
return packer
end
local function chain(funcs)
local timeout = 1000
local inc = 1000
for _, func in ipairs(funcs) do
vim.defer_fn(func, timeout)
timeout = timeout + inc
end
end
local function init()
chain({
function()
vim.cmd("top new | wincmd o")
end,
function()
vim.cmd("Neotree float")
end,
function()
vim.api.nvim_feedkeys("q", "m", true)
end,
})
end
local function setup_plugins(packer)
packer.startup(function(use)
use("wbthomason/packer.nvim")
use("MunifTanjim/nui.nvim")
use("nvim-lua/plenary.nvim")
use("nvim-tree/nvim-web-devicons")
use({
"levouh/tint.nvim",
config = function()
require("tint").setup({})
end,
})
use({
"nvim-neo-tree/neo-tree.nvim",
config = function()
require("neo-tree").setup({})
end,
})
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "PackerComplete" },
callback = function()
init()
end,
})
packer.sync()
end)
end
local function main()
if opts.plugins then
setup_plugins(install_packer())
end
end
main()
when running nvim -u /tmp/init.lua
(where the above is the content of /tmp/init.lua
).
@levouh so I'd actually completely forgotten but this issue doesn't happen at all if I don't lazy load neo-tree
. I usually only load it when I run the command to first open the tree.
Gotcha, that works. Thanks @akinsho. The only change is to add cmd = { "Neotree" }
to the configuration of neo-tree.nvim
, but for the sake of completeness the "minimal reproduction" is now:
local opts = {
plugins = true,
dir = "/tmp/nvim-test",
}
vim.opt.runtimepath:remove(vim.fn.stdpath("config"))
vim.opt.packpath:remove(vim.fn.stdpath("data") .. "/site")
vim.opt.runtimepath:append(vim.fn.expand(opts.dir))
vim.opt.packpath:append(vim.fn.expand(opts.dir))
vim.opt.termguicolors = true
local function install_packer()
local install_path = opts.dir .. "/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
vim.cmd("packadd packer.nvim")
end
local packer = require("packer")
packer.init({
package_root = opts.dir .. "/pack",
compile_path = opts.dir .. "/plugin/packer_compiled.lua",
})
return packer
end
local function chain(funcs)
local timeout = 1000
local inc = 1000
for _, func in ipairs(funcs) do
vim.defer_fn(func, timeout)
timeout = timeout + inc
end
end
local function init()
chain({
function()
vim.cmd("top new | wincmd o")
end,
function()
vim.cmd("Neotree float")
end,
function()
vim.api.nvim_create_autocmd({ "WinEnter", "WinClosed" }, {
group = vim.api.nvim_create_augroup("_tmp", { clear = true }),
pattern = { "*" },
callback = function(ev)
print(string.format("event fired: %s", vim.inspect(ev)))
end,
})
end,
function()
vim.api.nvim_feedkeys("q", "m", true)
end,
})
end
local function setup_plugins(packer)
packer.startup(function(use)
use("wbthomason/packer.nvim")
use("MunifTanjim/nui.nvim")
use("nvim-lua/plenary.nvim")
use("nvim-tree/nvim-web-devicons")
use({
"levouh/tint.nvim",
config = function()
require("tint").setup({})
end,
})
use({
"nvim-neo-tree/neo-tree.nvim",
cmd = { "Neotree" },
config = function()
require("neo-tree").setup({})
end,
})
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "PackerComplete" },
callback = function()
init()
end,
})
packer.sync()
end)
end
local function main()
if opts.plugins then
setup_plugins(install_packer())
end
end
main()
Will try to mess around with the involved plugins to see whats up ASAP. Thanks for the patience all.
@sho-87 @akinsho @doongjohn in your experience, does this only happen when closing floating windows?
@levouh I don't use the floating window functionality of neotree at all, so definitely happens even without floats
same. i have mine docked to the left and use toggle to open/close it. no floats