Skip to content

Commit

Permalink
feat: allow customizing section gaps
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Section gaps no longer use the default `bg` color by
default, so the section gap highlights need to be specified manually.
For more info, see:
https://github.com/famiu/feline.nvim/blob/develop/USAGE.md#highlight-section-gaps
  • Loading branch information
famiu committed Sep 27, 2021
1 parent 9a296f0 commit dc18e87
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ You can use component values to customize each component to your liking. Most va

Feline will automatically evaluate the function if it is one. In case a function is provided, the type of the value the function returns must be the same as the type of value required by the component. For example, since [`enabled`](#conditionally-enable-components) requires a boolean value, if you set it to a function, the function must also return a boolean value.

Note that you can omit all of the component values except `provider`, in which case the defaults would be used instead. The different kinds of component values are discussed below.
Note that you can omit all of the component values, in which case the defaults would be used instead. The different kinds of component values are discussed below.

#### Component providers

Expand Down Expand Up @@ -167,6 +167,8 @@ provider = function(_, _, opts)
end
```

If you omit the provider value, it will be set to an empty string. A component with no provider or an empty provider may be useful for things like [applying a highlight to section gaps](#highlight-section-gaps) or just having an icon or separator as a component.

#### Conditionally enable components

The `enabled` value of a component can be a boolean or function. This value determines if the component is enabled or not. If false, the component is not shown in the statusline. If it's a function, it can take either the window handler as an argument, or it can take no arguments. For example:
Expand Down Expand Up @@ -638,6 +640,33 @@ require('feline').reset_highlights()

And then Feline will automatically regenerate those highlights when it needs them, so you don't have to worry about setting the highlights yourself.

### Highlight section gaps

By default, gaps between two sections inherit the highlight of the last element of the section. If you wish to customize the highlight of the gap between two sections, you can just add a component with only an `hl` value to the end of the first section.

For example, if you had two sections in the active statusline and wanted the gap between the first and second section to use a certain background color, you could do this:

```lua
components.active[1] = {
{
-- Insert all components of first section here

-- Component for customizing highlight for the gap between section 1 and 2
{
hl = {
-- Replace 'oceanblue' with whatever color you want the gap to be.
bg = 'oceanblue'
}
}
},
{
-- Insert all components of second section here
}
}
```

It's even simpler if you want to use the default `bg` color for the gap between sections. In that case, you can just put an empty component at the end of the first section. You don't even have the define the `hl` manually since `hl` by default uses the default `bg` as its background.

### Thin line for horizontal splits

If you want, you can have a thin line instead of the inactive statusline to separate your windows, like the vertical window split separator, except in this case it would act as a horizontal window separator of sorts. You can do this through:
Expand Down
2 changes: 1 addition & 1 deletion lua/feline/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function M.generate_statusline(winid)
sections[#sections+1] = parse_statusline_section(section, winid, statusline_type, i)
end

statusline_str = table.concat(sections, string.format('%%#%s#%%=', defhl()))
statusline_str = table.concat(sections, '%=')
end
end

Expand Down

0 comments on commit dc18e87

Please sign in to comment.