focus.nvim icon indicating copy to clipboard operation
focus.nvim copied to clipboard

Make FocusMaxOrEqual work nicely with excluded filetype windows

Open DanielCardonaRojas opened this issue 2 years ago • 2 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
  }

DanielCardonaRojas avatar Dec 05 '21 02:12 DanielCardonaRojas

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

beauwilliams avatar Dec 10 '21 23:12 beauwilliams

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.

DanielCardonaRojas avatar Jan 15 '22 17:01 DanielCardonaRojas

Please try https://github.com/nvim-focus/focus.nvim/tree/refactor

Take a look at the Disabling Focus section: https://github.com/nvim-focus/focus.nvim/tree/refactor#disabling-focus

cryptomilk avatar Jun 03 '23 07:06 cryptomilk

Fixed in current master/main.

cryptomilk avatar Jul 15 '23 06:07 cryptomilk