nvim-tree.lua-float-preview
nvim-tree.lua-float-preview copied to clipboard
TAB still open preview behind float window
Hey, I followed the doc but in my case I still have the preview when using tab.
part of my config: nvim-tree config:
require('nvim-tree').setup {
on_attach = function(bufnr)
local api = require 'nvim-tree.api'
local FloatPreview = require 'float-preview'
local close_wrap = FloatPreview.close_wrap
-- FloatPreview.attach_nvimtree(bufnr)
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- api.node.open.preview = customTreeFunc.open_or_expand_or_dir_up_with_node_no_edit()
-- api.config.mappings.default_on_attach(bufnr)
FloatPreview.attach_nvimtree(bufnr)
customTreeFunc.keymaps(api, close_wrap, opts)
end,
in customTreeFunc.keymaps I have all keymapping and the TAB:
vim.keymap.set('n', '<Tab>', close_wrap(api.node.open.preview), opts 'Open preview')
The only way to fix this was to rewrite the nvim-tree.api.node.open.preview function and comment the edit:
--- Rewrite of nvim-tree open_or_expand_or_dir_up
--- so it does not open the preview in the background
---@param mode string
---@return fun(node: table)
local function open_or_expand_or_dir_up(mode, toggle_group)
local lib = require 'nvim-tree.lib'
local actions = require 'nvim-tree.actions'
return function(node)
if node.name == '..' then
actions.root.change_dir.fn '..'
elseif node.nodes then
lib.expand_or_collapse(node, toggle_group)
end
-- elseif not toggle_group then
-- edit(mode, node)
-- end
end
end
I hope their is e better way can check config: personal kickstart
@jo-pouradier Hello, second variant, you can add this if to pre_open hook
pre_open = function(path)
local is_showed = require("float-preview.utils").is_showed(path)
if is_showed then
return false
end
...
end
It disable show preview for opened file in current tab
Thanks for the reply but it only blocks the floating preview of an already opened file and still gets the normal preview (behind) of other files.