Skip to content

Statusline sets highlight groups on every redraw instead of once at colorscheme load #93

@ooloth

Description

@ooloth

Why

The statusline active function calls vim.api.nvim_set_hl three times on every cursor movement, doing redundant API work in one of Neovim's most frequently-invoked paths.

Current state

lua/config/plugins/specs/mini-statusline.lua defines opts.content.active as a function that calls vim.api.nvim_set_hl for MiniStatuslineFilename, MiniStatuslineLspServers, and MiniStatuslineDiagnostics on every invocation (lines 150–152). This function runs on every CursorMoved, ModeChanged, and related events.

Ideal state

  • MiniStatuslineFilename, MiniStatuslineLspServers, and MiniStatuslineDiagnostics highlight groups are set once at colorscheme setup time (e.g., in the catppuccin config callback).
  • The active function returns the composed statusline string without calling nvim_set_hl.
  • Redraws do not make redundant API calls.

Out of scope

  • Changing the colours or logic of the statusline components themselves.

Starting points

  • lua/config/plugins/specs/mini-statusline.lua — lines 150–152 where nvim_set_hl is called inside active
  • lua/config/plugins/specs/catppuccin.lua — where colorscheme-specific highlight overrides are set

QA plan

  1. Open Neovim and move the cursor rapidly — confirm the statusline renders correctly with expected highlight colours.
  2. Run :lua vim.api.nvim_set_hl(0, 'MiniStatuslineFilename', {}) manually to clear the group, then move the cursor — expect the highlight to stay cleared (confirming nvim_set_hl is no longer called on redraw).
  3. Switch colorscheme and move the cursor — expect the custom highlights to reappear via the colorscheme config hook.

Done when

nvim_set_hl is not called inside the statusline active function; all three highlight groups are set at colorscheme-load time only.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions