Bekaboo / dropbar.nvim

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

[Bug]: Dropbar flashes when refreshing #170

Closed willdavidow closed 1 month ago

willdavidow commented 1 month ago

Description

I've noticed in the last week or two (without any configuration updates) that my winbar containing dropbar data has started flashing off and then back on after updating.

I'm having a difficult time figuring out if this issue is specfic to dropbar, or something else, but... I've tested by disabling dropbar and using nvim-navic to render my winbar and haven't seen the same thing happening.

nvim version

NVIM v0.11.0-dev-3626+g5fc25ecc7-Homebrew

dropbar.nvim version

6567d50

Operating system and version

Mac OS Sonoma 14.5

Minimal config

-- dropbar config
return {
  "Bekaboo/dropbar.nvim",
  event = "VeryLazy",
  keys = {
    {
      "<leader>w",
      function()
        require("dropbar.api").pick()
      end,
      desc = "Winbar pick",
    },
  },
  opts = function()
    local menu_utils = require "dropbar.utils.menu"

    -- Closes all the windows in the current dropbar.
    local function close()
      local menu = menu_utils.get_current()
      while menu and menu.prev_menu do
        menu = menu.prev_menu
      end
      if menu then
        menu:close()
      end
    end

    return {
      general = {
        attach_events = { "BufWinEnter", "BufWritePost" },
        update_events = {
          win = { "CursorMoved", "CursorMovedI", "WinResized" },
        },
      },
      icons = {
        ui = {
          bar = { separator = "  " },
          menu = { separator = "" },
        },
        kinds = {
          symbols = vim.tbl_map(function(symbol)
            return symbol .. " "
          end, require("wd.icons").kind),
        },
      },
      bar = {
        pick = {
          pivots = "asdfghjklqwertyuiopzxcvbnm",
        },
        sources = function()
          local sources = require "dropbar.sources"
          local utils = require "dropbar.utils.source"

          return {
            -- filename,
            {
              get_symbols = function(buf, win, cursor)
                if vim.api.nvim_get_current_win() ~= win then
                  return {}
                end

                if vim.bo[buf].ft == "markdown" then
                  return sources.markdown.get_symbols(buf, win, cursor)
                end
                return utils.fallback({ sources.lsp, sources.treesitter }).get_symbols(buf, win, cursor)
              end,
            },
          }
        end,
      },
      menu = {
        win_configs = { border = "rounded" },
        keymaps = {
          -- Navigate back to the parent menu.
          ["h"] = "<C-w>c",
          -- Expands the entry if possible.
          ["l"] = function()
            local menu = menu_utils.get_current()
            if not menu then
              return
            end
            local row = vim.api.nvim_win_get_cursor(menu.win)[1]
            local component = menu.entries[row]:first_clickable()
            if component then
              menu:click_on(component, nil, 1, "l")
            end
          end,
          -- "Jump and close".
          ["o"] = function()
            local menu = menu_utils.get_current()
            if not menu then
              return
            end
            local cursor = vim.api.nvim_win_get_cursor(menu.win)
            local entry = menu.entries[cursor[1]]
            local component = entry:first_clickable(entry.padding.left + entry.components[1]:bytewidth())
            if component then
              menu:click_on(component, nil, 1, "l")
            end
          end,
          -- Close the dropbar entirely with <esc> and q.
          ["q"] = close,
          ["<esc>"] = close,
        },
      },
    }
  end,
  config = function(_, opts)
    local bar_utils = require "dropbar.utils.bar"

    require("dropbar").setup(opts)
  end,
}
-- relevant lualine config...
      winbar = {
        lualine_a = {
          {
            "filename",
            path = 4,
            separator = { left = "", right = "" },
            padding = { left = 1, right = 1 },
            draw_empty = false,
          },
          {
            "%{%v:lua.dropbar.get_dropbar_str()%}",
            separator = { left = "", right = "" },
            color = "nil",
            padding = { left = 0, right = 0 },
          },
        },
        lualine_z = { { "filetype" } },
      },

Steps to reproduce

  1. Open any file and move cursor around, causing updates to sources available from LSP.
  2. Notice that after a few seconds dropbar flashes and then re-appears

Expected behavior

Winbar does not flash/flicker.

Actual behavior

Winbar flashes/flickers

Additional information

https://github.com/user-attachments/assets/dee6b79d-883f-46a3-9157-336a2ff46b1d

Bekaboo commented 1 month ago

Thanks for the info! Quite a strange bug, will investigate it later this week.

Could you provide a stripped-down (minimal) version of dropbar and lualine config that reproduce this issue? Currently the lualine config is incomplete and the dropbar config is not minimal.

willdavidow commented 1 month ago

sure, here's my whole lualine config - there's not too much going on here other than a small "last search" function.

local function search_result()
  if vim.v.hlsearch == 0 then
    return ""
  end
  local last_search = vim.fn.getreg "/"
  if not last_search or last_search == "" then
    return ""
  end
  local searchcount = vim.fn.searchcount { maxcount = 9999 }
  return "🔍 " .. last_search .. " (" .. searchcount.current .. "/" .. searchcount.total .. ")"
end
return {
  "nvim-lualine/lualine.nvim",
  event = "VeryLazy",
  dependencies = {
    "AndreM222/copilot-lualine",
    "nvim-tree/nvim-web-devicons",
  },
  config = function()
    local status_mode = require("noice").api.status.mode

    require("lualine").setup {
      options = {
        component_separators = { left = "", right = "" },
        section_separators = { left = "", right = "" },
        ignore_focus = { "neo-tree", "dropbar_menu" },
        theme = "tokyonight",
        globalstatus = false,
      },
      sections = {
        lualine_a = { "branch" },
        lualine_b = {
          {
            status_mode.get,
            cond = status_mode.has,
            color = { fg = "#ff9e64" },
          },
        },
        lualine_c = { "diagnostics", search_result },
        lualine_x = { "copilot" },
        lualine_y = { "progress" },
      },
      winbar = {
        lualine_a = {
          {
            "filename",
            path = 4,
            separator = { left = "", right = "" },
            padding = { left = 1, right = 1 },
            draw_empty = false,
          },
          {
            "%{%v:lua.dropbar.get_dropbar_str()%}",
            separator = { left = "", right = "" },
            color = "nil",
            padding = { left = 0, right = 0 },
          },
        },
        lualine_z = { { "filetype" } },
      },
      inactive_winbar = {},
      extensions = { "quickfix", "man", "fugitive" },
    }
  end,
}
willdavidow commented 1 month ago

@Bekaboo I figured this out just now - it was another plugin that I used to be paired with nvim-navic when I used that, and it was affecting the winbar. It is strange that it just started causing the flashing issue recently (I've been using dropbar exclusively for months), but removing that plugin got rid of the flashing issue.

Apologies for opening the rogue bug report here.

Bekaboo commented 1 month ago

Glad that you solved this problem yourself! 🎉