Change the width dynamically without closing the tree #2595
-
Hello everyone! I would like to change the width of the tree view dynamically. For that, I was hopping to create a Which Key keybind that would allow me to set the width based on my liking. For instance, pressing some keybind would allow the tree to be displayed using 30 units, another would allow the tree to dynamically resize the tree based on the largest opened node in terms of width. I know that you can set this in the However, I would like to set this dynamically based on a keybind as stated above. I read in the documentation that it is possible to use the However, doing so also closes the tree. require("nvim-tree").setup({ view = { width = newvaluehere }}) Is it possible to only apply the setting to the current opened tree instead? I tried accessing the properties of the table directly although this is not documented, but as I expected it does not work. require("nvim-tree").view.width = 30 Is it possible to achieve this goal using Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
See There's an event to go with it, however we need to add some API. |
Beta Was this translation helpful? Give feedback.
-
Hi @alex-courtis and thank you for you reply. I looked at the documentation for I also tried the However, using This would be great as a feature of the require("nvim-tree.builtin").resize_width({ dynamic = true }) -- For dynamic width
require("nvim-tree-builtin").resize_width({ size = 30 }) -- For hardcoded width
require("nvim-tree-builtin").resize_width({ offset = 30 }) -- For increased width
require("nvim-tree-builtin").resize_width({ offset = -30 }) -- Fordecreased width Or something similar. |
Beta Was this translation helpful? Give feedback.
-
That's quite a solution! Raised #2598 As usual, contributions are most gratefully appreciated |
Beta Was this translation helpful? Give feedback.
See
:help :NvimTreeResize
There's an event to go with it, however we need to add some API.