Map a key to toggle dynamic resize? #2661
-
Is it possible to map a key that will toggle the dynamic width functionality that you get by setting:
The idea is that I would like a narrow tree most of the time and don't care if some of the file names are too long. However, sometimes I want to see everything, and when I do, I want to toggle the width to be exactly wide enough to fit everything. |
Beta Was this translation helpful? Give feedback.
Answered by
alex-courtis
Feb 3, 2024
Replies: 1 comment 2 replies
-
That is indeed functionality that I am interested in. Try this out. We could add a recipe or some other support. local view_width_max = -1
local function toggle_width_unbounded()
if view_width_max == -1 then
view_width_max = 30
else
view_width_max = -1
end
require("nvim-tree.api").tree.reload()
end
local function get_view_width_max()
return view_width_max
end
vim.keymap.set("n", "<space>f", toggle_width_unbounded, { noremap = true })
require("nvim-tree").setup({
view = {
width = {
min = 30,
max = get_view_width_max,
}
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
brucejxz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is indeed functionality that I am interested in. Try this out. We could add a recipe or some other support.