nvim-tree.lua-float-preview icon indicating copy to clipboard operation
nvim-tree.lua-float-preview copied to clipboard

Is the wrap function necessary?

Open haondt opened this issue 2 years ago • 3 comments

Instead of wrapping every keymap, Couldn't you just use the event hooks?

    local api = require('nvim-tree.api')
    local floatpreview = require('float-preview')
    local float_close_wrap = floatpreview.close_wrap

    local Event = api.events.Event
    api.events.subscribe(Event.TreeClose, function()
        float_close_wrap(function() end)()
    end)

haondt avatar Nov 11 '23 11:11 haondt

I didn't know about this nvim-tree feature. I have checked, it's good solution if you don't use window picker. I will try to use this solution soon, I predict we need event like 'open window picker' for best solution.

JMarkin avatar Nov 13 '23 21:11 JMarkin

@haondt Hello, I tested with only events and it isn't work as want. But I think we can move wrapping commands to inside plugin. You can see this idea in https://github.com/JMarkin/nvim-tree.lua-float-preview/pull/10

JMarkin avatar Nov 17 '23 20:11 JMarkin

Fair enough. It works for me fine, fwiw, though I had to use it with vim.schedule to get everything working. I understand my use case might be a bit different since I am using the tree in a floating window too.

api.events.subscribe(Event.TreeClose, function()
        vim.schedule(function ()
            float_close_wrap(function() end)()
        end)
    end)

haondt avatar Nov 17 '23 21:11 haondt