Skip to content

Commit

Permalink
feat(statusline): add pick_child list to allow control on which
Browse files Browse the repository at this point in the history
children to execute. This may supersede stop_when.
  • Loading branch information
rebelot committed Jan 25, 2022
1 parent 23a5a5d commit 71e43d4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lua/heirline/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local default_restrict = {
provider = true,
condition = true,
restrict = true,
pick_child = true,
}

local StatusLine = {
Expand Down Expand Up @@ -72,7 +73,6 @@ function StatusLine:get(id)
return curr
end


function StatusLine:nonlocal(attr)
return getmetatable(self).__index(self, attr)
end
Expand Down Expand Up @@ -116,11 +116,22 @@ function StatusLine:eval()
table.insert(stl, hl_str_start .. provider_str .. hl_str_end)
end

for _, child in ipairs(self) do
local out = child:eval()
table.insert(stl, out)
if self.stop_when and self:stop_when(out) then
break
if self.pick_child then
for _, i in ipairs(self.pick_child) do
local child = self[i]
local out = child:eval()
table.insert(stl, out)
if self.stop_when and self:stop_when(out, child) then
break
end
end
else
for _, child in ipairs(self) do
local out = child:eval()
table.insert(stl, out)
if self.stop_when and self:stop_when(out, child) then
break
end
end
end

Expand Down

0 comments on commit 71e43d4

Please sign in to comment.