From ee2ccc1b6747f2088835ffe6863f861d9aedd701 Mon Sep 17 00:00:00 2001 From: bekaboo <18127878294@qq.com> Date: Fri, 23 Aug 2024 01:42:40 -0400 Subject: [PATCH] fix(setup): dropbar attaches to wrong window --- lua/dropbar.lua | 7 ++++++- lua/dropbar/utils/bar.lua | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/dropbar.lua b/lua/dropbar.lua index d85c1cdd..ff61f8a2 100644 --- a/lua/dropbar.lua +++ b/lua/dropbar.lua @@ -61,7 +61,12 @@ local function setup(opts) vim.api.nvim_create_autocmd(configs.opts.general.attach_events, { group = groupid, callback = function(info) - utils.bar.attach(info.buf, 0, info) + -- Try attaching dropbar to all windows containing the buffer + -- Notice that we cannot simply let `win=0` here since the current + -- buffer isn't necessarily the window containing the buffer + for _, win in ipairs(vim.fn.win_findbuf(info.buf)) do + utils.bar.attach(info.buf, win, info) + end end, desc = 'Attach dropbar', }) diff --git a/lua/dropbar/utils/bar.lua b/lua/dropbar/utils/bar.lua index e1963f61..35c7d65a 100644 --- a/lua/dropbar/utils/bar.lua +++ b/lua/dropbar/utils/bar.lua @@ -103,7 +103,7 @@ end ---@param buf integer ---@param info table? info from autocmd function M.attach(buf, win, info) - local configs = require('plugin.winbar.configs') + local configs = require('dropbar.configs') if configs.eval(configs.opts.general.enable, buf, win, info) then vim.wo[win].winbar = '%{%v:lua._winbar.get_winbar()%}' end