Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Changes #17

Open
rebelot opened this issue Feb 7, 2022 · 10 comments
Open

Breaking Changes #17

rebelot opened this issue Feb 7, 2022 · 10 comments

Comments

@rebelot
Copy link
Owner

rebelot commented Feb 7, 2022

@rebelot rebelot pinned this issue Feb 7, 2022
rebelot added a commit that referenced this issue Feb 7, 2022
feat(flexible components)!: introduce components able to expand/contract depending on available window space.
BREAKING CHANGE: stop_at_first is superseded by pick_child see Breaking Changes #17.
@rebelot
Copy link
Owner Author

rebelot commented Feb 7, 2022

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
Copy link

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
Copy link
Owner Author

rebelot commented Feb 7, 2022

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
Copy link

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
Copy link
Owner Author

rebelot commented Apr 26, 2022

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 rebelot unpinned this issue Jun 17, 2022
@rebelot rebelot pinned this issue Jun 17, 2022
@rebelot
Copy link
Owner Author

rebelot commented Aug 29, 2022

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
Copy link
Owner Author

rebelot commented Aug 31, 2022

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
Copy link
Contributor

@rebelot 7bd7190

@rebelot
Copy link
Owner Author

rebelot commented Nov 8, 2022

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' } }

@rebelot
Copy link
Owner Author

rebelot commented Jan 10, 2023

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 = ...})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants