rebelot/heirline.nvim

Breaking Changes

Opened this issue · 10 comments

stop_at_first has been superseded by the more versatile pick_child.

To get the same behavior change

...
stop_at_first = true
...

to

...
init = require'heirline.utils'.pick_child_on_condition
...

or

...
init = function(self)
    -- your stuff
    require'heirline.utils'.pick_child_on_condition(self)
end
...

Hello, I changed my statusline definition from:

local Statusline = {
	stop_at_first = true,
	SpecialStatusline,
	TerminalStatusline,
	InactiveStatusline,
	ActiveStatusline,
}

to

local Statusline = {
       init = utils.pick_child_on_condition,
	SpecialStatusline,
	TerminalStatusline,
	InactiveStatusline,
	ActiveStatusline,
}

Only the SpecialStatusline is "rendered" correctly. All others statuslines aren't rendered at all(blank statusline for regular file buffer or terminal buffer).

Neovim version:

❯ nvim --version
NVIM v0.7.0-dev+1027-gf02a5a7bda
Build type: RelWithDebInfo
LuaJIT 2.0.5

Do your statuslines have a condition set? That function breaks the evaluation of children to the first children whose condition evaluates to true, or to the first children that does not have a condition (assuming this latter case is your default for everything else)

That was the exact problem. My statuslines didn't have conditions set directly, but only their children had. Now I defined conditions directly and statuslines are back. Thank you very much for this awesome statusline API.

use of nvim_set_hl

This change passes the hl component field to api function nvim_set_hl, so it takes the same syntax for defining highlights using the api. The only exceptional key supported is force.

This deprecates style and guisp fields

{
    provider = 'Using :highlight',
    hl = { fg = "red", style="bold,underline", guisp='blue'}
}

becomes

{
    provider = 'Using API',
    hl = { fg = "red", bold = true, underline = true, sp='blue' }
}

These changes reflect also to heirline.utils.get_highlight(), which is now a soft wrapper to nvim_get_hl_by_name() that allows indexing the abbreviated keys fg, bg and sp.

Removal of stl field from components

This is quite a technicality and users can safely ignore this breaking change.

The stl field of components has been removed in favor of a more powerful logic to accumulate the statusline output. The last string value of a component can now be retrieved with the method traverse() after it is evaluated.

eg:

local stl = require'heirline.statusline':new({ provider = 'test', hl = "Comment" })
stl:eval()
local out = stl:traverse()

print(out)

Deprecate utils.pick_child_on_condition() in favor of fallthrough.

This change represent a performance improvement, since now there is no need to calculate conditions in advance.

From the cookbook:

local StatusLines = {

    hl = function()
        if conditions.is_active() then
            return "StatusLine"
        else
            return "StatusLineNC"
        end
    end,

    -- the first statusline with no condition, or which condition returns true is used.
    -- think of it as a switch case with breaks to stop fallthrough.
   
    -- init = utils.pick_child_on_condition, -- DEPRECATED --
    fallthrough = false,

    SpecialStatusline, TerminalStatusline, InactiveStatusline, DefaultStatusline,
}

Promote flexible components to builtin and deprecate utils.make_flexible_component

as per 7bd7190, flexible components can now be handled without requiring a special constructor.

old syntax

local flex_comp = utils.make_flexible_component(1, { provider = 'aaaaaaaaa' }, { provider = 'bbb' })

new syntax

local flex_comp = { flexible = 1, { provider = 'aaaaaaaaa' }, { provider = 'bbb' } }

change the function signature of setup(...) to setup(config).

7b57b27

from

    require('heirline').setup(statusline, winbar, tabline)

to

    require('heirline').setup({
        statusline = ...,
        winbar = ..,
        tabline = ...,
        statuscolumn = ...})