rebelot/heirline.nvim

buffer_matches not working for empty strings

Closed this issue ยท 1 comments

Hey ๐Ÿ‘‹๐Ÿพ
I'm honestly not 100% sure, but I think this used to work in the past. Anyway, I have the "issue" that I want to disable the winbar in buffers that have no filetype. That is for example necessary for the floating diagnostic window. Else diagnostics are partially hidden. So I have the following:

require('heirline').setup({
  opts = {
    disable_winbar_cb = function(args)
      return require('heirline.conditions').buffer_matches({
        buftype = { 'some', 'buffer', 'names' },
        filetype = { 'some', 'filetypes', 'and', '' },
      })
    end
  }
})

The problem is that (now), this empty string pattern will always match. And thereby the winbar is always disabled. So I was in need to write some extra logic myself to manually match the filetype for an empty string in addition to the buffer_matches utility function.

While this all works fine. I was wondering if it might be desirable that this actually works. Having an empty string to match all makes barely sense in any scenario. Else there would be no condition. So maybe this could be resolved in the utility function?

Thanks for this great plugin!

You can catch most plugins and pop-up windows by checking buftype == 'nofile'. Or you can avoid pattern matching and use direct comparison like this:

disable_winbar_cb = function(args)
      return require('heirline.conditions').buffer_matches({
        buftype = { 'some', 'buffer', 'names' },
        filetype = { 'some', 'filetypes', 'and' },
      }) or vim.bo[args.buf].ft == ""
    end