Skip to content

tabline_conditional_padding

Zeioth edited this page Feb 23, 2024 · 5 revisions

You can add this component to the tabline section of heirline opts.

require("heirline-components.all").component.tabline_conditional_padding()

It applies padding under certain conditions. For example, given the next screenshot screenshot_2024-02-23_21-43-06_942302604

If we open nerdtree, it will apply padding to the tab name: screenshot_2024-02-23_21-41-45_183029696

Available providers

These are the available providers for this component and its options.

-- If it returns 1 or more, add padding. If return false, don't.
condition = function(self)
  self.winid = vim.api.nvim_tabpage_list_wins(0)[1]
  local pattern = (opts and opts.pattern) or {
    filetype = { "aerial", "dapui_.", "dap%-repl", "neo%-tree", "NvimTree", "edgy" },
    buftype = {}
  }
  return condition.buffer_matches(
    pattern,
    vim.api.nvim_win_get_buf(self.winid)
  )
end,
-- Amount of padding is self-caltulated based on the opened panel.
provider = function(self)
  return string.rep(" ", vim.api.nvim_win_get_width(self.winid) + 1)
end,
hl = { bg = "tabline_bg" },

Examples

For example you could change the condition with

component.tabline_conditional_padding({ condition = function() end })

Or how the padding is applied with

component.tabline_conditional_padding({ provider = function() end })

Or the background color of the padding with

component.tabline_conditional_padding({ bg = "#777777" })
Clone this wiki locally