nvim-tree.lua
nvim-tree.lua copied to clipboard
feat(view): Floating nvim tree window #1377
This PR adds option to display nvim-tree window as float. Requires setting nvim-tree.actions.open_file.quit_on_open to true to work properly.

References #1377
thanks for the PR :) i think this was asked a lot by people, we could ask them to try it out. https://github.com/kyazdani42/nvim-tree.lua/issues/135
Switching away from the nvim-tree window is problematic as the cursor shows in the nvim-tree window. This is a confusing user experience.
Minimal config with quit_on_open and float.enable set

<C-W>w was used to switch windows.
Practical Proposal quit_on_open is insufficient as it only covers one specific case. Close the nvim-tree window when focus is lost.
gitsigns.nvim behaviour

I agree we could merge a first version and improve on that. I'm not sure all the UX impacts that will raise. Closing the window when leaving it would also be a good addition i think
@Khrees can you commit to ongoing support / fixes / changes for this feature?
Yes, but it will be somewhat limited.
@alex-courtis I have applied your patch and made nvim-tree window close on focus lost.
@alex-courtis I have applied your patch and made nvim-tree window close on focus lost.
Thank you. I can't test / approve until the weekend.
Works beautifully with a variety of options.
Let's see how users like it...
Hi! Testing and it works super well. Could we allow width, height, col and row to be functions that return numbers? So we can calculate on demand this values. My use-case would be to open the float window in the center, with something like:
local screen_w = vim.opt.columns:get()
local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
local _width = screen_w
local _height = screen_h
local width = math.floor(_width)
local height = math.floor(_height)
local center_y = (vim.opt.lines:get() - _height) / 2
local center_x = (screen_w - _width) / 2
Thanks!
Hi! Testing and it works super well. Could we allow width, height, col and row to be functions that return numbers? So we can calculate on demand this values. My use-case would be to open the float window in the center, with something like:
local screen_w = vim.opt.columns:get() local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() local _width = screen_w local _height = screen_h local width = math.floor(_width) local height = math.floor(_height) local center_y = (vim.opt.lines:get() - _height) / 2 local center_x = (screen_w - _width) / 2Thanks!
Very interesting. Rather than individual functions, we could instead have view.float.open_win_config be a function that returns a complete able of options. Please raise a feature request.
Is there a summary for how to enable and test this for someone who just installed the extension?
Is there a summary for how to enable and test this for someone who just installed the extension?
:help nvim-tree.view.float