Bekaboo / dropbar.nvim

IDE-like breadcrumbs, out of the box
GNU General Public License v3.0
1.05k stars 24 forks source link

[Feature]: Synchronize the enabled state of two windows when `scrollbind` #165

Closed ofseed closed 4 months ago

ofseed commented 5 months ago

Problem

When scrollbind is set, we expect that every line of the two windows has a line-to-line relationship, but if one window's winbar is enabled while the other is not, we lose the relationship.

For example, for git blame plugins, the right window shows the file, and the left window shows its corresponding blame information for every line. The line-to-line relation will be broken if the right window has a winbar while the left window does not.

Expected behavior

If one of the two scrollbind windows has the dropbar enabled, the other must be enabled too.

Bekaboo commented 4 months ago

Scroll-bind window synchronization should be handled by nvim IMO. However, as a workaround, you can use the following autocmd to fix this (for fugitive blame window):

vim.api.nvim_create_autocmd('FileType', {
  desc = 'Set local options for fugitive blame buffers.',
  group = vim.api.nvim_create_augroup('FugitiveSettings', {}),
  pattern = 'fugitiveblame',
  callback = function()
    local win_alt = vim.fn.win_getid(vim.fn.winnr('#'))
    vim.opt_local.winbar = vim.api.nvim_win_is_valid(win_alt)
        and vim.wo[win_alt].winbar ~= ''
        and ' '
      or ''
  end,
})