rebelot/heirline.nvim

Requesting utillity to make spacing better

Closed this issue · 4 comments

In the examples given, there are many Space bar items being used.

The problem with this is that if you have an item in the middle of two Space's that renders empty (e.g. not in a git repo) then two spaces are placed in the bar.

There should be a way to build a bar that makes adding a space implicit in joining a list, and elides the space that is associated with an empty object.

OK perhaps a utility isn't really needed. I am finding that just adhering to the convention of

  • space prepended to the left on all left-aligned components except first
  • space appended to the right on all right-aligned components except last

handles the spacing perfectly.
It is still the case that it would be easier if we didn't have to place the spaces ourselves at all though.

Isn't it what utils.insert() is for?

I'm not sure. That seems to be inserting stuff to a table. Is there something that joins that uses a delimiter?

You can add the Space component within the component itself.

local conditional_component = {
  condition = foo(),
  provider = "foo",
  { provider = " "}
}

as @gegoune was suggesting, this can be accomplished more concisely with utils.insert.

local conditional_component = {...}
conditional_component = utils.insert(conditional_component, {provider = " "})

An "automatic" way to concatenate components could be feasible, but probably veery inefficient. I'll think about it