nvim-focus/focus.nvim

Make FocusMaxOrEqual work nicely with excluded filetype windows

Closed this issue · 4 comments

Hey @beauwilliams thanks again for this awesome plugin,

I while ago you implemented a feature request I made for completly expanding windows, I've been using it daily. I have encountered one issue though, I'm using nvim-tree and toggleterm for openning terminal at the bottom.

Having either nvim-tree or terminal open if I do FocusMaxOrEqual to collapse back excluded windows won't be resized back to their initial size.

Two options come to mind which might be left configurable if possible:

  • Don't assume excluded windows as available screen space
  • Remember sizes of excluded windows when expanding.

This is my config:

  use { "beauwilliams/focus.nvim",
    config = function()
      require("focus").setup({
        excluded_filetypes = {'toggleterm', 'Trouble', 'NvimTree', 'dapui_scopes', 'dapui_breakpoints', 'dapui_stacks'},
        signcolumn = false
      })
      vim.cmd [[ FocusDisable ]]
    end,
    setup = function()
      vim.api.nvim_set_keymap("n", '<c-w>=', ':FocusMaxOrEqual <CR>', {})
    end
  }

This is a tough one. There really is not much that can be done to address this with built in vim features, as it involves using the standard vim command to equalize windows wincmd=

Now, remembering the sizes of excluded windows could be possible. It would require quite a bit of work, I actually had this issue earlier trying to implement a better resizing function, finding that there was simply a lack of API to remember widths of windows and set them later. Let me look into it

Another idea would be to just expose a callback willExpand or something to manually close excluded split windows like terminal and file tree before maxing out the window.

Fixed in current master/main.