feat(view): Floating nvim tree window #1377#1462
Conversation
| float = { | ||
| enable = false, | ||
| -- options passed to nvim_open_win() | ||
| relative = "editor", | ||
| row = 1, | ||
| col = 1, | ||
| border = "rounded", |
There was a problem hiding this comment.
should be documented. specially because:
Requires setting nvim-tree.actions.open_file.quit_on_open to true to work properly.
There was a problem hiding this comment.
If we require this, quit_on_open should be overridden and set when float.enable is set.
There was a problem hiding this comment.
quit_on_open is now enforced if float.enable is set.
|
thanks for the PR :) i think this was asked a lot by people, we could ask them to try it out. |
|
Switching away from the nvim-tree window is problematic as the cursor shows in the nvim-tree window. This is a confusing user experience.
Practical Proposal |
There was a problem hiding this comment.
Very promising, needs UX improvements: #1462 (comment)
I'm tempted to release this early and resolve bugs / improve UX after users raise issues; I expect there will be a lot. Thoughts @kyazdani42 ?
@khrees can you commit to ongoing support / fixes / changes for this feature?
| float = { | ||
| enable = false, | ||
| -- options passed to nvim_open_win() | ||
| relative = "editor", | ||
| row = 1, | ||
| col = 1, | ||
| border = "rounded", |
There was a problem hiding this comment.
If we require this, quit_on_open should be overridden and set when float.enable is set.
|
I agree we could merge a first version and improve on that. I'm not sure all the UX impacts that will raise. |
Yes, but it will be somewhat limited. |
kyazdani42
left a comment
There was a problem hiding this comment.
LGTM, lets wait for alex's review
There was a problem hiding this comment.
- nvim-tree float is still not closing on window exit
- open up
nvim_open_winconfig
After playing with this for a while, it became clear that the user needs to be able to set all of the config passed to nvim_open_win, rather than the limited config we allow.
Solution is to allow the user to pass all config, rather than just what we specify in the defaults. The user may pass an invalid config to nvim_open_win however they will get a useful error message.
Added float.open_win_config which is no longer validated, however it is merged. Simplified help to match.
Tidied view.lua: just pass the options to open_win.
0001-add-view.float.open_win_config-skipping-validation.patch.txt
|
@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) / 2Thanks! |
Very interesting. Rather than individual functions, we could instead have |
|
Is there a summary for how to enable and test this for someone who just installed the extension? |
|
* Simple mock-up of floating nvim-tree window * Passing whole table to nvim_open_win() * Run update-help.sh * Use vim.api alias * Add comment to float options * Added `anchor` to float options * Enabling float window enforces `actions.open_file.quit_on_open` * Added documentation * add view.float.open_win_config, skipping validation * Made nvim-tree window closes when float is enabled * Close nvim-tree window when out of focus * Update help Co-authored-by: Krzysztof Cieśla <krzysztof.marcin.ciesla@cern.ch> Co-authored-by: Alexander Courtis <alex@courtis.org>


This PR adds option to display nvim-tree window as float. Requires setting
nvim-tree.actions.open_file.quit_on_opentotrueto work properly.References #1377