nvim-tree.lua-float-preview
nvim-tree.lua-float-preview copied to clipboard
Floating nvim-tree + update_focused_file gives error
When using nvim-tree.lua-float-preview with nvim-tree in the split screen configuration (like in #14), I get this when closing nvim-tree
Error executing Lua callback: ...e/nvim-modular/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:223: Failed to switch to window 1008
stack traceback:
[C]: in function 'nvim_set_current_win'
...e/nvim-modular/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:223: in function 'close'
...e/nvim-modular/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:235: in function 'close_this_tab_only'
...e/nvim-modular/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:248: in function 'close'
...lazy/nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:45: in function 'toggle'
...im-modular/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:36: in function <...im-modular/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:35>
the on_attach for nvim-tree is configured like this:
local api = require "nvim-tree.api"
local FloatPreview = require("float-preview")
FloatPreview.attach_nvimtree(bufnr)
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
local close_wrap = FloatPreview.close_wrap
If I wrap the functions in the close_wrap, the error won't show up, but I have defined a global keymap for :NvimTreeToggle, and that will throw the error regardless. I can perphaps wrap the keymap with the close_wrap globally, but it still won't really solve the issue, just bypass it.
Is there known solution to this?
Hello @Cliffback , I don't know this feature of nvim-tree. May be you can use nvim-tree.update_focused_file.exclude and check if it's float window like?
function(args)
return require("float-preview").is_float(args.buf)
end
Thanks for the reply! The split screen feature is just the one you showcase on the front page like this. Sorry if explanation was a bit misleading.
I basically just set up this, and get the error described above when using :NvimTreeToggle.
I'll check out the provided snippet
hey I got the same issue, fixed by adding modifying the keymap to quit:
-- add the close_wrap func
vim.keymap.set('n', 'q', close_wrap(api.tree.close), opts 'Close')
And same for ESC