Closed seblj closed 1 year ago
A hack that seems to work is this:
local blocked_fts = {
"term",
"startify",
"NvimTree",
"packer",
"startuptime",
}
vim.api.nvim_create_autocmd({ "BufWinEnter", "TabNew", "TabEnter", "BufEnter", "WinClosed", "BufWritePost" }, {
group = vim.api.nvim_create_augroup("AttachWinbar", { clear = true }),
desc = "Winbar only on some buffers",
callback = function()
vim.o.winbar = ""
for _, w in pairs(vim.api.nvim_tabpage_list_wins(0)) do
local buf, win = vim.bo[vim.api.nvim_win_get_buf(w)], vim.wo[w]
if
not vim.tbl_contains(blocked_fts, buf.filetype)
and vim.fn.win_gettype(vim.api.nvim_win_get_number(w)) == ""
and buf.buftype == ""
and buf.filetype ~= ""
and not win.diff
then
win.winbar = "%{%v:lua.require'heirline'.eval_winbar()%}"
elseif win.diff then
win.winbar = nil
end
end
end,
})
-- Hack to make it work correctly to disable winbar in certain buffers
vim.api.nvim_create_autocmd("User", {
pattern = "HeirlineInitWinbar",
callback = function()
vim.opt_local.winbar = nil
end,
})
I have used the other autocmd with feline for a while and that has worked flawlessly for me, but it feels really hacky to subscribe to HeirlineInitWinbar
and set winbar to nil
I can't properly disable the winbar on certain buffers, especially in startify which I use for my starting screen.
Minimal config:
If I understand it correctly according to the cookbook, this should disable the winbar in the startify buffer, however it only works sometimes. I suspect this is because the autocmd that sets the winbar is called on
BufWinEnter
andVimEnter
and thatfiletype
is not resolved yet (sometimes). I confirmed this by trying to print out what the filetype was, and sometimes the filetype is empty in both the autocmd and in the first component in the winbar.The winbar also disappears if I press
j
for example.See video below that it sometimes work and sometimes not:
https://user-images.githubusercontent.com/5160701/220169291-835acff3-3001-4b26-87f4-baebaf7bbbe5.mov
Awesome plugin btw!