Skip to content

[BUG] Focus does no return to current window when closing an edgy.nvim window #174

@diego-velez

Description

@diego-velez

I'm using this plugin along with edgy.nvim.

The issue is that after I close a window that uses edgy (e.g. quickfix list) and the focus comes back to a regular buffer, the focus.nvim options do not come back to the buffer. Meaning that the number column do not turn back on, or the colorcolumn.

This is my focus.nvim config:

return {
  'nvim-focus/focus.nvim',
  lazy = false,
  opts = {
    commands = false,
    autoresize = {
      enable = true, -- Enable or disable auto-resizing of splits
      width = 100, -- Force width for the focused window
      height = 0, -- Force height for the focused window
      minwidth = 80, -- Force minimum width for the unfocused window
      minheight = 0, -- Force minimum height for the unfocused window
      focusedwindow_minwidth = 0, -- Force minimum width for the focused window
      focusedwindow_minheight = 0, -- Force minimum height for the focused window
      height_quickfix = 0, -- Set the height of quickfix panel
    },
    ui = {
      number = true, -- Display line numbers in the focussed window only
      relativenumber = true, -- Display relative line numbers in the focussed window only
      hybridnumber = false, -- Display hybrid line numbers in the focussed window only
      absolutenumber_unfocussed = false, -- Preserve absolute numbers in the unfocussed windows

      cursorline = true, -- Display a cursorline in the focussed window only
      cursorcolumn = false, -- Display cursorcolumn in the focussed window only
      colorcolumn = {
        enable = true, -- Display colorcolumn in the foccused window only
        list = '100', -- Set the comma-saperated list for the colorcolumn
      },
      signcolumn = true, -- Display signcolumn in the focussed window only
      winhighlight = false, -- Auto highlighting for focussed/unfocussed windows
    },
  },
  config = function(_, opts)
    require('focus').setup(opts)

    local ignore_filetypes = { 'neo-tree', 'qf' }
    local ignore_buftypes = { 'nofile', 'prompt', 'popup' }

    local augroup = vim.api.nvim_create_augroup('FocusDisable', { clear = true })

    vim.api.nvim_create_autocmd('WinEnter', {
      group = augroup,
      callback = function(_)
        if vim.tbl_contains(ignore_buftypes, vim.bo.buftype) then
          Focus.focus_disable_window()
        else
          Focus.focus_enable_window()
        end
      end,
      desc = 'Disable focus autoresize for BufType',
    })

    vim.api.nvim_create_autocmd('FileType', {
      group = augroup,
      callback = function(_)
        if vim.tbl_contains(ignore_filetypes, vim.bo.filetype) then
          Focus.focus_disable_buffer()
        else
          Focus.focus_enable_buffer()
        end
      end,
      desc = 'Disable focus autoresize for FileType',
    })
  end,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions