local sources = require("dropbar.sources")

local function get_hl_color(group, attr)
  return vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID(group)), attr)
end

vim.cmd [[hi WinBar guisp=#665c54 guibg=#313131]]
vim.cmd [[hi WinBarNC guisp=#665c54 guibg=#313131]]

require("dropbar").setup(
  {
    bar = {
      sources = {
        {
          get_symbols = function(buf, win, cursor)
            local symbols = sources.path.get_symbols(buf, win, cursor)
            for _, symbol in ipairs(symbols) do
              -- get correct icon color
              local icon_fg = get_hl_color(symbol.icon_hl, "fg#")
              symbol.icon_hl = "DropbarSymbol" .. symbol.icon_hl

              local icon_string = ""
              -- if icon_fg == "" then
              --   icon_string = "hi " .. symbol.icon_hl .. " guisp=#665c54 guibg=#313131"
              -- else
              --   icon_string = "hi " .. symbol.icon_hl .. " guisp=#665c54 guibg=#313131 guifg=" .. icon_fg
              -- end

              vim.cmd(icon_string)
            end
            return symbols
          end
        }
      }
    }
  }
)
