Skip to content

Commit

Permalink
fix(winbar): make efforts not to setup winbar if window is floating
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelot committed Mar 13, 2023
1 parent 00f7e27 commit 7684d4b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
8 changes: 3 additions & 5 deletions cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Index

<!--toc:start-->

- [Cookbook.md](#cookbookmd)
- [Index](#index)
- [Main concepts](#main-concepts)
Expand Down Expand Up @@ -43,7 +44,7 @@
- [TablineOffset](#tablineoffset)
- [~~Goodbye Bufferline~~Hello Tabline!](#goodbye-bufferlinehello-tabline)
- [Theming](#theming)
<!--toc:end-->
<!--toc:end-->

## Main concepts

Expand Down Expand Up @@ -1552,10 +1553,7 @@ vim.api.nvim_create_autocmd("User", {
pattern = 'HeirlineInitWinbar',
callback = function(args)
local buf = args.buf
local buftype = vim.tbl_contains(
{ "prompt", "nofile", "help", "quickfix" },
vim.bo[buf].buftype
)
local buftype = vim.tbl_contains({ "prompt", "nofile", "help", "quickfix" }, vim.bo[buf].buftype)
local filetype = vim.tbl_contains({ "gitcommit", "fugitive" }, vim.bo[buf].filetype)
if buftype or filetype then
vim.opt_local.winbar = nil
Expand Down
30 changes: 24 additions & 6 deletions lua/heirline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,26 @@ end
local function setup_local_winbar_with_autocmd()
local augrp_id = vim.api.nvim_create_augroup("Heirline_init_winbar", { clear = true })
vim.api.nvim_create_autocmd({ "VimEnter", "BufWinEnter" }, {
callback = function()
if vim.api.nvim_win_get_height(0) > 1 then
vim.opt_local.winbar = "%{%v:lua.require'heirline'.eval_winbar()%}"
vim.api.nvim_exec_autocmds("User", { pattern = "HeirlineInitWinbar", modeline = false })
callback = function(args)
-- local data = { ok = true }

local wins = vim.tbl_filter(function(win)
return vim.api.nvim_win_get_buf(win) == args.buf
end, vim.api.nvim_list_wins())

if vim.api.nvim_win_get_config(wins[0] or 0).zindex then
return
end

-- vim.api.nvim_exec_autocmds("User", { pattern = "HeirlineInitWinbar", modeline = false, data = data })

-- if not data.ok then
-- return
-- end

vim.opt_local.winbar = "%{%v:lua.require'heirline'.eval_winbar()%}"

vim.api.nvim_exec_autocmds("User", { pattern = "HeirlineInitWinbar", modeline = false, data = data })
end,
group = augrp_id,
desc = "Heirline: set window-local winbar",
Expand All @@ -39,15 +54,18 @@ end
---@param config {statusline: StatusLine, winbar: StatusLine, tabline: StatusLine, statuscolumn: StatusLine, opts: table}
function M.setup(config, ...)
if ... then
vim.notify([[
vim.notify(
[[
Heirline: setup() takes only one argument: config
example:
require('heirline').setup({
statusline = ...,
winbar = ..,
tabline = ...,
statuscolumn = ...})
]], vim.log.levels.ERROR)
]],
vim.log.levels.ERROR
)
return
end

Expand Down

0 comments on commit 7684d4b

Please sign in to comment.