nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.72k stars 455 forks source link

Feat: add own tabline component separator #1173

Open frolvanya opened 6 months ago

frolvanya commented 6 months ago

Requested feature

Right now we can set component separator for both sections and tabline using one option field called component_separators. Can you, please, add a new field like tabline_separators to provide more customization to users?

Examples:

image image

Motivation

I'd like to have '|' separator in sections (statusline) and empty separator in tabline

williamhCode commented 3 months ago

I tried doing removing the separator for tabline:

  tabline = {
    lualine_a = {
      {
        "tabs",
        separator = "",
        mode = 2,
        path = 0,
      },
    },
  },

Unfortunately did not work. I guess that's for the entire component, not the separator in between tabs.

daephx commented 3 months ago

You might be able to give the buffer component it's own explicit separators?

{
  "buffers",
  -- separators = { left = "", right = "" },
  component_separators = { left = "", right = "" },
  section_separators = { left = "", right = "" },
}

Alternatively, you could use the process_sections function from the master/examples/slanted-gaps.lua example theme if you need to modify the separators for all of the components in one of the tabline/statusline sections.

This has been what I have used for while.

---Override separators for all components
---@param sections table
---@return table
local function process_sections(sections)
  for _, section in pairs(sections) do
    for id, comp in ipairs(section) do
      if type(comp) ~= "table" then
        comp = { comp }
        section[id] = comp
      end
      comp.component_separators = { left = "", right = "" }
      comp.section_separators = { left = "", right = "" }
    end
  end
  return sections
end

If you're using lazy.nvim, you pass this into the config function and overwrite the opts.tabline table before loading lualine.

config = function(_, opts)
  -- NOTE: Modify separators before loading plugin
  -- opts.sections = process_sections(opts.sections)
  opts.tabline = process_sections(opts.tabline)
  require("lualine").setup(opts)
end