Skip to content

Map a key to toggle dynamic resize? #2661

Answered by alex-courtis
brucejxz asked this question in Q&A
Discussion options

You must be logged in to vote

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,
    }
  }
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@brucejxz
Comment options

@alex-courtis
Comment options

Answer selected by brucejxz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants