diff --git a/lua/heirline/statusline.lua b/lua/heirline/statusline.lua index 23bf824..9db097e 100644 --- a/lua/heirline/statusline.lua +++ b/lua/heirline/statusline.lua @@ -26,16 +26,49 @@ local default_restrict = { _win_child_index = true, } +---@alias HeirlineColor string|integer Type: string to hex color code, color alias defined by heirline.load_colors() or fallback to vim standard color name; integer to 24-bit color. +---@alias HeirlineCtermColor string|integer Type: integer to 8-bit color, string to color name alias or default color name. +---@alias HeirlineCtermStyle ("bold"|"underline"|"undercurl"|"underdouble"|"underdotted"|"underdashed"|"strikethrough"|"reverse"|"inverse"|"italic"|"standout"|"altfont"|"nocombine")[]|"NONE" + +---@class HeirlineHighlight +---@field fg? HeirlineColor The foreground color +---@field bg? HeirlineColor The background color +---@field sp? HeirlineColor The underline/undercurl color, if any +---@field bold? boolean +---@field italic? boolean +---@field reverse? boolean +---@field inverse? boolean +---@field standout? boolean +---@field underline? boolean +---@field undercurl? boolean +---@field underdouble? boolean +---@field underdotted? boolean +---@field underdashed? boolean +---@field strikethrough? boolean +---@field altfont? boolean +---@field nocombine? boolean +---@field ctermfg? HeirlineCtermColor The foreground color +---@field ctermbg? HeirlineCtermColor The background color +---@field cterm? HeirlineCtermStyle The special style for cterm +---@field force? boolean Control whether the parent's hl fields will override child's hl + +---@alias HeirlineOnClickCallback fun(self: StatusLine, minwid: integer, nclicks: integer, button: "l"|"m"|"r", mods: string) +---@class HeirlineOnClick +---@field callback? string|HeirlineOnClickCallback +---@field name? string|fun():string +---@field update? boolean +---@field minwid? number|fun():integer + ---@class StatusLine ----@field condition? function ----@field init? function ----@field provider? function | string ----@field hl? table | function | string ----@field restrict? table ----@field after? function ----@field update? function | table ----@field on_click? function | table ----@field id table +---@field condition? fun(self: StatusLine): any +---@field init? fun(self: StatusLine): any +---@field provider? string|number|fun(self: StatusLine):string|number|nil +---@field hl? HeirlineHighlight|string|fun(self: StatusLine): HeirlineHighlight|string|nil controls the colors of what is printed by the component's provider, or by any of its descendants. +---@field restrict? table +---@field after? fun(self: StatusLine): any +---@field update? table|string|fun(self: StatusLine): boolean +---@field on_click? HeirlineOnClickCallback|HeirlineOnClick +---@field id integer[] ---@field winnr integer ---@field fallthrough boolean ---@field flexible integer @@ -44,7 +77,7 @@ local default_restrict = { ---@field _tree table ---@field _updatable_components table ---@field _flexible_components table ----@field pick_child? table +---@field pick_child? integer[] local StatusLine = {} ---Initialize a new statusline object @@ -122,7 +155,7 @@ end --- Get the component where func(component) evaluates to true ---@param func function predicate ----@return StatusLine | nil +---@return StatusLine|nil function StatusLine:find(func) if func(self) then return self