rebelot/heirline.nvim

Support for adding highlight groups

Closed this issue · 10 comments

Hi! im new to heirline and was going through the docs and couldnt found any option for setting a highlight group for a component

image

Feline has that option btw.

Usage:

hl= "Heirline_git"

so if the hl's a string then use the highlight group

Give it a shot! :)

i will! currently the docs look too scary :c . I'll try setting up heirline first

Please let me know if you need help!

@rebelot i was unable to change bg color for the surround so i stopped configuring, it'd be nice to add the highlight group support for the surround characters too

ViMode = utils.surround({ "", "" }, "my highlight group" , ViMode)

like if when a highlight group's specified then take bg/fg of hl group for the surround characters, by default the surround chars take bg color of component right?

Also one query.. it'd be nice to have dynamic padding between components or divide the statusline components in 3 components so we dont have to worry about manully adding spaces between components

local left = { ... } 
local middle = { ... } 
local right = { ... } 

local sections = { left , middle , right }
local statusline = {sections}

Feline has this too, its very helpful!

it'd be nice to add the highlight group support for the surround characters too [...] like if when a highlight group's specified then take bg/fg of hl group for the surround characters

utils.surround takes a string or function -> string as second argument, that's supposed to be a color name or rgb hex code. The reason it cannot support an highlight name is that it's not possible to distinguish between a color name or an highlight group name from its type. However, it's always possible to retrieve colors from highlight groups using utils.get_highlight

ViMode = utils.surround({ "", "" }, utils.get_highlight("my_highlight_group").fg , ViMode)

Also one query.. it'd be nice to have dynamic padding between components or divide the statusline components in 3 components so we dont have to worry about manully adding spaces between components

Absolutely not. The whole idea behind heirline is that users can do almost anything. This has the drawback that common things are slightly more verbose, however hard things become possible, because no opinionated behavior will stand as an obstacle.

What you are asking can be accomplished like this

local align = { provider = "%=" }
local left = { ... } 
local middle = { ... } 
local right = { ... } 

local sections = { left , align, middle, align, right }
local statusline = {sections}

cool.. @rebelot I wanted to set bg for the surround too if possible ;((

What do you mean? The use case is to surround a component with a colored delimiter: the provided color will be used as the foreground of the delimiter and as the background of the surrounded stuff.

Also remember that utils.surround is just an utility, you can do everything "manually" if you need more control:

local mysurroundedcomponent = {
{provider=' <<< ', hl = {...}},
{<your component>},
{provider = '>>>', hl = {...}}
}

you can also nest surrounded blocks:

utils.surround({" ", " "}, 'red', utils.surrund({" ", " "}, "blue", {provider = 'hello'}))

image

This is on feline btw

bg color of the vimode component is grey here
bg color of the light grey separator is grey here and its fg is light grey

how would this be on heirline? theoretically the separator bg would take the bg of the statusline?

It looks ugly 'cause it's nonsense, but you get the idea. Also remember that you don't need to use surround if it's easier to do it manually..

    local surrr = {
        utils.surround({ "", "" }, "red", {
            utils.surround({ "", "" }, "green", utils.surround({ "", "" }, "blue", { provider = "heyya" })),
            { provider = "Normal" },
        }),
    }