rebelot / heirline.nvim

Heirline.nvim is a no-nonsense Neovim Statusline plugin designed around recursive inheritance to be exceptionally fast and versatile.
MIT License
1.05k stars 40 forks source link

Breaking Changes #17

Open rebelot opened 2 years ago

rebelot commented 2 years ago
rebelot commented 2 years ago

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
...
JanValiska commented 2 years ago

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
rebelot commented 2 years ago

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)

JanValiska commented 2 years ago

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.

rebelot commented 2 years ago

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.

rebelot commented 2 years ago

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)
rebelot commented 2 years ago

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,
}
max397574 commented 2 years ago

@rebelot https://github.com/rebelot/heirline.nvim/commit/7bd719094a6b712e02b99e40aacd07c8eae871e2

rebelot commented 2 years ago

Promote flexible components to builtin and deprecate utils.make_flexible_component

as per https://github.com/rebelot/heirline.nvim/commit/7bd719094a6b712e02b99e40aacd07c8eae871e2, 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' } }
rebelot commented 1 year ago

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

7b57b27e9e4d1ffa4f3e149f8fdc927db18a850a

from

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

to

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