Skip to content

Status bars

Most plugin surfaces are click-driven menus and buttons. Status bars are different: they show compact, continuously visible information that updates on a timer and as the file manager context changes.

Register one with waydir.register_bar. The update(ctx) function is called on load, every interval seconds, and (unless refresh_on_change = false) whenever its context changes. Return visible = false to hide the bar for the current context.

lua
waydir.register_bar({
  id = "project_status",
  scope = "pane",
  title = "Project",
  icon = "code",
  interval = 10,
  refresh_on_change = true,
  update = function(ctx)
    if not ctx.dir:match("/src") then
      return { visible = false }
    end
    return {
      visible = true,
      items = {
        { type = "badge", text = "src", level = "info" },
        { type = "text", text = ctx.dir },
        { type = "button", id = "refresh", action = "refresh", icon = "refresh", tooltip = "Refresh" },
      },
    }
  end,
})

Scope

ScopeWhere it renders
"global"Above Waydir's bottom status bar. One instance for the window.
"pane"Per pane, above pane status strips such as Git. Receives pane-local context.

Definition

FieldMeaning
idBar id inside this plugin.
scope"global" or "pane".
titleLabel shown at the start of the bar.
iconNamed builtin glyph or bundled image path. See Icons.
intervalRefresh cadence in seconds, clamped between 2 and 3600; 0 disables periodic refresh.
refresh_on_changeRefresh when the context changes (folder, selection, active pane). Defaults to true.
settingsOptional schema merged with the plugin's normal settings.
update(ctx)Returns the current visible state.
click(ctx)Optional handler for button clicks; receives ctx.item_id.

Bar context

Bar ctx includes the usual ctx.dir, ctx.paths, ctx.count, ctx.plugin_dir, and ctx.settings. It also adds:

FieldMeaning
ctx.scope"global" or "pane".
ctx.paneThe pane the bar renders in (pane scope).
ctx.is_activeWhether this pane is the active one.
ctx.item_idIn click(ctx), the id of the clicked button.

Items

update returns items, a list of compact UI elements:

Item typeFields
texttext, optional level
badgetext, optional level
iconicon, optional level
buttonid, optional text, icon, tooltip, action
separatorno fields

level can be info, success, warn, or error.

Buttons

A button emits a click(ctx) call with ctx.item_id set to the button id. A button with action = "refresh" refreshes the bar without calling click - use it for a manual refresh control.

lua
waydir.register_bar({
  id = "counter",
  scope = "global",
  title = "Items",
  update = function(ctx)
    return {
      visible = true,
      items = {
        { type = "text", text = ctx.count .. " selected" },
        { type = "separator" },
        { type = "button", id = "show", text = "Show", icon = "eye" },
      },
    }
  end,
  click = function(ctx)
    if ctx.item_id == "show" then
      waydir.toast(ctx.count .. " items selected")
    end
  end,
})

MIT licensed. Open source.